wav: adpcm: stricter header validation [bug #265]
[sox.git] / scripts / testcd.sh
blobadf727eb69718fe95168d0e907861da2c4119754
1 #!/bin/sh
2 # create WAV-Files that can be used to create an audio Test CD
4 # The intent of this Test CD is to allow you to test the reproduction
5 # quality and response of an audio system by playing back audio
6 # of various frequencies and power levels. Browse through the
7 # script comments to see what all audio files are created.
9 # all files are created in the current directory
11 # Command Line options:
12 # testcd.sh filename_prefix audio_length
14 # filename_prefix is what each soundfile starts with. Defaults to
15 # using testcd as the prefix.
16 # audio_length is the length of audio data in seconds. Defaults to 30
17 # seconds.
20 # length of sample file in seconds
22 if [ "$2" = "" ] ; then
23 LENGTH="30"
24 else
25 LENGTH=$2
27 # use 'fade' effect for smooth start and end of tone
28 FT="0.05"
30 # a different default volume
31 VOL=""
33 #output file type
34 OFT=".wav"
36 #our binary
37 SOX=../src/sox
39 # filenameprefix
40 if [ "$1" = "" ] ; then
41 PRE="testcd"
42 else
43 PRE=$1;
45 # 2 channel 16 bit signed linear int with CD sampling rate
46 SOXOPT="-c 2 -r 44100 -e signed-integer -b 16 -n"
48 # file with list of filenames
49 LST="${PRE}.lst"
52 #summarise seconds
53 TC="0"
54 #summarize file numbers
55 FC="0"
58 newname()
60 FC="$(( $FC + 1 ))"
61 LEN="$2"
62 FADE=" fade $FT $LEN $FT"
64 TC="$(( $TC + $LEN ))"
66 if [ $FC -lt 10 ] ; then
67 NAME="${PRE}_0${FC}_${1}${OFT}"
68 else
69 NAME="${PRE}_${FC}_${1}${OFT}"
71 echo -n -e " \t$1"
72 echo "$NAME" >>$LST
75 #empty / delete list file
76 echo "" >$LST
80 # ok, lets start with the actual creation of the files
84 # fixed frequencies,
85 FREQ=" 19.4 23.1 27.5 32.7 38.9 46.2"
86 FREQ="$FREQ 55.0 64.4 77.8 92.5 110.0 130.8 155.6 185.0"
87 FREQ="$FREQ 220.0 261.6 311.1 367.0 440.0 523.3 622.3 740.0"
88 FREQ="$FREQ 880.0 1046 1245 1480 1760 2093 2489 2960"
89 FREQ="$FREQ 3520 4186 4978 5920 7040 8372 9956 11840"
90 FREQ="$FREQ 14080 16744 19912"
91 #FREQ="5 10 20 50 100 200 500 1000 2000 5000 10000 20000"
92 echo "\n--- different frequencies"
93 for f in $FREQ; do
94 newname "${f}hz" $LENGTH
95 $SOX $SOXOPT $NAME synth $LEN sine $f $FADE $VOL
96 done
101 # frequency sweep
102 # need some mark every octave
104 FREQ="220-3520" #4
105 FREQ="55-14080" # 8 oct
106 FREQ="13.75-28160" # 10 oct
107 OCT=10
108 TOCT=10
109 TGES="$(( $OCT * $TOCT ))"
110 MARKFREQ=622
111 echo "\n--- frequency sweep range $FREQ"
112 newname ${FREQ}hz $TGES
113 $SOX $SOXOPT $NAME synth $LEN sine $MARKFREQ synth square amod 0.1 0 97 94 vol -3 db synth $LEN sine mix $FREQ $VOL
115 FREQ="3520-220"
116 FREQ="28160-13.75" # 9 oct
117 newname ${FREQ}hz $TGES
118 $SOX $SOXOPT $NAME synth $LEN sine $MARKFREQ synth square amod 0.1 0 97 94 vol -3 db synth $LEN sine mix $FREQ $VOL
120 # CD frequencies
121 FREQ="22050 11025 5512.5 "
122 echo "\n--- different frequencies $FREQ"
123 for f in $FREQ; do
124 newname "cd${f}hz" $LENGTH
125 $SOX $SOXOPT $NAME synth $LEN sine $f $FADE $VOL
126 done
130 # similar frequencies
132 FREQ1="9000"
133 FREQ2="10000"
134 echo "\n--- similar frequencies"
135 newname ${FREQ1}_${FREQ2} $LENGTH
136 $SOX $SOXOPT $NAME synth $LEN sine $FREQ1 synth sine mix $FREQ2 $FADE $VOL
137 FREQ1="440"
138 FREQ2="445"
139 newname ${FREQ1}_${FREQ2} $LENGTH
140 $SOX $SOXOPT $NAME synth $LEN sine $FREQ1 synth sine mix $FREQ2 $FADE $VOL
143 #noise
145 echo "\n--- noise"
146 newname whitenoise $LENGTH
147 $SOX $SOXOPT $NAME synth $LEN whitenoise $FADE $VOL
148 newname pinknoise $LENGTH
149 $SOX $SOXOPT $NAME synth $LEN pinknoise $FADE $VOL
150 newname brownnoise $LENGTH
151 $SOX $SOXOPT $NAME synth $LEN brownnoise $FADE $VOL
156 # square waves
158 FREQ="100 1000 10000"
159 echo "\n--- square waves at $FREQ"
160 for f in $FREQ; do
161 newname ${f}_square $LENGTH
162 $SOX $SOXOPT $NAME synth $LEN square $f vol -12 db $FADE
163 done
167 # different volumes at a few frequencies
169 FREQ="100 1000 10000"
170 DB="0 12 24 36 48 60 72 84 96"
171 echo "\n--- different volumes $DB db at Frequencies $FREQ"
172 for f in $FREQ; do
173 for d in $DB; do
174 newname ${f}_${d}db $LENGTH
175 $SOX $SOXOPT $NAME synth $LEN sine $f vol -$d db $FADE
176 done
177 done
179 # silence
180 echo "\n-- silence"
181 newname silence $LENGTH
182 $SOX $SOXOPT $NAME synth $LEN sine 1000 vol 0
188 # volume sweep at different frequencies
191 FREQ="100 1000 10000"
192 MARKFREQ=662
193 DB=100 # 10sec for 10db
194 echo "\n--- volume sweep 0..100% at Frequencies $FREQ"
195 for f in $FREQ; do
196 newname ${f}_dbsweep 200
197 $SOX $SOXOPT $NAME synth $LEN sine $f synth exp amod 0.005 0 0 50 $DB
198 done
202 # offset test - a 1K sine with 1Hz square offset of 10%
204 echo "\n--- offset test, 1KHz tone with 1HZ 10% offset"
205 newname offset $LENGTH
206 $SOX $SOXOPT $NAME synth $LEN square 1 vol 0.1 synth sine mix 1000 $FADE $VOL
207 newname offset1 $LENGTH
208 $SOX $SOXOPT $NAME synth $LEN square 1 0 0 square 1 vol 0.1 $FADE
212 # effects for different channels
214 # silence on one channel, full power on the other - different frequencies
215 FREQ="100 1000 10000"
216 echo "\n--- single channel"
217 for f in $FREQ; do
218 newname ${f}leftchan $LENGTH
219 $SOX $SOXOPT $NAME synth $LEN sine $f synth square amod 0 100 square amod 0 0 $Fade $VOL
220 newname ${f}rightchan $LENGTH
221 $SOX $SOXOPT $NAME synth $LEN sine $f synth square amod 0 0 square amod 0 100 $Fade $VOL
222 done
224 # phase error between channels
225 FREQ="100 1000 10000"
226 # equal phase/ 24 degrees / 90 degrees / 180 degrees
227 PHASE="25"
228 echo "\n--- phase error test between channels at $FREQ "
229 for f in $FREQ; do
230 for p in $PHASE; do
231 newname ${f}hz_phase${p} $LENGTH
232 $SOX $SOXOPT $NAME synth $LEN sine $f 0 0 sine $f 0 $p $FADE $VOL
233 done
234 done
238 # end - show statistics
241 echo "\n------------------\ncreated $FC files with prefix $PRE type $OFT"
242 MIN="$(( $TC / 60 ))"
243 echo "total length is $TC sec = $MIN min"
244 #---------