Advertisement Jump to content
Sign in to follow this  

Weird Stuff with DirectSound

This topic is 3814 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 got some weird things going on with DirectSound again. Thanks for all who helped me in my previous pos, but this is slightly weird.
int AudioEngine :: LoadSegment(char *filename, bool Background, int ID)
	Sound * temp = new Sound;
	WCHAR wcharStr[MAX_PATH];
    MultiByteToWideChar(CP_ACP, 0, filename, -1, wcharStr, MAX_PATH); // convert filename to unicode string

	if(FAILED(m_pLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, wcharStr, (void**)&temp->m_pSegment)))
		return -1;


		if(FAILED(m_pPerformance->CreateStandardAudioPath(DMUS_APATH_DYNAMIC_3D, 64, TRUE, &temp->m_p3DAudioPath))) // create a standard 3D audiopath
			return -1;
		if(FAILED(temp->m_p3DAudioPath->GetObjectInPath( 0,DMUS_PATH_BUFFER,0,GUID_NULL,0, IID_IDirectSound3DBuffer,(void**)&temp->m_pDirectSoundBuffer3D)))
			return -1;
		temp->m_p3DAudioPath = NULL;
		temp->m_pDirectSoundBuffer3D = NULL;
	if(m_pListener != NULL)
			0,									// Performance channel.
			DMUS_PATH_PRIMARY_BUFFER,			// Stage in the path.
			0,									// Index of buffer in chain.
			GUID_NULL,							// Class of object.
			0,									// Index of object in buffer; ignored.
			IID_IDirectSound3DListener,			// GUID of desired interface.
			(void**)&m_pListener				// Pointer that receives interface.
	if(ID < 0)
		temp->id = placer++;
		Audio[ID] = *temp;
	return (int(Audio.size()) - 1);

This is how I am loading my segments to be played in DirectSound. But for some reason it cant overwrite. As in, if I load one piece of music onto this location, say the first element of the vector(Audio), then want another piece of music to be overwritten. for example AudioManager * audio = new AudioManager; audio->LoadSegment("music1.wav", true, -1); audio->LoadSegment("music2.wav", true, 0); while in debugging mode, I noted that that the first element of the vector(Audio) has been changed, but when I try to play it, no sound comes out. why?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!