Sign in to follow this  

Weird Stuff with DirectSound

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this