James W. Morris wrote:
can anyone point me to some information about time
signatures and tempo
which would be useful from a programmers perspective. I've looked on the
internet and what I found either told me nothing I did not know or just said
that time signature was irrelevant (ie for notation only) and it was down to
the performers to decide.
true, from my experience. unless you want to code event-generating
algorithms that rely on bar/beat/tick notation.
a good resource is probably the standard MIDI file spec; i guess most
sequencers still work with the scheme described therein. lots of
open-source MIDI file players and sequencers out there, too.
so far my code is based on 4/4 (4 'beats' of
quarter notes per bar/measure).
a single bar has a value of 256, with halfnote 128, etc. What I need to
work out is how a different time signature will effect this, would I need to
change the value of a bar etc?
on a sidenote: usually, a 'beat' equals a 1/4 note and has a 'value'
(to use your term) that is divisible by both 3 and 4. if using integer
'values' (the unit of which is usually called a 'tick') this allows
for precise notation of triplets and even beats alike. for instance:
1/4 note = 12 ticks; 1/8 note = 6 ticks; 1/8 triplet = 4 ticks etc.
getting the length of a bar then is as simple as you think. if 1/4 has
12 ticks, a 3/4 measure is 3 * 12 ticks, a 7/8 is 7 * 6 ticks etc. to
get the bar/beat/tick notation at an arbitrary point in a song
containing time signature changes, you need to iterate all prior
signatures (yes, caching b/b/t for every signature change 'event' is a
good idea if you need this often).
expressing tempo as quarter notes per minute (bpm) [or ticks per
second for ease of computation] regardless of time signature is the
simplest way, with no obvious drawbacks. as you assume, this allows
the sequencer engine to run without looking at time signature.
I tried some experiments in cubase (i've not got
any realtime sequencers
working in linux yet) with audio blocks snapped to every half bar. What
confused me completely was when I changed the time signature to 5/8. the
snaps to half bars stayed in the same place, but the snaps to bars changed,
ending with every 5th block snapped to a half note actually landing on a
bar. Uh?
i remember that cubase's 'snap' behaviour was irritating when it had
to deal with odd time signatures (back when i used it, years ago, on
an atari st). i can very well imagine it still is.
tim