shithub: sox

Download patch

ref: ef75a218af2fb6da7935ba65a892f28ad59a0e29
parent: 7633af3c8826efa2ae799a64c65855aded814145
author: Rob Sykes <robs@users.sourceforge.net>
date: Tue Mar 13 09:39:02 EDT 2012

remove code for compatibility with old versions of sox; default to 1dB of head-room

--- a/scripts/testtones.sh
+++ b/scripts/testtones.sh
@@ -38,15 +38,12 @@
 #   the test-tones.
 #
 # Other parameters can be changed in the Configuration section below.
-#
-# Note: this script has been tested with SoX 14.3.0.  It works
-# to a lesser extent with 14.2.0.
 
 
 
 # Configuration:
 
-sox=../src/sox		# Where is sox?  E.g. sox, /usr/local/bin/sox
+sox="../src/sox"	# Where is sox?  E.g. sox, /usr/local/bin/sox
 type=wav		# File type, e.g. flac, cdda
 rate=44100		# Default sample rate
 #chans2="-c 2"		# Uncomment for all files to have 2 channels
@@ -53,8 +50,8 @@
 part_octave=6		# 5 for harmonic split, 6 for true half octave
 tone_length=36		# In seconds; not used for sweeps
 fade_time=.05		# Fade in/out time (for smooth start and end of tone)
-#gain="gain -9"		# Uncomment for different default volume
-#NDD=-D			# Uncomment to disable TPDF default dither (v14.3.0)
+gain="gain -1"		# Headroom for playpack chain
+#NDD=-D			# Uncomment to disable TPDF default dither
 vol_dither="-f ge"	# Type of dither to be used for volume tests
 plot=yes		# Uncomment to enable PNG plots
 
@@ -62,8 +59,8 @@
 
 plot()
 {
-  [ -n "$plot" ] && [ -n "$name" ] && $sox $D "$name" -n \
-    spectrogram -w kaiser -o "`basename "$name" $type`png"
+  [ -n "$plot" ] && [ -n "$name" ] && $sox -D "$name" -n \
+    spectrogram -h -w kaiser -o "`basename "$name" $type`png"
 }
 
 
@@ -88,11 +85,6 @@
 
 # Initialisation:
 
-soxver=`$sox --version | sed "s/.* v//" `       # Find out sox version
-major=`echo $soxver | cut -d . -f1`
-minor=`echo $soxver | cut -d . -f2`
-soxver=$(($major * 100 + $minor))		# Ignore patch number
-
 [ -n "$1" ] && rate="$1"
 [ -n "$2" ] && tone_length="$2"
 
@@ -104,9 +96,6 @@
 
 freqs="100 1k 10k"
 input="$sox $NDD -r $rate -n"
-[ $soxver -ge 1403 ] && H=-h
-[ $soxver -ge 1403 ] && D=-D
-[ $soxver -ge 1403 ] && J="-j 0"
 
 echo "Creating test audio files with sample-rate = $rate"
 
@@ -115,7 +104,7 @@
 echo; echo "Silence:"
 
 next_file silence
-$input $D $output trim 0 $length
+$input -D $output trim 0 $length
 
 
 
@@ -140,7 +129,7 @@
   else
     next_file %$note
   fi
-  $input $output synth $J sine %$note $fade $gain
+  $input $output synth -j 0 sine %$note $fade $gain
   note=$(($note + $part_octave))
   part_octave=$((12 - $part_octave))
 done
@@ -174,7 +163,7 @@
   $input $output synth sine %30 \
              synth sine amod 8.333333333333333333 0 $phase1 \
 	     synth squa amod 0.08333333333333333333 0 $phase2 1 gain -9 \
-	     synth $length sine mix $freq gain $H 3 $gain
+	     synth $length sine mix $freq gain -h 3 $gain
   phase1=41.66666666666666667
   phase2=42.66666666666666667
 done
@@ -206,42 +195,29 @@
 for freq in $freqs; do
   for att in 12 24 36 48 60 72 84 96 108; do
     next_file ${freq}hz_${att}dB_att
-    $input $output synth $length sine $freq gain $H -$att $fade dither $vol_dither
+    $input $output synth $length sine $freq gain -h -$att $fade dither $vol_dither
   done
 done
 
 
 
-if [ $soxver -ge 1403 ]; then
-  echo; echo "Sweep volume @ 1dB/s, -108->0->-108dB, with a mark (-40dB) every 12dB:"
+echo; echo "Sweep volume @ 1dB/s, -108->0->-108dB, with a mark (-40dB) every 12dB:"
 
-  for freq in $freqs; do
-    next_file ${freq}hz_108dB-sweep 216
-    $input $output synth $length sin $freq sin %30 \
-	       synth squ amod 0 100 sine amod 8.333333333333333333 0 75 \
-	       synth exp amod 0.00462962962962962963 0 0 50 54 \
-		     squ amod 0.08333333333333333333 0 1 1 \
-	       remix 1v.99,2v.01 dither $vol_dither
-  done
-else
-  echo; echo "Sweep volume @ 1dB/s, -96->0->-96dB, with a mark (-40dB) every 12dB:"
+for freq in $freqs; do
+  next_file ${freq}hz_108dB-sweep 216
+  $input $output synth $length sin $freq sin %30 \
+             synth squ amod 0 100 sine amod 8.333333333333333333 0 75 \
+             synth exp amod 0.00462962962962962963 0 0 50 54 \
+      	     squ amod 0.08333333333333333333 0 1 1 \
+             remix 1v.99,2v.01 dither $vol_dither
+done
 
-  for freq in $freqs; do
-    next_file ${freq}hz_96dB-sweep 198
-    $input $output synth $length sin $freq sin %30 \
-	       synth squ amod 0 100 sine amod 8.333333333333333333 0 75 \
-	       synth exp amod 0.005050505050505050505 0 0 50 96 \
-		     squ amod 0.08333333333333333333 0 1 1 \
-	       remix 1v.99,2v.01 dither $vol_dither
-  done
-fi
 
 
-
 echo; echo "1kHz tone offset with 1Hz:"
 
 next_file offset_10%_square
-$input $output synth $length square 1 sine 1000 remix 1v0.05,2v0.95 gain $H 0 $fade $gain
+$input $output synth $length square 1 sine 1000 remix 1v0.05,2v0.95 gain -h 0 $fade $gain
 next_file offset_50%_sine
 $input $output synth $length sine 1 synth sine mix 1000 $fade $gain
 
@@ -251,9 +227,9 @@
 
 for freq in $freqs; do
   next_file ${freq}hz_left-chan
-  $input $output synth $length sine $freq remix 1 0 gain $H 0 $fade $gain
+  $input $output synth $length sine $freq remix 1 0 gain -h 0 $fade $gain
   next_file ${freq}hz_right-chan
-  $input $output synth $length sine $freq remix 0 1 gain $H 0 $fade $gain
+  $input $output synth $length sine $freq remix 0 1 gain -h 0 $fade $gain
 done
 
 
@@ -269,35 +245,33 @@
 
 
 
-if [ $soxver -ge 1403 ]; then
-  echo; echo "Plucked scale:"
+echo; echo "Plucked scale:"
 
-  options=
-  overdrive="gain -3"
-  for f in pluck pluck_dist; do
-    next_file $f 42
-    note=-29
-    :>tmp.s32
-    
-    while [ $note -lt 17 ]; do
-      $input -t s32 - synth .4 pluck %$note $options >> tmp.s32
-      note=$(($note + 1))
-    done
-    $input -t s32 - synth 1.2 pluck %$note $options >> tmp.s32
-    
-    while [ $note -gt -29 ]; do
-      $input -t s32 - synth .4 pluck %$note $options >> tmp.s32
-      note=$(($note - 1))
-    done
-    $input -t s32 - synth pluck %$note $options fade t 0 4 3.6 >> tmp.s32
+options=
+overdrive="gain -3"
+for f in pluck pluck_dist; do
+  next_file $f 42
+  note=-29
+  :>tmp.s32
+  
+  while [ $note -lt 17 ]; do
+    $input -t s32 - synth .4 pluck %$note $options >> tmp.s32
+    note=$(($note + 1))
+  done
+  $input -t s32 - synth 1.2 pluck %$note $options >> tmp.s32
+  
+  while [ $note -gt -29 ]; do
+    $input -t s32 - synth .4 pluck %$note $options >> tmp.s32
+    note=$(($note - 1))
+  done
+  $input -t s32 - synth pluck %$note $options fade t 0 4 3.6 >> tmp.s32
 
-    $sox -r $rate -c 1 tmp.s32 $output $overdrive remix 1 1 reverb 30
+  $sox -r $rate -c 1 tmp.s32 $output $overdrive remix 1 1 reverb 30
 
-    rm -f tmp.s32
-    options="0 0 60 75 0"
-    overdrive="overdrive gain -10"
-  done
-fi
+  rm -f tmp.s32
+  options="0 0 60 75 0"
+  overdrive="overdrive gain -10"
+done