Skip to content

Commit

Permalink
Test-case: Add to check-alsabat.sh additional audio test
Browse files Browse the repository at this point in the history
This patch adds run of check_wav_file_snr.m script for the
alsabat capture file to analyze with STFT spectra the audio
quality.

A drop in signal-to-noise ratio in a single FFT indicates presence
of glitch. A low SNR result triggers run of additional glitch
periodicity finder.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu committed Mar 30, 2023
1 parent 02aafc0 commit b815bfa
Show file tree
Hide file tree
Showing 2 changed files with 456 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test-case/check-alsabat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
rm -f /tmp/bat.wav.*

# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
TESTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
source "$TESTDIR/case-lib/lib.sh"

OPT_NAME['p']='pcm_p' OPT_DESC['p']='pcm for playback. Example: hw:0,0'
OPT_HAS_ARG['p']=1 OPT_VAL['p']=''
Expand Down Expand Up @@ -95,6 +96,20 @@ function __upload_wav_file
done
}

function check_wav_file_snr
{
for file in /tmp/bat.wav.*
do
if test -s "$file"; then
dlogi "Checking wav file $file"
cd "$TESTDIR"/tools
octave --silent --no-gui --eval "check_wav_file_snr('$file', $frequency, '$LOG_ROOT/')" || {
die "Error: Script check_wav_file_snr.m found issues in $file"
}
fi
done
}

# check the PCMs before alsabat test
dlogi "check the PCMs before alsabat test"
aplay -Dplug$pcm_p -d 1 /dev/zero -q || die "Failed to play on PCM: $pcm_p"
Expand All @@ -119,4 +134,6 @@ alsabat -C$pcm_c -c $channel_c -r $rate -f $format -F $frequency -k $sigmak || {
exit 1
}

check_wav_file_snr

wait $playPID
Loading

0 comments on commit b815bfa

Please sign in to comment.