Grand Nagus
Newcomer
- Joined
- Jan 7, 2004
- Messages
- 10
Hey guys. Coding for Direct3D is fun, but how much fun is a game without sound?
Anyways, I've created a simple DirectMusic performance object...
loaded it up with data...
and loaded the music segments into my performance object...
and can play sound effects using this...
...and it all works pretty well. I can get sound effects to play whenever I want, and they don't interrupt each other when the playing sound effects get numerous.
But what I'm having a problem with is 'looping' a sound; more specifically, a music track. Here's what I'm doing to try to loop the song stored in array 6:
When the song plays, it plays once and stops. I thought that the flag 'DMUS_SEG_REPEAT_INFINITE' was to make it repeat over and over, but it only plays once. How do I get it to play indefinitely?
Thanks in advance for the help!
Anyways, I've created a simple DirectMusic performance object...
Code:
if (FAILED(MyGame->g_pPerformance->InitAudio(
NULL, // IDirectMusic interface not needed.
NULL, // IDirectSound interface not needed.
NULL, // Window handle.
DMUS_APATH_SHARED_STEREOPLUSREVERB, // Default audiopath type.
64, // Number of performance channels.
DMUS_AUDIOF_ALL, // Features on synthesizer.
NULL // Audio parameters; use defaults.
)))
loaded it up with data...
Code:
if (FAILED(MyGame->g_pLoader->LoadObjectFromFile(
CLSID_DirectMusicSegment, // Class identifier.
IID_IDirectMusicSegment8, // ID of desired interface.
MyGame->MusicFiles[i].SoundName, // wstrFileName, // Filename.
(LPVOID*) &MyGame->MusicFiles[i].g_pSegment // Pointer that receives interface.
)))
and loaded the music segments into my performance object...
Code:
if ( FAILED(MyGame->MusicFiles[i].g_pSegment->Download(MyGame->g_pPerformance)) )
and can play sound effects using this...
Code:
MyGame->g_pPerformance->PlaySegment(MyGame->MusicFiles[SoundFX].g_pSegment, (DMUS_SEGF_NOINVALIDATE), NULL, NULL);
...and it all works pretty well. I can get sound effects to play whenever I want, and they don't interrupt each other when the playing sound effects get numerous.
But what I'm having a problem with is 'looping' a sound; more specifically, a music track. Here's what I'm doing to try to loop the song stored in array 6:
Code:
MyGame->MusicFiles[6].g_pSegment->SetRepeats(DMUS_SEG_REPEAT_INFINITE);
MyGame->g_pPerformance->PlaySegmentEx(MyGame->MusicFiles[6].g_pSegment, NULL, NULL, 0, 0, NULL, NULL, NULL);
Thanks in advance for the help!