shithub: sox

Download patch

ref: 8873f38b8b4a2ef5210e6b6c870d184f005ae70e
parent: 3eecb25cb1c46a7cc1159f6f9b7c87874f399571
author: robs <robs>
date: Sun Dec 17 04:19:28 EST 2006

Make dither alias for mask

--- a/ChangeLog
+++ b/ChangeLog
@@ -41,7 +41,9 @@
     circumstances. (robs)
   o Add support for 24-bit PCM raw, wav (WAVE_FORMAT_EXTENSIBLE) [FR# 801015],
     au, aiff, & flac files. (robs)
-  o Added alias -1 (for -b), -2 (for -w), -4 (for -l), -8 (for -d). (robs)
+  o Added aliases -1 (for -b), -2 (for -w), -4 (for -l), -8 (for -d),
+    dither (for mask). (robs)
+  o Dither/mask amount now specifiable.  (robs)
   o Remove old, optional rate change and alaw/ulaw conversion code.
     (Reuben Thomas)
   o Make sox and soxmix a single binary.  (Reuben Thomas)
--- a/README
+++ b/README
@@ -66,7 +66,7 @@
   o Apply a high-pass filter
   o Apply a low-pass filter
   o Apply an equalizer effect
-  o Add masking noise to a signal
+  o Add dithering/masking noise to a signal
   o Multi-band compander
   o Pan sound between channels
   o Apply a phaser effect
--- a/TODO
+++ b/TODO
@@ -18,9 +18,6 @@
     will prevent corrupt files from causing sox to go into
     an infinite loop trying to read just a couple more bytes.
 
-  o Make "dither" an alias of "mask" since that's how most
-    people refer to this process.
-
   o Make "mix" an alias of "avg" since that's closer to what it
     really is.  For 2->2 mixes, make a 2 option L->L and R->R
     shortcut.  Similar 4 option for 4->4.
--- a/sox.1
+++ b/sox.1
@@ -152,12 +152,12 @@
 into a Microsoft .WAV file, while
 .P
 .br
-	sox -v 0.5 file.au -r 12000 file.wav mask
+	sox -v 0.5 file.au -r 12000 file.wav dither
 .P
 .br
 does the same format translation but also 
 lowers the amplitude by 1/2, changes
-the sampling rate to 12000 Hz, and applies the \fBmask\fR sound effect
+the sampling rate to 12000 Hz, and applies the \fBdither\fR sound effect
 to the audio data.
 .P
 The following will mix two sound files together to to produce a single sound
@@ -1020,6 +1020,17 @@
 This effect supports the \fI-o\fR option (see above).
 
 .TP 10
+dither [\fIdepth\fR]
+Dithering deliberately adds white noise to the signal
+in order to mask audible quantization effects that
+can occur if the output sample size is less than 24 bits.
+By default, the amount of noise added is 1/2 bit;
+the optional \fIdepth\fR parameter is a (linear or voltage)
+multiplier of this amount.
+
+This effect should not be followed by any other effect that
+affects the audio.
+.TP 10
 earwax
 Makes sound easier to listen to on headphones.
 Adds audio-cues to samples in audio CD format so that
@@ -1140,14 +1151,9 @@
 lowpass \fIfrequency\fB
 See the description of the \fIhighpass\fR effect for details.
 .TP 10
-mask
-Add "masking noise" to signal.
-This effect deliberately adds white noise to a sound 
-in order to mask quantization effects,
-created by the process of playing a sound digitally.
-It tends to mask buzzing voices, for example.
-It adds 1/2 bit of noise to the sound file at the
-output bit depth.
+mask [\fIdepth\fR]
+This effect is just an alias of the "dither" effect but is left
+here for historical reasons.
 .TP
 mcompand "\fIattack1,decay1\fR[,\fIattack2,decay2\fR...]
 .TP 
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -95,6 +95,7 @@
   st_copy_effect_fn,
   st_dcshift_effect_fn,
   st_deemph_effect_fn,
+  st_dither_effect_fn,
   st_earwax_effect_fn,
   st_echo_effect_fn,
   st_echos_effect_fn,
--- a/src/play.in
+++ b/src/play.in
@@ -80,7 +80,7 @@
       --file=FILENAME          specify filename
 
 EFFECTs are one or more of the following: avg, band, bandpass, bandreject,
-bass, chorus, compand, copy, dcshift, deemph, earwax, echo, echos,
+bass, chorus, compand, copy, dcshift, deemph, dither, earwax, echo, echos,
 equalizer, fade, filter, flanger, highpass, highp, lowpass, lowp, mask,
 mcompand, noiseprof, noisered, pan, phaser, pick, pitch, polyphase,
 rabbit, rate, repeat, resample, reverb, reverse, silence, speed, speedr,
@@ -94,7 +94,7 @@
 # loop over arguments
 while [ $# -ne 0 ]; do
     case "$1" in
-	avg|band|bandpass|bandreject|bass|chorus|compand|copy|dcshift|deemph|earwax|echo|echos|equalizer|fade|filter|flanger|highpass|highp|lowpass|lowp|mask|mcompand|noiseprof|noisered|pan|phaser|pick|pitch|polyphase|rabbit|rate|repeat|resample|reverb|reverse|silence|speed|speedr|stat|stretch|swap|synth|treble|trim|vibro|vol)
+	avg|band|bandpass|bandreject|bass|chorus|compand|copy|dcshift|deemph|dither|earwax|echo|echos|equalizer|fade|filter|flanger|highpass|highp|lowpass|lowp|mask|mcompand|noiseprof|noisered|pan|phaser|pick|pitch|polyphase|rabbit|rate|repeat|resample|reverb|reverse|silence|speed|speedr|stat|stretch|swap|synth|treble|trim|vibro|vol)
 	    effects="$@"
 	    break
 	    ;;