Re: How to implement BPM in a sequencer?
Re: How to implement BPM in a sequencer?
- Subject: Re: How to implement BPM in a sequencer?
- From: James Chandler Jr <email@hidden>
- Date: Fri, 14 Feb 2003 09:23:19 -0500
>
There is a theory behind it but I don't get it so I'm asking for
>
help to explain this theory in a simple way.
>
>
Example: I have a sequence recorded and I want to play it back in another
>
tempo. What calculating of the timestamp is needed to do that? Or is this
>
maybe the wrong way of doing it?
Hi Peter
This might not be what you want/need but here is a general overview of how
most folks seem to do it in roll-your-own sequencing.
You maintain at least two timebases--
1. A steady timebase. I usually use a variable something like
CurrentTimeMilliseconds.
2. A variable-tempo Tick timebase (ie CurrentTimeTicks).
You decide what Tick resolution you want in your sequencer. Historically
there has been wide variety in what folks find reasonable, but for many
commercial sequencers used 480 Ticks Per Quarter Note. The Tick resolution
is also sometimes called PPQN, Pulses Per Quarter Note.
As long as PPQN is fairly high, it doesn't really matter what the PPQN is.
From a user standpoint, long-time users get accustomed to certain magic
numbers when typing timing values into list editor windows, and I'm
hopelessly mentally geared to 480 PPQN from using Studio Vision and Digital
Performer for so many years (GRIN).
BPM is beats per minute. In my uses, for simplicity in tempo calculations I
usually use a quarter note as the beat definition, even in x/8 or x/16 time
signatures. Some folks think the "beat" definition should be
user-specifiable.
MIDI files, and whatever you use as an internal storage format, associate a
Tick timestamp with each MIDI event.
So to play back at any tempo--
1. Given the current BPM and PPQN, convert the stored Tick timestamp of each
MIDI event into the steady time (milliseconds or whatever) that specifies
when the computer should transmit the MIDI event.
2. When the CurrentTimeMilliseconds reaches the Millisecond time you
calculated for the MIDI event, transmit the MIDI event.
It can get complicated to chase sequence tempo maps and such, but the
process basically maintains a simple math relationship between
CurrentTimeTicks and CurrentTimeMilliseconds, given the sequence BPM and
your internal PPQN resolution.
I used CurrentTimeMilliseconds because that was "good enough" resolution
easily representable in 32 bit integer math, back when computers were too
slow to do intensive repetitive float math.
But nowadays, perhaps a double variable CurrentTimeSeconds, would be
cleaner. The double would have vastly higher resolution than an integer
Millisecond counter.
Hope that helps some.
James Chandler Jr.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.