• Advertisement

Archived

This topic is now archived and is closed to further replies.

DMusic Looping

This topic is 5831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I read a tutorial on the msdn online library and it told me how to get my program to play midis and wavs, but I can''t get it to loop. I''ve looked around msdn and tried things that look like they should work but they aren''t working and it just plays one time through. Here is a little of the code. if (FAILED(g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, // Class identifier. IID_IDirectMusicSegment8, // ID of desired interface. wstrFileName, // Filename. (LPVOID*) &g_pSegment // Pointer that receives interface. ))) { MessageBox( NULL, "Media not found, sample will now quit.", "DMusic Tutorial", MB_OK ); return 0; } g_pSegment->Download( g_pPerformance ); g_pPerformance->PlaySegmentEx( g_pSegment, // Segment to play. NULL, // Used for songs; not implemented. NULL, // For transitions. 0, // Flags. 0, // Start time; 0 is immediate. NULL, // Pointer that receives segment state. NULL, // Object to stop. NULL // Audiopath, if not default. ); Any help would be appreciated. EAX

Share this post


Link to post
Share on other sites
Advertisement
Just use this to set the segment to repeat forever. It works for me... =)

Segment->SetRepeats(DMUS_SEG_REPEAT_INFINITE);

Share this post


Link to post
Share on other sites
Ok that makes it repeat, but it leaves a second or 2 of silence at the end of my mid''s so that the end doesn''t blend to the beginning like it should. I made these midis to loop, is there a way to keep DMusic to get rid of the blank space at the end?

Thanks


EAX

Share this post


Link to post
Share on other sites
cant you tell DMusic to give you a heads-up just before the end - ie, just before the very last part of the music begins playing...? I think it''s designed so that you can que/load the next piece of music ready to play. check the SDK.

Jack;

Share this post


Link to post
Share on other sites
Hmm...

Try when u play the segment setting the second parameter to
DMUS_SEGF_DEFAULT. If you are using DMUS_SEGF_AFTERPREPARETIME theres a delay before the segment starts playing.

Try like this:
PERFORMANCE->PlaySegment(SEGMENT, DMUS_SEGF_DEFAULT, 0, NULL);



Hopes this helps

Share this post


Link to post
Share on other sites
Thanks for your advice, but it still didn''t immediately start playing the beggining.

EAX

Share this post


Link to post
Share on other sites
Well have you checked your soundfile? Maybe theres some "silent thingy" or what you call it .

Share this post


Link to post
Share on other sites
Maybe this will help I havent tried this but it may work

use these:

HRESULT SetLoopPoints(
MUSIC_TIME mtStart,
MUSIC_TIME mtEnd
);

HRESULT GetLoopPoints(
MUSIC_TIME mtStart,
MUSIC_TIME mtEnd
);

Share this post


Link to post
Share on other sites
I got it working using GetLength And SetLoopPoints, Thanks for your help.

EAX

Share this post


Link to post
Share on other sites

  • Advertisement