#! /bin/sh

# spectrogram -x

# Applying "sox spectrogram" with x axis of 1001 to a file of 1000 samples
# produces a segmentation fault.
#
# Repeat-by:
#    sox -c 1 -b 16 -r 1000 -n file.wav synth 1 sin 440 gain -3
#    sox file.wav -n spectrogram -x 1001
#
# See https://sourceforge.net/p/sox/mailman/message/33196362

# Check whether sox was compiled with the spectrogram effect
${sox:-sox} 2>&1 | grep -q '^EFFECTS:.*spectrogram' || exit 254

${sox:-sox} file.wav -n spectrogram -X 1001
status=$?

rm -f core spectrogram.png

exit $status
