@@ -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>, input rate, default 48000"
1918 echo " -R <rate>, output rate, default 48000"
@@ -49,7 +48,6 @@ if [ ! -d "sof" ]; then
4948 exit 1
5049fi
5150
52- OUTWAV=
5351CLIP=/usr/share/sounds/alsa/Front_Center.wav
5452MODULE=gain
5553BITS=32
@@ -58,10 +56,6 @@ RATE_OUT=48000
5856CHANNELS_IN=2
5957CHANNELS_OUT=2
6058PIPELINES=" 1,2"
61- INFILE1=$( mktemp --tmpdir=/tmp in-XXXX.raw)
62- OUTFILE1=$( mktemp --tmpdir=/tmp out-XXXX.raw)
63- TRACEFILE=$( mktemp --tmpdir=/tmp trace-XXXX.txt)
64- PROFILEOUT=$( mktemp --tmpdir=/tmp profile-XXXX.out)
6559KEEP_TMP=false
6660XTRUN=false
6761PROFILE=false
@@ -123,6 +117,19 @@ while getopts "b:c:hi:km:n:o:p:r:R:t:vx" opt; do
123117done
124118shift $(( OPTIND- 1 ))
125119
120+ # Get the current date and time in a specific format (YYYYMMDD_HHMMSS)
121+ timestamp=$( date +" %Y%m%d_%H%M%S" )
122+
123+ # Combine the prefix and timestamp to create the filename
124+ INFILE1=" $PWD /testbench_data/in-${MODULE} -${timestamp} .raw"
125+ OUTFILE1=" $PWD /testbench_data/out-${MODULE} -${timestamp} .raw"
126+ TRACEFILE=" $PWD /testbench_data/trace-${MODULE} -${timestamp} .txt"
127+ PROFILEOUT=" $PWD /testbench_data/profile-${MODULE} -${timestamp} .out"
128+ OUTWAV=" $PWD /testbench_data/outwav-${MODULE} -${timestamp} .wav"
129+
130+ # make the data directory if it doesn't exist
131+ mkdir -p $PWD /testbench_data
132+
126133echo Converting clip " $CLIP " to raw input
127134if [[ " $BITS " == " 24" ]]; then
128135 # Sox does not support S24_4LE format
@@ -184,16 +191,17 @@ else
184191 fi
185192fi
186193
187- if [ -n " $OUTWAV " ]; then
194+ # Generate the outwav if we are keeping our data files for inspection.
195+ if [[ " $KEEP_TMP " == false ]]; then
196+ echo Deleting temporary files
197+ rm -f " $INFILE1 " " $OUTFILE1 " " $TRACEFILE " " $PROFILEOUT "
198+ else
188199 echo Converting raw output to " $OUTWAV "
189200 if [[ " $BITS " == " 24" ]]; then
190- sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b 32 " $OUTFILE1 " " $OUTWAV " vol 256
201+ sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b 32 \
202+ " $OUTFILE1 " " $OUTWAV " vol 256
191203 else
192- sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b " $BITS " " $OUTFILE1 " " $OUTWAV "
204+ sox --encoding signed-integer -L -r " $RATE_OUT " -c " $CHANNELS_OUT " -b " $BITS " \
205+ " $OUTFILE1 " " $OUTWAV "
193206 fi
194207fi
195-
196- if [[ " $KEEP_TMP " == false ]]; then
197- echo Deleting temporary files
198- rm -f " $INFILE1 " " $OUTFILE1 " " $TRACEFILE " " $PROFILEOUT "
199- fi
0 commit comments