ref: 3af10ea0b4079495d640e9c615ce15cbdbb49460
parent: 0ac9f7f715bc5740ba06adcfc69eadf2f85457b1
author: Ulrich Klauer <ulrich@chirlu.de>
date: Mon Jan 28 20:16:51 EST 2013
Some cleanup of example scripts
--- a/scripts/crossfade.sh
+++ b/scripts/crossfade.sh
@@ -72,7 +72,7 @@
echo "crossfade and concatenate files"
echo
echo "Finding length of $first_file..."
-first_length=`$SOX "$first_file" 2>&1 -n stat | grep Length | cut -d : -f 2 | cut -f 1`
+first_length=`$SOX --info -D "$first_file"`
echo "Length is $first_length seconds"
trim_length=`echo "$first_length - $fade_length" | bc`
@@ -85,8 +85,8 @@
# When user specifies "auto" try to guess if a fadeout is needed.
# "RMS amplitude" from the stat effect is effectively an average
# value of samples for the whole fade length file. If it seems
-# quite then assume a fadeout has already been done. An RMS value
-# of 0.1 was just obtained from trail and error.
+# quiet then assume a fadeout has already been done. An RMS value
+# of 0.1 was just obtained from trial and error.
if [ "$fade_first" == "auto" ]; then
RMS=`$SOX fadeout1.wav 2>&1 -n stat | grep RMS | grep amplitude | cut -d : -f 2 | cut -f 1`
should_fade=`echo "$RMS > 0.1" | bc`
--- a/scripts/crossfade_cat.sh
+++ b/scripts/crossfade_cat.sh
@@ -66,7 +66,7 @@
echo "crossfade and concatenate files"
echo
echo "Finding length of $first_file..."
-first_length=`$SOX "$first_file" 2>&1 -n stat | grep Length | cut -d : -f 2 | cut -f 1`
+first_length=`$SOX --info -D "$first_file"`
echo "Length is $first_length seconds"
trim_length=`echo "$first_length - $fade_length" | bc`
@@ -78,8 +78,8 @@
# When user specifies "auto" try to guess if a fadeout is needed.
# "RMS amplitude" from the stat effect is effectively an average
# value of samples for the whole fade length file. If it seems
-# quite then assume a fadeout has already been done. An RMS value
-# of 0.1 was just obtained from trail and error.
+# quiet then assume a fadeout has already been done. An RMS value
+# of 0.1 was just obtained from trial and error.
if [ "$fade_first" == "auto" ]; then
RMS=`$SOX fadeout1.wav 2>&1 -n stat | grep RMS | grep amplitude | cut -d : -f 2 | cut -f 1`
should_fade=`echo "$RMS > 0.1" | bc`
--- a/scripts/synth.sh
+++ b/scripts/synth.sh
@@ -35,15 +35,15 @@
s="$sox -q -n -p synth 0 0 1 60 90"
l="$sox -q -n -p synth 0 0 0 50 20"
-b="$sox -np synth 0 0 0 30 20 pl"
+b="$sox -n -p synth 0 0 0 30 20 pl"
c3="fade h 0 .75"
c="fade h 0 .25"
cs="fade h 0 .25 .05"
m="fade h 0 .5"
sb="fade h 0 1"
-r="$sox -np trim 0 .25"
-r2="$sox -np trim 0 .5"
-r3="$sox -np trim 0 .75"
+r="$sox -n -p trim 0 .25"
+r2="$sox -n -p trim 0 .5"
+r3="$sox -n -p trim 0 .75"
$sox -m -v .8 \
"|$sox \
--- a/scripts/testcd.sh
+++ b/scripts/testcd.sh
@@ -15,7 +15,8 @@
# using testcd as the prefix.
# audio_length is the length of audio data in seconds. Defaults to 30
# seconds.
-#
+
+
# length of sample file in seconds
if [ "$2" = "" ] ; then
@@ -33,7 +34,7 @@
OFT=".wav"
#our binary
-SOX=../src/sox
+SOX=../src/sox
# filenameprefix
if [ "$1" = "" ] ; then
@@ -59,13 +60,13 @@
FC="$(( $FC + 1 ))"
LEN="$2"
FADE=" fade $FT $LEN $FT"
-
+
TC="$(( $TC + $LEN ))"
-
+
if [ $FC -lt 10 ] ; then
- NAME="${PRE}_0${FC}_${1}${OFT}"
+ NAME="${PRE}_0${FC}_${1}${OFT}"
else
- NAME="${PRE}_${FC}_${1}${OFT}"
+ NAME="${PRE}_${FC}_${1}${OFT}"
fi
echo -n -e " \t$1"
echo "$NAME" >>$LST
@@ -80,7 +81,7 @@
#
#
-# fixed frequencies,
+# fixed frequencies,
FREQ=" 19.4 23.1 27.5 32.7 38.9 46.2"
FREQ="$FREQ 55.0 64.4 77.8 92.5 110.0 130.8 155.6 185.0"
FREQ="$FREQ 220.0 261.6 311.1 367.0 440.0 523.3 622.3 740.0"
@@ -88,7 +89,7 @@
FREQ="$FREQ 3520 4186 4978 5920 7040 8372 9956 11840"
FREQ="$FREQ 14080 16744 19912"
#FREQ="5 10 20 50 100 200 500 1000 2000 5000 10000 20000"
-echo -e "\n--- different frequencies"
+echo "\n--- different frequencies"
for f in $FREQ; do
newname "${f}hz" $LENGTH
$SOX $SOXOPT $NAME synth $LEN sine $f $FADE $VOL
@@ -107,7 +108,7 @@
TOCT=10
TGES="$(( $OCT * $TOCT ))"
MARKFREQ=622
-echo -e "\n--- frequency sweep range $FREQ"
+echo "\n--- frequency sweep range $FREQ"
newname ${FREQ}hz $TGES
$SOX $SOXOPT $NAME synth $LEN sine $MARKFREQ synth square amod 0.1 0 97 94 vol -3 db synth $LEN sine mix $FREQ $VOL
@@ -118,7 +119,7 @@
# CD frequencies
FREQ="22050 11025 5512.5 "
-echo -e "\n--- different frequencies $FREQ"
+echo "\n--- different frequencies $FREQ"
for f in $FREQ; do
newname "cd${f}hz" $LENGTH
$SOX $SOXOPT $NAME synth $LEN sine $f $FADE $VOL
@@ -130,7 +131,7 @@
#
FREQ1="9000"
FREQ2="10000"
-echo -e "\n--- similar frequencies"
+echo "\n--- similar frequencies"
newname ${FREQ1}_${FREQ2} $LENGTH
$SOX $SOXOPT $NAME synth $LEN sine $FREQ1 synth sine mix $FREQ2 $FADE $VOL
FREQ1="440"
@@ -140,14 +141,14 @@
#
#noise
-#
-echo -e "\n--- noise"
+#
+echo "\n--- noise"
newname whitenoise $LENGTH
$SOX $SOXOPT $NAME synth $LEN whitenoise $FADE $VOL
newname pinknoise $LENGTH
$SOX $SOXOPT $NAME synth $LEN pinknoise $FADE $VOL
newname brownnoise $LENGTH
-$SOX $SOXOPT $NAME synth $LEN brownnoise $FADE $VOL
+$SOX $SOXOPT $NAME synth $LEN brownnoise $FADE $VOL
@@ -155,8 +156,8 @@
# square waves
#
FREQ="100 1000 10000"
-echo -e "\n--- square waves at $FREQ"
-for f in $FREQ; do
+echo "\n--- square waves at $FREQ"
+for f in $FREQ; do
newname ${f}_square $LENGTH
$SOX $SOXOPT $NAME synth $LEN square $f vol -12 db $FADE
done
@@ -165,9 +166,9 @@
#
# different volumes at a few frequencies
#
-FREQ="100 1000 10000"
+FREQ="100 1000 10000"
DB="0 12 24 36 48 60 72 84 96"
-echo -e "\n--- different volumes $DB db at Frequencies $FREQ"
+echo "\n--- different volumes $DB db at Frequencies $FREQ"
for f in $FREQ; do
for d in $DB; do
newname ${f}_${d}db $LENGTH
@@ -176,7 +177,7 @@
done
# silence
-echo -e "\n-- silence"
+echo "\n-- silence"
newname silence $LENGTH
$SOX $SOXOPT $NAME synth $LEN sine 1000 vol 0
@@ -190,7 +191,7 @@
FREQ="100 1000 10000"
MARKFREQ=662
DB=100 # 10sec for 10db
-echo -e "\n--- volume sweep 0..100% at Frequencies $FREQ"
+echo "\n--- volume sweep 0..100% at Frequencies $FREQ"
for f in $FREQ; do
newname ${f}_dbsweep 200
$SOX $SOXOPT $NAME synth $LEN sine $f synth exp amod 0.005 0 0 50 $DB
@@ -200,7 +201,7 @@
#
# offset test - a 1K sine with 1Hz square offset of 10%
#
-echo -e "\n--- offset test, 1KHz tone with 1HZ 10% offset"
+echo "\n--- offset test, 1KHz tone with 1HZ 10% offset"
newname offset $LENGTH
$SOX $SOXOPT $NAME synth $LEN square 1 vol 0.1 synth sine mix 1000 $FADE $VOL
newname offset1 $LENGTH
@@ -212,7 +213,7 @@
#
# silence on one channel, full power on the other - different frequencies
FREQ="100 1000 10000"
-echo -e "\n--- single channel"
+echo "\n--- single channel"
for f in $FREQ; do
newname ${f}leftchan $LENGTH
$SOX $SOXOPT $NAME synth $LEN sine $f synth square amod 0 100 square amod 0 0 $Fade $VOL
@@ -224,7 +225,7 @@
FREQ="100 1000 10000"
# equal phase/ 24 degrees / 90 degrees / 180 degrees
PHASE="25"
-echo -e "\n--- phase error test between channels at $FREQ "
+echo "\n--- phase error test between channels at $FREQ "
for f in $FREQ; do
for p in $PHASE; do
newname ${f}hz_phase${p} $LENGTH
@@ -237,7 +238,7 @@
# end - show statistics
#
-echo -e "\n------------------\ncreated $FC files with prefix $PRE type $OFT"
+echo "\n------------------\ncreated $FC files with prefix $PRE type $OFT"
MIN="$(( $TC / 60 ))"
echo "total length is $TC sec = $MIN min"
#---------
--- a/scripts/testtones.sh
+++ b/scripts/testtones.sh
@@ -162,8 +162,8 @@
next_file ${freq}_sweep 127
$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 squa amod 0.08333333333333333333 0 $phase2 1 gain -9 \
+ synth $length sine mix $freq gain -h 3 $gain
phase1=41.66666666666666667
phase2=42.66666666666666667
done
@@ -208,7 +208,7 @@
$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 \
+ squ amod 0.08333333333333333333 0 1 1 \
remix 1v.99,2v.01 dither $vol_dither
done
@@ -253,13 +253,13 @@
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))