Greetings,
I've been trying to figure out the best way to implement a metronome. My initial design was to programatically create a Music Sequence by:
1) adding all the tempo changes to the tempo track 2) looping through the duration of the track adding a MIDI note event on every beat.
For the most part this works fine if the assumption is made that the user doesn't want anything fancy like a tick for eight notes instead of quarters or to have the first beat of a measure accented.
To add an accent to the first beat I need to know the time signature changes through the song. From the API I don't think there is a (obvious) way to add this to the tempo track of a MusicSequence, however, I did notice when playing around with the PlaySequence example that my test MIDI file did have a time signature in it. Is there any way to utilize this? Here is the output from CAShow() where I noticed this:
NumTracks = 8, Type = beats * * TempoTrack * * SequenceTrack @0x101d70 Num Events: 2, Track Length: 0.00 beats 0.000: Tempo:160.000 0.000: Time Sig:4/4, 24 clks/qtr, 8 32nds/clk
Alternatively, I began looking into using a CAClock along with the MusicSequence to keep track of the time changes and use the information available in CAClock to populate the MIDI note events on the sequence.
Am I heading in the right direction or way off base? This is more or less a hobby for me and I don't really have any background in audio programming so I wouldn't be surprised if I'm way off here.
One last question, could anyone suggest a good book to get me on the right track with this stuff?
Thanks in advance, Peter
|