Advertisement Jump to content
Sign in to follow this  
docyoung83

CreateSoundBuffer error

This topic is 4913 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 copied this code pretty much straight from the source, with a few modifications, but for some reason the function keeps failing. The return value is consistantly E_INVALIDARG, but I don't see that many places I could be screwing up. Any ideas?
// set up the format data structure
	memset(&pcmwf, 0, sizeof(WAVEFORMATEX));

	pcmwf.wFormatTag	  = WAVE_FORMAT_PCM;  // pulse code modulation
	pcmwf.nChannels		  = 1;                // mono 
	pcmwf.nSamplesPerSec  = 11025;            // always this rate
	pcmwf.nBlockAlign	  = 1;                
	pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
	pcmwf.wBitsPerSample  = 8;
	pcmwf.cbSize		  = 0;

	// prepare to create sounds buffer
	DSBUFFERDESC dsbd;
	dsbd.dwSize			= sizeof(DSBUFFERDESC);
	dsbd.dwFlags		= DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
	dsbd.dwBufferBytes	= child.cksize;
	dsbd.lpwfxFormat	= &pcmwf;
	
	// set rate and size in data structure
	rate  = wfmtx.nSamplesPerSec;
	size  = child.cksize;
	duration = size / pcmwf.nAvgBytesPerSec;

	LPDIRECTSOUNDBUFFER temp_snd_buffer = NULL;
	HRESULT hr = lpds->CreateSoundBuffer(&dsbd, &temp_snd_buffer, NULL);


"lpds" is of type LPDIRECTSOUND8 and has been created previously.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!