Compare commits
11 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
e0f5676e48 | |
|
|
913728bf97 | |
|
|
53601f6b3a | |
|
|
795c8ea75b | |
|
|
a0bd601464 | |
|
|
31b1475995 | |
|
|
57a2f9e940 | |
|
|
edca668e4d | |
|
|
f68ec6eff2 | |
|
|
015bbd47aa | |
|
|
b3cea166c1 |
5
Makefile
5
Makefile
|
|
@ -4,6 +4,9 @@ PREFIX ?= /usr/local
|
||||||
INSTALL ?= install
|
INSTALL ?= install
|
||||||
|
|
||||||
BINDIR ?= $(PREFIX)/bin
|
BINDIR ?= $(PREFIX)/bin
|
||||||
|
MANDIR ?= $(PREFIX)/share/man
|
||||||
|
|
||||||
|
CFLAGS ?= -O3
|
||||||
|
|
||||||
CFLAGS += -Wall
|
CFLAGS += -Wall
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm
|
||||||
|
|
@ -18,6 +21,8 @@ clean:
|
||||||
install:
|
install:
|
||||||
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
||||||
$(INSTALL) -t $(DESTDIR)$(BINDIR) bpm bpm-graph bpm-tag
|
$(INSTALL) -t $(DESTDIR)$(BINDIR) bpm bpm-graph bpm-tag
|
||||||
|
$(INSTALL) -d $(DESTDIR)$(MANDIR)/man1
|
||||||
|
$(INSTALL) -t $(DESTDIR)$(MANDIR)/man1 bpm.1 bpm-graph.1 bpm-tag.1
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
|
||||||
2
README
2
README
|
|
@ -1,6 +1,6 @@
|
||||||
bpm-tools: Tempo (Beats Per Minute) analysis tools
|
bpm-tools: Tempo (Beats Per Minute) analysis tools
|
||||||
|
|
||||||
(C) Copyright 2012 Mark Hills <mark@xwax.org>
|
(C) Copyright 2013 Mark Hills <mark@xwax.org>
|
||||||
|
|
||||||
See the COPYING file for licensing terms.
|
See the COPYING file for licensing terms.
|
||||||
|
|
||||||
|
|
|
||||||
29
bpm-graph
29
bpm-graph
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
# Copyright (C) 2013 Mark Hills <mark@xwax.org>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -21,22 +21,37 @@
|
||||||
# View graph of BPM analysis
|
# View graph of BPM analysis
|
||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -eu
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
usage()
|
||||||
echo "Usage: $0 <file>" >&2
|
{
|
||||||
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -u
|
|
||||||
|
|
||||||
FILE="$1"
|
FILE="$1"
|
||||||
shift
|
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
|
TMP=`mktemp -t bpm.XXXXXX` || exit 1
|
||||||
trap "rm $TMP" 0
|
trap "rm $TMP" 0
|
||||||
|
|
||||||
sox "$FILE" -r 44100 -e float -c 1 -t raw - | bpm -m 60 -x 180 -g $TMP
|
sox "$FILE" -r 44100 -e float -c 1 -t raw - | bpm -m 60 -x 220 -g $TMP
|
||||||
gnuplot -p <<END
|
gnuplot -p <<END
|
||||||
set style data lines
|
set style data lines
|
||||||
set ylabel "Difference"
|
set ylabel "Difference"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
.so man1/bpm-graph.1
|
||||||
11
bpm-tag
11
bpm-tag
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
# Copyright (C) 2013 Mark Hills <mark@xwax.org>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -26,7 +26,7 @@ set -e
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat <<END
|
cat <<END
|
||||||
bpm-tag (C) Copyright 2012 Mark Hills <mark@xwax.org>
|
bpm-tag (C) Copyright 2013 Mark Hills <mark@xwax.org>
|
||||||
|
|
||||||
Usage: bpm-tag [options] <file>
|
Usage: bpm-tag [options] <file>
|
||||||
Tag an audio file with tempo (in beats-per-minute, BPM)
|
Tag an audio file with tempo (in beats-per-minute, BPM)
|
||||||
|
|
@ -37,6 +37,7 @@ Tag an audio file with tempo (in beats-per-minute, BPM)
|
||||||
-x Maximum detected BPM
|
-x Maximum detected BPM
|
||||||
-h Display this help message and exit
|
-h Display this help message and exit
|
||||||
|
|
||||||
|
See the bpm-tag(1) man page for more information and examples.
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,6 +93,9 @@ case "$FILE" in
|
||||||
*.ogg)
|
*.ogg)
|
||||||
BPM=`vorbiscomment "$FILE" | sed -n 's/^BPM=//p'`
|
BPM=`vorbiscomment "$FILE" | sed -n 's/^BPM=//p'`
|
||||||
;;
|
;;
|
||||||
|
*.m4a)
|
||||||
|
BPM=`mp4info "$FILE" | sed -n 's/^\s*BPM://p'`
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$FILE: file extension not known" >&2
|
echo "$FILE: file extension not known" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -128,6 +132,9 @@ case "$FILE" in
|
||||||
*.ogg)
|
*.ogg)
|
||||||
vorbiscomment -at "BPM=$BPM" "$FILE"
|
vorbiscomment -at "BPM=$BPM" "$FILE"
|
||||||
;;
|
;;
|
||||||
|
*.m4a)
|
||||||
|
mp4tags -tempo "$BPM" "$FILE"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$FILE: don't know how to tag this type of file" >&2
|
echo "$FILE: don't know how to tag this type of file" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
.TH BPM "1"
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
bpm-tools \- calculate the tempo of music files
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B bpm-tag
|
||||||
|
[\fIoptions\fR] \fIfile\fR
|
||||||
|
|
||||||
|
.B bpm-graph
|
||||||
|
\fIfile\fR
|
||||||
|
|
||||||
|
.B bpm
|
||||||
|
[\fIoptions\fR] < \fIfile.raw\fR
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
|
||||||
|
The
|
||||||
|
.B bpm-tools
|
||||||
|
commands are used to automatically calculate the tempo (in
|
||||||
|
beats-per-minute) of music, optionally displaying an analysis
|
||||||
|
and adding it to file 'tags'. The data from these tags can be
|
||||||
|
especially useful for navigating a music library in DJ software
|
||||||
|
such as
|
||||||
|
.B xwax(1).
|
||||||
|
|
||||||
|
The
|
||||||
|
.B bpm
|
||||||
|
command implements the algorithm on raw data, but
|
||||||
|
the most commonly used command is
|
||||||
|
.B bpm-tag.
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
|
||||||
|
Options are described by the commands themselves. Use one of the
|
||||||
|
following for more information:
|
||||||
|
.sp
|
||||||
|
.RS
|
||||||
|
bpm-tag -h
|
||||||
|
|
||||||
|
bpm-graph -h
|
||||||
|
|
||||||
|
bpm -h
|
||||||
|
.RE
|
||||||
|
|
||||||
|
.SH EXAMPLES
|
||||||
|
|
||||||
|
.P
|
||||||
|
Tag a file with its tempo:
|
||||||
|
.sp
|
||||||
|
.RS
|
||||||
|
bpm-tag "Daft Punk - Get Lucky.mp3"
|
||||||
|
.RE
|
||||||
|
|
||||||
|
.P
|
||||||
|
Calculate and display the tempo of a file without modifying it:
|
||||||
|
.sp
|
||||||
|
.RS
|
||||||
|
bpm-tag -f -n "Gwen Guthrie - Padlock.flac"
|
||||||
|
.RE
|
||||||
|
|
||||||
|
.P
|
||||||
|
Tag a file, with a hint to look for a fast tempo:
|
||||||
|
.sp
|
||||||
|
.RS
|
||||||
|
bpm-tag -m 120 -x 200 "Roni Size - Brown Paper Bag.oga"
|
||||||
|
.RE
|
||||||
|
|
||||||
|
.SH HOMEPAGE
|
||||||
|
http://www.pogo.org.uk/~mark/bpm-tools/
|
||||||
|
|
||||||
|
.SH AUTHOR
|
||||||
|
Mark Hills <mark@xwax.org>
|
||||||
7
bpm.c
7
bpm.c
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012 Mark Hills <mark@xwax.org>
|
* Copyright (C) 2013 Mark Hills <mark@xwax.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include <sysexits.h>
|
#include <sysexits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define BANNER "bpm (C) Copyright 2012 Mark Hills <mark@xwax.org>"
|
#define BANNER "bpm (C) Copyright 2013 Mark Hills <mark@xwax.org>"
|
||||||
#define NAME "bpm"
|
#define NAME "bpm"
|
||||||
|
|
||||||
#define RATE 44100 /* of input data */
|
#define RATE 44100 /* of input data */
|
||||||
|
|
@ -141,6 +141,7 @@ double scan_for_bpm(float nrg[], size_t len,
|
||||||
step = (slowest - fastest) / steps;
|
step = (slowest - fastest) / steps;
|
||||||
|
|
||||||
height = INFINITY;
|
height = INFINITY;
|
||||||
|
trough = NAN;
|
||||||
|
|
||||||
for (interval = fastest; interval <= slowest; interval += step) {
|
for (interval = fastest; interval <= slowest; interval += step) {
|
||||||
double t;
|
double t;
|
||||||
|
|
@ -186,7 +187,7 @@ void usage(FILE *f)
|
||||||
RATE, RATE);
|
RATE, RATE);
|
||||||
|
|
||||||
fprintf(f, "To view autodifference or energy data:\n"
|
fprintf(f, "To view autodifference or energy data:\n"
|
||||||
" $ sox [...] | ./tempo -g file.dat\n"
|
" $ sox [...] | " NAME " -g file.dat\n"
|
||||||
" $ gnuplot\n"
|
" $ gnuplot\n"
|
||||||
" gnuplot> plot \"file.dat\"\n\n");
|
" gnuplot> plot \"file.dat\"\n\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue