I have not used DirectMusic, but a quick google pulled this up - http://www.devmaster.net/forums/arch...hp/t-3175.html
I also found this in Google Groups...
Code:
here is what I find, from the dev team, yes this is hard to do and isnt
doc'ed.
here's code to get the current offset into a segment that handles loops and
offsets. mtNow is the current performance time, the rest are all obtained
from the segment state or segment itself. It currently just returns the
current offset into the segment, but it could be modified to also return the
number of repeats of the segment left (so the repeat count could be set
correctly when unpausing the segment). This code is much more accurate than
the segment state's GetSeek() method, which just returns the next time that
the segment track's Play method will be called (which may be as much as one
second into the future).
MUSIC_TIME GetTimeOffset( const MUSIC_TIME mtNow,
const MUSIC_TIME
mtStartTime,
const MUSIC_TIME
mtStartPoint,
const MUSIC_TIME
mtLoopStart,
const MUSIC_TIME
mtLoopEnd,
const MUSIC_TIME mtLength,
const DWORD dwLoopRepeats)
{
// Convert mtNow from absolute time to an offset
// from when the segment started playing
LONGLONG llBigNow = mtNow - (mtStartTime - mtStartPoint);
// If mtLoopEnd is non zero, set lLoopEnd to mtLoopEnd,
// otherwise use the segment length
LONGLONG llLoopEnd = mtLoopEnd ? mtLoopEnd : mtLength;
LONGLONG llLoopStart = mtLoopStart;
if( (dwLoopRepeats != 0)
&& (llLoopStart <llLoopEnd> mtStartPoint) )
{
if( (dwLoopRepeats != DMUS_SEG_REPEAT_INFINITE)
&& (llBigNow > (llLoopStart + (llLoopEnd - llLoopStart) *
(signed)dwLoopRepeats)) )
{
llBigNow -= (llLoopEnd - llLoopStart) * dwLoopRepeats;
}
else if( llBigNow > llLoopStart )
{
llBigNow = llLoopStart + (llBigNow - llLoopStart) % (llLoopEnd -
llLoopStart);
}
}
llBigNow = min( llBigNow, LONG_MAX );
return long(llBigNow);
}
Is this usefull?
It might also be an idea to post what you have tried so as to avoid people suggesting things you may have already tried.
Bookmarks