bpm-tools/bpm-graph

61 lines
1.4 KiB
Plaintext
Raw Normal View History

2011-12-11 16:40:50 -02:00
#!/bin/sh
2012-06-01 09:08:31 -03:00
#
2013-05-21 17:21:49 -03:00
# Copyright (C) 2013 Mark Hills <mark@xwax.org>
2012-06-01 09:08:31 -03:00
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License version 2 for more details.
#
# You should have received a copy of the GNU General Public License
# version 2 along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
2011-12-11 16:40:50 -02:00
#
# View graph of BPM analysis
#
2013-05-21 17:35:51 -03:00
set -eu
2011-12-11 16:40:50 -02:00
2013-05-21 17:28:14 -03:00
usage()
{
cat <<END
bpm-graph (C) Copyright 2013 Mark Hills <mark@xwax.org>
Usage: bpm-graph <file>
Display tempo analysis data
See the bpm-graph(1) man page for more information.
END
}
2013-05-21 17:35:51 -03:00
if [ -z "${1-}" ] || [ "$1" = "-h" ]; then
2013-05-21 17:28:14 -03:00
usage >&2
2011-12-11 16:40:50 -02:00
exit 1
fi
2011-12-18 10:13:30 -02:00
FILE="$1"
shift
2013-05-21 17:38:33 -03:00
if ! which gnuplot > /dev/null 2>&1; then
echo "$0: requires gnuplot to be installed" >&1
exit 1
fi
2011-12-11 16:40:50 -02:00
TMP=`mktemp -t bpm.XXXXXX` || exit 1
trap "rm $TMP" 0
2013-05-21 17:36:16 -03:00
sox "$FILE" -r 44100 -e float -c 1 -t raw - | bpm -m 60 -x 220 -g $TMP
2011-12-18 10:13:30 -02:00
gnuplot -p <<END
set style data lines
set ylabel "Difference"
set xlabel "Offset (Beats per minute)"
plot "$TMP" title "`echo "$FILE" | sed -e 's:\":\\\\":g'`"
END