PDA

View Full Version : Little question (i hope) DXMusic.



Chesso
10-01-2007, 09:39 AM
I am using DXMusic with UnDelphiX 1.07B, everything is going fine, but I would like to somehow pause and resume music, most importantly for when the game is paused and unpaused.

Is there some way to get what the track playing is up to and then set it when I re-play it to give it a pause/unpause effect?

Iv'e tried a few things but they don't seem to work.....

Chesso
15-01-2007, 11:14 AM
No one has any idea?

savage
15-01-2007, 11:36 AM
I have not used DirectMusic, but a quick google pulled this up - http://www.devmaster.net/forums/archive/index.php/t-3175.html

I also found this in Google Groups...



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)
&& &#40;llLoopStart <llLoopEnd> mtStartPoint&#41; &#41;
&#123;
if&#40; &#40;dwLoopRepeats != DMUS_SEG_REPEAT_INFINITE&#41;
&& &#40;llBigNow > &#40;llLoopStart + &#40;llLoopEnd - llLoopStart&#41; *
&#40;signed&#41;dwLoopRepeats&#41;&#41; &#41;
&#123;
llBigNow -= &#40;llLoopEnd - llLoopStart&#41; * dwLoopRepeats;
&#125;
else if&#40; llBigNow > llLoopStart &#41;
&#123;
llBigNow = llLoopStart + &#40;llBigNow - llLoopStart&#41; % &#40;llLoopEnd -
llLoopStart&#41;;
&#125;
&#125;
llBigNow = min&#40; llBigNow, LONG_MAX &#41;;
return long&#40;llBigNow&#41;;

&#125;


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.

Chesso
15-01-2007, 11:57 AM
Well I posted this a bit ago and I kind of can't remember lol.

But concerning DXMusic there isn't much that you can try that look even remotely like it.

Perhaps this is a future feature? I might email and ask Micrel, he might hopefully know if it's been implemented or could.

seiferalmasy
11-02-2007, 09:57 PM
I don't use delphix for music. I use Tactivemovie but even the crap tmediaplayer has a .position

for instance you load the wav then>> Positionvar:=tmediaplayer1.position;

then you have stored the position and can go back to it when unpause.

Along those lines.

Of course I use this when I wish to loop audio music and for a few other things. I guess .pause would be much more your thing in this case. Delphix is a bit short in the audio dept

FNX
12-02-2007, 11:10 AM
I would suggest you to have a look at FMOD library.

You can find it at http://www.fmod.org/

It's free for non commercial use and it plays almost every known music
format :)

Very easy also to interface within delphi, and it has exactly what you need
because i already used it for the same purpose :!: