@@ -10,10 +10,9 @@ usage() {
1010 echo " -c <channels>, default 2"
1111 echo " -h shows this text"
1212 echo " -i <input wav>, default /usr/share/sounds/alsa/Front_Center.wav"
13- echo " -k keep temporary files in /tmp "
13+ echo " -k keep temporary files in data directory "
1414 echo " -m <module>, default gain"
1515 echo " -n <pipelines>, default 1,2"
16- echo " -o <output wav>, default none"
1716 echo " -p <profiling result text>, use with -x, default none"
1817 echo " -r <rate>, default 48000"
1918 echo " -t <force topology>, default none, e.g. production/sof-hda-generic.tplg"
@@ -44,7 +43,6 @@ if [ ! -d "sof" ]; then
4443 exit 1
4544fi
4645
47- OUTWAV=
4846CLIP=/usr/share/sounds/alsa/Front_Center.wav
4947MODULE=gain
5048BITS=32
@@ -53,10 +51,6 @@ RATE_OUT=48000
5351CHANNELS_IN=2
5452CHANNELS_OUT=2
5553PIPELINES=" 1,2"
56- INFILE1=$( mktemp --tmpdir=/tmp in-XXXX.raw)
57- OUTFILE1=$( mktemp --tmpdir=/tmp out-XXXX.raw)
58- TRACEFILE=$( mktemp --tmpdir=/tmp trace-XXXX.txt)
59- PROFILEOUT=$( mktemp --tmpdir=/tmp profile-XXXX.out)
6054KEEP_TMP=false
6155XTRUN=false
6256PROFILE=false
@@ -116,6 +110,19 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do
116110done
117111shift $(( OPTIND- 1 ))
118112
113+ # Get the current date and time in a specific format (YYYYMMDD_HHMMSS)
114+ timestamp=$( date +" %Y%m%d_%H%M%S" )
115+
116+ # Combine the prefix and timestamp to create the filename
117+ INFILE1=" $PWD /testbench_data/in-${MODULE} -${timestamp} .raw"
118+ OUTFILE1=" $PWD /testbench_data/out-${MODULE} -${timestamp} .raw"
119+ TRACEFILE=" $PWD /testbench_data/trace-${MODULE} -${timestamp} .txt"
120+ PROFILEOUT=" $PWD /testbench_data/profile-${MODULE} -${timestamp} .out"
121+ OUTWAV=" $PWD /testbench_data/outwav-${MODULE} -${timestamp} .wav"
122+
123+ # make the data directory if it doesn't exist
124+ mkdir -p $PWD /testbench_data
125+
119126echo Converting clip " $CLIP " to raw input
120127if [[ " $BITS " == " 24" ]]; then
121128 # Sox does not support S24_4LE format
@@ -177,16 +184,17 @@ else
177184 fi
178185fi
179186
180- if [ -n " $OUTWAV " ]; then
187+ # Generate the outwav if we are keeping our data files for inspection.
188+ if [[ " $KEEP_TMP " == false ]]; then
189+ echo Deleting temporary files
190+ rm -f " $INFILE1 " " $OUTFILE1 " " $TRACEFILE " " $PROFILEOUT "
191+ else
181192 echo Converting raw output to " $OUTWAV "
182193 if [[ " $BITS " == " 24" ]]; then
183- sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b 32 " $OUTFILE1 " " $OUTWAV " vol 256
194+ sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b 32 \
195+ " $OUTFILE1 " " $OUTWAV " vol 256
184196 else
185- sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b " $BITS " " $OUTFILE1 " " $OUTWAV "
197+ sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b " $BITS " \
198+ " $OUTFILE1 " " $OUTWAV "
186199 fi
187200fi
188-
189- if [[ " $KEEP_TMP " == false ]]; then
190- echo Deleting temporary files
191- rm -f " $INFILE1 " " $OUTFILE1 " " $TRACEFILE " " $PROFILEOUT "
192- fi
0 commit comments