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
20 # length of sample file in seconds
22 if [ "$2" = "" ] ; then
27 # use 'fade' effect for smooth start and end of tone
30 # a different default volume
40 if [ "$1" = "" ] ; then
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
54 #summarize file numbers
62 FADE
=" fade $FT $LEN $FT"
64 TC
="$(( $TC + $LEN ))"
66 if [ $FC -lt 10 ] ; then
67 NAME
="${PRE}_0${FC}_${1}${OFT}"
69 NAME
="${PRE}_${FC}_${1}${OFT}"
75 #empty / delete list file
80 # ok, lets start with the actual creation of the files
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"
94 newname
"${f}hz" $LENGTH
95 $SOX $SOXOPT $NAME synth
$LEN sine
$f $FADE $VOL
102 # need some mark every octave
105 FREQ
="55-14080" # 8 oct
106 FREQ
="13.75-28160" # 10 oct
109 TGES
="$(( $OCT * $TOCT ))"
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
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
121 FREQ
="22050 11025 5512.5 "
122 echo "\n--- different frequencies $FREQ"
124 newname
"cd${f}hz" $LENGTH
125 $SOX $SOXOPT $NAME synth
$LEN sine
$f $FADE $VOL
130 # similar frequencies
134 echo "\n--- similar frequencies"
135 newname
${FREQ1}_
${FREQ2} $LENGTH
136 $SOX $SOXOPT $NAME synth
$LEN sine
$FREQ1 synth sine mix
$FREQ2 $FADE $VOL
139 newname
${FREQ1}_
${FREQ2} $LENGTH
140 $SOX $SOXOPT $NAME synth
$LEN sine
$FREQ1 synth sine mix
$FREQ2 $FADE $VOL
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
158 FREQ
="100 1000 10000"
159 echo "\n--- square waves at $FREQ"
161 newname
${f}_square
$LENGTH
162 $SOX $SOXOPT $NAME synth
$LEN square
$f vol
-12 db
$FADE
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"
174 newname
${f}_
${d}db
$LENGTH
175 $SOX $SOXOPT $NAME synth
$LEN sine
$f vol
-$d db
$FADE
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"
193 DB
=100 # 10sec for 10db
194 echo "\n--- volume sweep 0..100% at Frequencies $FREQ"
196 newname
${f}_dbsweep
200
197 $SOX $SOXOPT $NAME synth
$LEN sine
$f synth exp amod
0.005 0 0 50 $DB
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"
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
224 # phase error between channels
225 FREQ
="100 1000 10000"
226 # equal phase/ 24 degrees / 90 degrees / 180 degrees
228 echo "\n--- phase error test between channels at $FREQ "
231 newname
${f}hz_phase
${p} $LENGTH
232 $SOX $SOXOPT $NAME synth
$LEN sine
$f 0 0 sine
$f 0 $p $FADE $VOL
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"