File: bpm-graph

package info (click to toggle)
bpm-tools 0.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 132 kB
  • sloc: ansic: 209; sh: 118; makefile: 24
file content (60 lines) | stat: -rwxr-xr-x 1,437 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# Copyright (C) 2013 Mark Hills <mark@xwax.org>
#
# 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.
#

#
# View graph of BPM analysis
#

set -eu

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
}

if [ -z "${1-}" ] || [ "$1" = "-h" ]; then
	usage >&2
	exit 1
fi

FILE="$1"
shift

if ! which gnuplot > /dev/null 2>&1; then
	echo "$0: requires gnuplot to be installed" >&1
	exit 1
fi

TMP=`mktemp -t bpm.XXXXXX` || exit 1
trap "rm $TMP" 0

sox "$FILE" -r 44100 -e float -c 1 -t raw - | bpm -m 60 -x 220 -g $TMP
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