Archived

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

DX8.1 Play More Then 1 Sound At a time

This topic is 5703 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 made a simple class using the dx8.1 sample as a basecode. My problem is that when i tell it to play another sound it clears the current one playing. How can i make it not stop playing the current and start playing the second over the first. ///////////////////////////////////////////////////// class dxsound { public: dxsound(); ~dxsound(); void play(int channel); //Play a sound void add(apstring filename,int channel); //Add a sound private: IDirectMusicLoader8* g_pLoader; IDirectMusicPerformance8* g_pPerformance; IDirectMusicSegment8* g_pSegmenttest[32]; //32 Sounds Total int used[32]; //Check }; //***************************************************************************** dxsound ::dxsound() { CoInitialize(NULL); CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&g_pLoader ); CoCreateInstance( CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, IID_IDirectMusicPerformance8, (void**)&g_pPerformance ); g_pPerformance->InitAudio( NULL, NULL, NULL, DMUS_APATH_SHARED_STEREOPLUSREVERB, 64, DMUS_AUDIOF_ALL, NULL ); g_pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, NULL, FALSE ); int x = 0; while (x < 32) { used[x]=0; x++; } } //***************************************************************************** void dxsound :: play(int channel) { g_pPerformance->PlaySegmentEx( g_pSegmenttest[channel], NULL, NULL, 0, 0, NULL, NULL, NULL ); } //***************************************************************************** void dxsound ::add(apstring filename,int channel) { used[channel] = 1; WCHAR wstrFileName[260]; int x=0; while (x < filename.length()) { wstrFileName[x] = filename[x]; x++; } wstrFileName[x] = NULL; if( FAILED( g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, wstrFileName, (LPVOID*) &g_pSegmenttest[channel] ) ) ) { MessageBox(NULL,"FILE ERROR","ERROR",0); } else { g_pSegmenttest[channel]->Download( g_pPerformance ); } } //***************************************************************************** dxsound :: ~dxsound() { g_pPerformance->Stop( NULL, NULL, 0, 0 ); g_pPerformance->CloseDown(); g_pLoader->Release(); g_pPerformance->Release(); int x=0; while (x < 32) { if (used[x] == 1) g_pSegmenttest[x]->Release(); x++; } CoUninitialize(); } /////////////////////////////////////////////////////

Share this post


Link to post
Share on other sites
I fixed it.

just had to change the play function.

void dxsound :: play(int channel)
{
g_pPerformance->PlaySegmentEx( g_pSegmenttest[channel], NULL, NULL, DMUS_SEGF_SECONDARY, 0, NULL, NULL, NULL );
}

Share this post


Link to post
Share on other sites