dotfiles/.local/bin/scripts/freq

24 lines
693 B
Bash
Executable File

#!/bin/sh
# 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
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"
$0 "$diff"
;;
(*)
out="${2:-/tmp/freq-$(basename "$1")}.png"
mkdir -p "$(dirname "$out")"
sox "$1" -n spectrogram -o "$out"
timg --title "$out"
;;
esac