Compare commits
No commits in common. "master" and "0.1" have entirely different histories.
16
Makefile
16
Makefile
|
|
@ -1,29 +1,15 @@
|
||||||
-include .config
|
-include .config
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
INSTALL ?= install
|
|
||||||
|
|
||||||
BINDIR ?= $(PREFIX)/bin
|
|
||||||
MANDIR ?= $(PREFIX)/share/man
|
|
||||||
|
|
||||||
CFLAGS ?= -O3
|
|
||||||
|
|
||||||
CFLAGS += -Wall
|
CFLAGS += -Wall
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm
|
||||||
|
|
||||||
.PHONY: clean install dist
|
.PHONY: clean dist
|
||||||
|
|
||||||
bpm: bpm.o
|
bpm: bpm.o
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f bpm *.o
|
rm -f bpm *.o
|
||||||
|
|
||||||
install:
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
|
||||||
$(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
|
||||||
V=$$(git describe) && git archive --prefix=bpm-tools-$$V/ HEAD \
|
V=$$(git describe) && git archive --prefix=bpm-tools-$$V/ HEAD \
|
||||||
|
|
|
||||||
16
README
16
README
|
|
@ -1,23 +1,9 @@
|
||||||
bpm-tools: Tempo (Beats Per Minute) analysis tools
|
bpm-tools: Tempo (Beats Per Minute) analysis tools
|
||||||
|
|
||||||
(C) Copyright 2013 Mark Hills <mark@xwax.org>
|
(C) Copyright 2012 Mark Hills <mark@pogo.org.uk>
|
||||||
|
|
||||||
See the COPYING file for licensing terms.
|
See the COPYING file for licensing terms.
|
||||||
|
|
||||||
This software is distributed from the following site:
|
This software is distributed from the following site:
|
||||||
|
|
||||||
http://www.pogo.org.uk/~mark/bpm-tools/
|
http://www.pogo.org.uk/~mark/bpm-tools/
|
||||||
|
|
||||||
The build is controlled via Makefile variables. In general
|
|
||||||
you should be able to build using:
|
|
||||||
|
|
||||||
$ make
|
|
||||||
$ make install
|
|
||||||
|
|
||||||
To change the target prefix, for example:
|
|
||||||
|
|
||||||
$ make install PREFIX=/opt/bpm-tools
|
|
||||||
|
|
||||||
The Makefile picks up additional variables from a .config file
|
|
||||||
in the source directory. You will prefer to use this if you want
|
|
||||||
to control build flags for testing and debugging.
|
|
||||||
|
|
|
||||||
29
bpm-graph
29
bpm-graph
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2013 Mark Hills <mark@xwax.org>
|
# Copyright (C) 2012 Mark Hills <mark@pogo.org.uk>
|
||||||
#
|
#
|
||||||
# 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,37 +21,22 @@
|
||||||
# View graph of BPM analysis
|
# View graph of BPM analysis
|
||||||
#
|
#
|
||||||
|
|
||||||
set -eu
|
set -e
|
||||||
|
|
||||||
usage()
|
if [ -z "$1" ]; then
|
||||||
{
|
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 220 -g $TMP
|
sox "$FILE" -r 44100 -e float -c 1 -t raw - | bpm -m 60 -x 180 -g $TMP
|
||||||
gnuplot -p <<END
|
gnuplot -p <<END
|
||||||
set style data lines
|
set style data lines
|
||||||
set ylabel "Difference"
|
set ylabel "Difference"
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
.so man1/bpm-graph.1
|
|
||||||
11
bpm-tag
11
bpm-tag
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2013 Mark Hills <mark@xwax.org>
|
# Copyright (C) 2012 Mark Hills <mark@pogo.org.uk>
|
||||||
#
|
#
|
||||||
# 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 2013 Mark Hills <mark@xwax.org>
|
bpm-tag 0.0-beta (C) Copyright 2011 Mark Hills <mark@pogo.org.uk>
|
||||||
|
|
||||||
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,7 +37,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,9 +92,6 @@ 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
|
||||||
|
|
@ -132,9 +128,6 @@ 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
|
||||||
|
|
|
||||||
73
bpm.1
73
bpm.1
|
|
@ -1,73 +0,0 @@
|
||||||
.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) 2013 Mark Hills <mark@xwax.org>
|
* Copyright (C) 2012 Mark Hills <mark@pogo.org.uk>
|
||||||
*
|
*
|
||||||
* 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 2013 Mark Hills <mark@xwax.org>"
|
#define BANNER "bpm (C) Copyright 2012 Mark Hills <mark@pogo.org.uk>"
|
||||||
#define NAME "bpm"
|
#define NAME "bpm"
|
||||||
|
|
||||||
#define RATE 44100 /* of input data */
|
#define RATE 44100 /* of input data */
|
||||||
|
|
@ -141,7 +141,6 @@ 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;
|
||||||
|
|
@ -187,7 +186,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 [...] | " NAME " -g file.dat\n"
|
" $ sox [...] | ./tempo -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