dotfiles/.local/bin/scripts/freq

24 lines
693 B
Plaintext
Raw Normal View History

2021-11-14 13:28:55 +00:00
#!/bin/sh
2021-11-17 14:56:16 +00:00
# Show a frequence spectrogram using sox and timg
# https://sound.stackexchange.com/questions/40226/show-the-differences-between-two-similar-audio-files-using-graphical-method
case $1 in
(-a) shift
for arg; do $0 "$arg"; done
;;
(-d) shift
2021-11-23 12:03:43 +00:00
one="$(basename "$1")"
two="$(basename "$2")"
diff="/tmp/diff-$one-$two.wav"
ffmpeg -y -v warning -i "$1" "/tmp/$one.wav"
ffmpeg -y -v warning -i "$2" "/tmp/$two.wav"
sox -m -v 1 "/tmp/$one.wav" -v -1 "/tmp/$two.wav" "$diff"
2021-11-17 14:56:16 +00:00
$0 "$diff"
;;
(*)
2022-06-27 11:03:11 +00:00
out="${2:-/tmp/freq-$(basename "$1")}.png"
2021-11-17 14:56:16 +00:00
mkdir -p "$(dirname "$out")"
sox "$1" -n spectrogram -o "$out"
timg --title "$out"
;;
esac