1SoX(7)                          Sound eXchange                          SoX(7)
2
3
4

NAME

6       soxexam - SoX Examples
7

EXAMPLES

9   Introduction
10       The  core  problem is that you need some experience in using effects in
11       order to say `that any old sound file sounds  with  effects  absolutely
12       hip'. There isn't any rule-based system which tell you the correct set‐
13       ting of all the parameters for every effect.  But after some  time  you
14       will become an expert in using effects.
15
16       Here are some examples which can be used with any music sample.  (For a
17       sample where only a single instrument  is  playing,  extreme  parameter
18       setting  may  make  well-known `typically' or `classical' sounds. Like‐
19       wise, for drums, vocals or guitars.)
20
21       Single effects will be explained and some given parameter settings that
22       can  be  used  to  understand the theory by listening to the sound file
23       with the added effect.
24
25       Using multiple effects in parallel or in series can result either in  a
26       very  nice sound or (mostly) in a dramatic overloading in variations of
27       sounds such that your ear may follow the sound but you will feel unsat‐
28       isfied.  Hence, for the first time using effects try to compose them as
29       minimally as possible. We don't regard the composition  of  effects  in
30       the  examples because too many combinations are possible and you really
31       need a very fast machine and a lot of memory to play them in real-time.
32
33       However, real-time playing of sounds will  greatly  speed  up  learning
34       and/or  tuning  the  parameter settings for your sounds in order to get
35       that `perfect' effect.
36
37       Basically, we will use the `play' front-end of SoX since it  is  easier
38       to listen sounds coming out of the speaker or earphone instead of look‐
39       ing at cryptic data in sound files.
40
41       For easy listening of file.xxx (`xxx' is any sound format):
42
43            play file.xxx effect-name effect-parameters
44
45       Or more SoX-like (for `dsp' output on a UNIX/Linux computer):
46
47            sox file.xxx -t ossdsp -2 -s /dev/dsp  effect-name  effect-parame‐
48       ters
49
50       or (for `au' output):
51
52            sox  file.xxx -t sunau -2 -s /dev/audio effect-name effect-parame‐
53       ters
54
55       And for date freaks:
56
57            sox file.xxx file.yyy effect-name effect-parameters
58
59       Additional options can be used. However, in this  case,  for  real-time
60       playing you'll need a very fast machine.
61
62       Notes:
63
64       I  played  all  examples  in  real-time on a Pentium 100 with 32 MB and
65       Linux 2.0.30 using a self-recorded sample ( 3:15 min long in `wav' for‐
66       mat  with  44.1 kHz sample rate and stereo 16 bit ).  The sample should
67       not contain any of the effects. However, if you take any recording of a
68       sound track from radio or tape or CD, and it sounds like a live concert
69       or ten people are playing the same rhythm with their  drums  or  funky-
70       grooves,  then  take any other sample.  (Typically, less then four dif‐
71       ferent instruments and no synthesizer in the sample is suitable.  Like‐
72       wise, the combination vocal, drums, bass and guitar.)
73
74   Echo
75       An  echo effect can be naturally found in the mountains, standing some‐
76       where on a mountain and shouting a single word will result  in  one  or
77       more  repetitions of the word (if not, turn a bit around and try again,
78       or climb to the next mountain).
79
80       However, the time difference between  shouting  and  repeating  is  the
81       delay  (time),  its loudness is the decay. Multiple echos can have dif‐
82       ferent delays and decays.
83
84       It is very popular to use echos  to  play  an  instrument  with  itself
85       together, like some guitar players (Queen's Brain May) or vocalists do.
86       For music samples of more than one instrument, echo can be used to  add
87       a second sample shortly after the original one.
88
89       This  will sound as if you are doubling the number of instruments play‐
90       ing in the same sample:
91
92            play file.xxx echo 0.8 0.88 60 0.4
93
94       If the delay is very short, then it sound like a (metallic) robot play‐
95       ing music:
96
97            play file.xxx echo 0.8 0.88 6 0.4
98
99       Longer delay will sound like an open air concert in the mountains:
100
101            play file.xxx echo 0.8 0.9 1000 0.3
102
103       One mountain more, and:
104
105            play file.xxx echo 0.8 0.9 1000 0.3 1800 0.25
106
107   Echos
108       Like  the  echo  effect,  echos stand for `ECHO in Sequel', that is the
109       first echos takes the input, the second the input and the first  echos,
110       the  third the input and the first and the second echos, ... and so on.
111       Care should be taken using many  echos  (see  introduction);  a  single
112       echos has the same effect as a single echo.
113
114       The sample will be bounced twice in symmetric echos:
115
116            play file.xxx echos 0.8 0.7 700 0.25 700 0.3
117
118       The sample will be bounced twice in asymmetric echos:
119
120            play file.xxx echos 0.8 0.7 700 0.25 900 0.3
121
122       The sample will sound as if played in a garage:
123
124            play file.xxx echos 0.8 0.7 40 0.25 63 0.3
125
126   Chorus
127       The  chorus effect has its name because it will often be used to make a
128       single vocal sound like a chorus.  But  it  can  be  applied  to  other
129       instrument samples too.
130
131       It  works  like the echo effect with a short delay, but the delay isn't
132       constant.  The delay is varied using a sinusoidal or triangular modula‐
133       tion.  The  modulation  depth  defines the range the modulated delay is
134       played before or after the delay. Hence the delayed  sound  will  sound
135       slower  or  faster, that is the delayed sound tuned around the original
136       one, like in a chorus where some vocals are a bit out of tune.
137
138       The typical delay is around 40ms to 60ms, the speed of  the  modulation
139       is best near 0.25Hz and the modulation depth around 2ms.
140
141       A single delay will make the sample more overloaded:
142
143            play file.xxx chorus 0.7 0.9 55 0.4 0.25 2 -t
144
145       Two delays of the original samples sound like this:
146
147            play file.xxx chorus 0.6 0.9 50 0.4 0.25 2 -t 60 0.32 0.4 1.3 -s
148
149       A big chorus of the sample is (three additional samples):
150
151            play  file.xxx  chorus 0.5 0.9 50 0.4 0.25 2 -t 60 0.32 0.4 2.3 -t
152       40 0.3 0.3 1.3 -s
153
154   Flanger
155       The flanger effect is like the chorus  effect,  but  the  delay  varies
156       between  0ms  and  maximal  5ms.  It sound like wind blowing, sometimes
157       faster or slower including changes of the speed.
158
159       The flanger effect is widely used in funk and  soul  music,  where  the
160       guitar sound varies frequently slow or a bit faster.
161
162       Now, let's groove the sample:
163
164            play file.xxx flanger
165
166       listen  carefully  between  the difference of sinusoidal and triangular
167       modulation:
168
169            play file.xxx flanger triangle
170
171   Reverb
172       The reverb effect is often used in audience hall which are to small  or
173       contain too many many visitors which disturb (dampen) the reflection of
174       sound at the walls.  Reverb will make the sound be perceived as  if  it
175       were  in  a large hall.  You can try the reverb effect in your bathroom
176       or garage or sport hall by shouting loud some words.  You'll  hear  the
177       words reflected from the walls.
178
179       The  biggest  problem in using the reverb effect is the correct setting
180       of the (wall) delays such that the sound is realistic and doesn't sound
181       like  music  playing  in  a  tin  can  or has overloaded feedback which
182       destroys any illusion of playing in a big hall.   To  help  you  obtain
183       realistic  reverb  effects, you should decide first how long the reverb
184       should take place until it is not loud enough to be registered by  your
185       ears.  This  is  be  done  by varying the reverb time `t'.  To simulate
186       small halls, use 200ms.  To simulate large halls, use 1000ms.  Clearly,
187       the walls of such a hall aren't far away, so you should define its set‐
188       ting be given every wall its delay time.  However, if the  wall  is  to
189       far away for the reverb time, you won't hear the reverb, so the nearest
190       wall will be best at `t/4' delay and the farthest at `t/2'. You can try
191       other  distances as well, but it won't sound very realistic.  The walls
192       shouldn't stand to close to each other and not in  a  multiple  integer
193       distance  to each other ( so avoid wall like: 200 and 202, or something
194       like 100 and 200 ).
195
196       Since audience halls do have a lot of walls, we  will  start  designing
197       one beginning with one wall:
198
199            play file.xxx reverb 1 600 180
200
201       One wall more:
202
203            play file.xxx reverb 1 600 180 200
204
205       Next two walls:
206
207            play file.xxx reverb 1 600 180 200 220 240
208
209       Now, why not a futuristic hall with six walls:
210
211            play file.xxx reverb 1 600 180 200 220 240 280 300
212
213       If  you  run out of machine power or memory, then stop as many applica‐
214       tions as possible (every interrupt will consume a lot of CPU time which
215       for bigger halls is absolutely necessary).
216
217   Phaser
218       The  phaser  effect  is  like  the flanger effect, but it uses a reverb
219       instead of an echo and does phase shifting. You'll hear the  difference
220       in  the  examples  comparing both effects.  The delay modulation can be
221       sinusoidal or triangular, preferable is the later for multiple  instru‐
222       ments.  For single instrument sounds, the sinusoidal phaser effect will
223       give a sharper phasing effect.  The decay shouldn't be to  close  to  1
224       which  will  cause dramatic feedback.  A good range is about 0.5 to 0.1
225       for the decay.
226
227       We will take a parameter setting as before  (gain-out  is  lower  since
228       feedback can raise the output dramatically):
229
230            play file.xxx phaser 0.8 0.74 3 0.4 0.5 -t
231
232       The drunken loudspeaker system (now less alcohol):
233
234            play file.xxx phaser 0.9 0.85 4 0.23 1.3 -s
235
236       A popular sound of the sample is as follows:
237
238            play file.xxx phaser 0.89 0.85 1 0.24 2 -t
239
240       The sample sounds if ten springs are in your ears:
241
242            play file.xxx phaser 0.6 0.66 3 0.6 2 -t
243
244   Compander
245       The  compander  effect  allows the dynamic range of a signal to be com‐
246       pressed or expanded.  For most situations, the attack time (response to
247       the music getting louder) should be shorter than the decay time because
248       our ears are more sensitive to suddenly loud  music  than  to  suddenly
249       soft music.
250
251       For  example,  suppose  you  are  listening  to  Strauss's `Also Sprach
252       Zarathustra' in a noisy environment such as a car.  If you turn up  the
253       volume  enough  to hear the soft passages over the road noise, the loud
254       sections will be too loud.  You could try this:
255
256            play file.xxx compand 0.3,1 -90,-90,-70,-70,-60,-20,0,0 -5 0 0.2
257
258       The transfer function (`-90,...') says that very  soft  sounds  between
259       -90  and  -70 decibels (-90 is about the limit of 16-bit encoding) will
260       remain unchanged.  That keeps the compander from boosting the volume on
261       `silent'  passages  such  as between movements.  However, sounds in the
262       range -60 decibels to 0 decibels (maximum volume) will  be  boosted  so
263       that  the  60dB  dynamic range of the original music will be compressed
264       3-to-1 into a 20dB range, which is wide enough to enjoy the  music  but
265       narrow  enough  to get around the road noise.  The -5 dB output gain is
266       needed to avoid clipping (the number is inexact,  and  was  derived  by
267       experimentation).   The  0  for the initial volume will work fine for a
268       clip that starts with a bit of silence, and the delay of  0.2  has  the
269       effect  of  causing the compander to react a bit more quickly to sudden
270       volume changes.
271
272       The following (one long) command shows  how  multi-band  companding  is
273       typically used in FM radio:
274
275            play file.xxx
276            vol -3 db filter 8000- 32 100 mcompand "0.005,0.1
277            -47,-40,-34,-34,-17,-33 0 0 0" 100 "0.003,0.05
278            -47,-40,-34,-34,-17,-33 0 0 0" 400 "0.000625,0.0125
279            -47,-40,-34,-34,-15,-33 0 0 0" 1600 "0.0001,0.025
280            -47,-40,-34,-34,-31,-31,-0,-30 0 0 0" 6400
281            "0,0.025 -38,-31,-28,-28,-0,-25 0 0 0" vol 27 db vol -12
282            db highpass 22 highpass 22 filter -17500 256 vol +12 db
283            vol -3 db lowp 17801
284
285       The  audio file is played with a simulated FM radio sound (or broadcast
286       signal condition if the lowp at the end is  skipped).   Note  that  the
287       pipeline is set up with US-style 75us preemphasis.
288
289   Changing the Rate of Playback
290       You  can  use stretch to change the rate of playback of an audio sample
291       while preserving the pitch.  For example to play at half the speed:
292
293            play file.wav stretch 2
294
295       To play a file at twice the speed:
296
297            play file.wav stretch 0.5
298
299       Other related options are `speed' to change  the  speed  of  play  (and
300       changing  the  pitch  accordingly),  and pitch, to alter the pitch of a
301       sample.  For example to speed a sample so it plays  in  half  the  time
302       (for those Mickey Mouse voices):
303
304            play file.wav speed 2
305
306       To raise the pitch of a sample 1 while note (100 cents):
307
308            play file.wav pitch 100
309
310
311   Reducing noise in a recording
312       First find a period of silence in your recording, such as the beginning
313       or end of a piece. If the  first  1.5  seconds  of  the  recording  are
314       silent, do
315
316            sox file.wav -n trim 0 1.5 noiseprof /tmp/profile
317
318       Next, use the noisered effect to actually reduce the noise:
319
320            play file.wav noisered /tmp/profile
321
322   Making a recording
323       Thanks to Douglas Held for the following suggestion:
324
325            rec parameters filename other-effects silence 1 5 2%
326
327       This  use of the silence effect allows you to start a recording session
328       but only start writing to disk once non-silence is detect. For example,
329       use  this  to  start  your favorite command line for recording and walk
330       over to your record player and start the song.  No periods  of  silence
331       will be recorded.
332
333   Scripting with SoX
334       One of the benefits of a command-line tool is that it is easy to use it
335       in scripts to perform more complex tasks.  In marine  radio,  a  Mayday
336       emergency call is transmitted preceded by a 30-second alert sound.  The
337       alert sound comprises two audio tones at 1300Hz and 2100Hz  alternating
338       at  a rate of 4Hz.  The following shows how SoX can be used in a script
339       to construct an audio file containing the alert sound.   The  scripting
340       language shown is `Bourne shell' (sh) but it should be simple to trans‐
341       late this to another scripting language if you do not  have  access  to
342       sh.
343
344       # Make sure we append to a file that's initially empty:
345       rm -f 2tones.raw
346
347       for freq in 1300 2200; do
348         sox -c1 -r8000 -n -t raw - synth 0.25 sine $freq vol 0.7 >> 2tones.raw
349         done
350
351       # We need 60 copies of 2tones.raw (0.5 sec) to get 30 secs of audio:
352       iterations=60
353
354       # Make sure we append to a file that's initially empty:
355       rm -f alert.raw
356
357       while [ $iterations -ge 1 ]; do
358         cat 2tones.raw >> alert.raw
359         iterations=`expr $iterations - 1`
360         done
361
362       # Add a file header and save some disc space:
363       sox -sw -c1 -r8000 alert.raw alert.ogg
364
365       play alert.ogg
366
367       If you try out the above script, you may want to hit Ctrl-C fairly soon
368       after the alert tone starts playing - it's not a pleasant  sound!   The
369       synth  effect is used to generate each of the tones; -c1 -r8000 selects
370       mono, 8kHz sampling-rate audio (i.e. relatively low fidelity,  suitable
371       for the marine radio transmission channel); each tone is generated at a
372       length of 0.25 seconds to give the required 4Hz alternation.  Note  the
373       use  of  `raw'  as  the  intermediary  file  format;  a self-describing
374       (header) format would just get in the way  here.   The  self-describing
375       header  is added only at the final stage; in this case, .ogg is chosen,
376       since lossy compression is appropriate for this application.
377
378       There are further practical examples of scripting with SoX available to
379       download from the SoX web-site [1].
380

SEE ALSO

382       sox(1), libst(3)
383
384   References
385       [1]    SoX    -    Sound   eXchange   |   Scripts,   http://sox.source
386              forge.net/Docs/Scripts
387

AUTHORS

389       This   man   page   was   written   largely    by    Juergen    Mueller
390       (jmueller@uia.ua.ac.be).  Other SoX authors and contributors are listed
391       in the AUTHORS file that is distributed with the source code.
392
393
394
395soxexam                        January 31, 2007                         SoX(7)
Impressum