DirectMusic MUSIC_TIME

Started by
2 comments, last by bjut 19 years, 1 month ago
hello! just a question, what is MUSIC_TIME? I just don't get the explanation in DirectMusic's help. How is it relative to the tempo? Is there any way to get the MUSIC_TIME of a measure in a MIDI file? I'm trying to implement a seeking feature in DirectMusic that seeks onto the measures in a MIDI file. I am thinking of computing it myself because I can already get the Time signature and tempo of the MIDI from DirectMusic. So I can just do this: (number of measure to seek to) * (number of beats per measure) * (duration of a beat obtained from tempo beats per minute) = start time of measure to seek to problem is, how do i translate this into MUSIC_TIME? whatever that is... or is there an easier way to do this? thank you!
Advertisement
You probably already saw this in the DX 8.1 docs, but here it is again.
Quote:
Music time is a 32-bit value defined as type MUSIC_TIME. It is not an absolute measure of time but is relative to the tempo. The clock is started when the performance is initialized and ticks DMUS_PPQ times for each quarter-note. DMUS_PPQ is defined as 768.

So if you just created a performance object and, at the same moment, started playing a song in common (4/4) time, by the end of the first measure, the clock would be at DMUS_PPQ*4. Note, that if the beats-per-minute is slower, it will take a longer REFERENCE_TIME to reach the same point, but MUSIC_TIME stays the same.

This might come in handy if you are creating dynamic sound-tracks.
thanks for the reply...

yup I have read that part of the help file. I just don't get how to compute for MUSIC_TIME.

so if I did this:

MUSIC_TIME mt;mt = 4 * DMUS_PPQ;m_pSegment->SetStartPoint(mt);


Would that start the segment on the 2nd measure? I tried it and it just fell silent. It actually went beyond the file's length (which I got from Segment->GetLength()).

The file I tested had 4/2 time signature.

What is the formula for MUSIC_TIME by the way? What unit is it in?
it's 4/4 sorry...i was looking at the MIDI chunk which says 0x04 0x02

This topic is closed to new replies.

Advertisement