On Tue, Sep 25, 2007 at 10:08:57AM -0700, Ken Restivo wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Tue, Sep 25, 2007 at 09:21:06AM +0200, Alexandre Ratchov wrote:
> > On Mon, Sep 24, 2007 at 07:00:38PM -0700, Ken Restivo wrote:
> > >
> > > Is there any command-line tool to extract and print the tempo of
> > > a MIDI file?
> > >
> >
> > hi,
> >
> > you could use midish for that: import the .mid file, and use the
> > songtimeinfo function; example:
> >
> > $ rmidish
> > send EOF character (control-D) to quit
> > 1> songimportsmf "sample.mid"
> > 2> songtimeinfo
> > {
> > timesig 4 24
> > tempo 400000
> > }
> > 3>
> >
>
> Thanks! However, I haven't found any explanation of what those numbers mean. I need the tempo in BPM.
>
> I found this formula in the Rosegarden source:
> qpm = (60.0 * beatTime) / (beatSec * quarter)
>
> But of the three numbers that songtimeinfo spits out, I haven't been able to figure out which one is beatTime, beatSec, and quarter.
>
oops, forgot to say what units are; 400000 is the diration of a
MIDI tic in 24th of microseconds. To get the BPM:
bpm = 60 * 24000000 / (tempo * ticks_per_beat)
= 60 * 24000000 / (400000 * 24)
= 150
(ticks_per_beat is the second parameter of the time signature).
[...]
However, in this case it's simpler to use "songgettempo" function,
example:
$ rmidish
send EOF character (control-D) to quit
1> songimportsmf "sample.mid"
2> print [songgettempo -1]
150
songgettempo returns the tempo (in BPM) at the given measure
number, -1 means the end of the song. This function is not in 0.3.1
release, its only in the last snapshot:
http://caoua.org/midish/midish.tar.gz
cheers,
-- Alexandre
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo.cgi/linux-audio-user
Received on Wed Sep 26 00:15:02 2007
This archive was generated by hypermail 2.1.8 : Wed Sep 26 2007 - 00:15:02 EEST