Jump to content
  • Advertisement


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


Creating a DirectSoundBuffer

This topic is 6475 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

Hi, I have a problem with the creation of a 3D sound buffer. I''m using DirectSound 8. I searched in the SDK, books and example codes for an answer to that problem but I didn''t find a solution. Ok, first of all, here is the part of the code: . . . if( b3DSound ) { dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRL3D | DSBCAPS_MUTE3DATMAXDISTANCE; wfx.nChannels = 1; } else { dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN; } memset( &dsbd, 0, sizeof( dsbd ) ); dsbd.dwSize = sizeof( dsbd ); dsbd.dwFlags = dwFlags; dsbd.dwBufferBytes = mmckiChild.cksize; dsbd.lpwfxFormat = &wfx; if( b3DSound ) dsbd.guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION; hr = pDS->CreateSoundBuffer( &dsbd, &pDSB, NULL ); if FAILED( hr ) { return hr; } . . . Ok, to my problem. Everytime the b3DFlag is set to TRUE, the CreateSoundBuffer() method fails and returns DSERR_INVALIDPARAM. If the flag is set to FALSE, everything works fine. I can even initialize the IDirectSound3DListener8 interface. There are also no problems if I create a 3D-Soundbuffer with DirectMusic. I hope you can help me because I don''t know where I make that mistake.

Share this post

Link to post
Share on other sites

does no one here has an idea, where the mistake is ?
I''m sorry if that sounds a bit unfriendly, but it seems as if not many people here know how to use DirectSound because nearly every topic about it is unanswered. Why ? I mean what API do you use for sound ? Or are your applications just some graphic demos without sound ?

Share this post

Link to post
Share on other sites
You''re right, I asked about sound APIs on here and got no response. I think most people are, sadly, just interested in their graphical engine. Which is a shame because computer games should be about so much more than graphics.

Does your hardware support the 3d sound features you''re asking for? Or perhaps, if you''re doing it in software, there is a certain reference driver you have to use rather than the default? Although I''ve used DirectSound, I''ve never used the 3D stuff, sadly.

I would try a process of elimination. The main differences between the 2 flows of control are:
3) wfx.nChannels = 1; (what is it when b3DSound is false?)
4) dsbd.guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION
I can just suggest you try removing these differences, one at a time, to try and narrow down which one is causing you the grief.

Share this post

Link to post
Share on other sites
First of all, thanks for the reply.

My soundcard supports 3D-Sound. It's a Soundblaster Live! and if I create 3D soundbuffers with DirectMusic I've got no problems. I don't even have problems with DirectSound when I create the primary soundbuffer with the DSBCAPS_CTRL3D flag. So I don't think that it is a problem of the hardware.

To the process of elimination: The creation fails even if I only set the DSBCAPS_CTRL3D flag and leave the CTRLVOLUME and MUTE3DATMAXDISTANCE out.
The value of wfx.nChannels is unknown because the wfx structure is filled with the informations in the wave-file I load before the creation. I have to set it to 1 because if I use 3D sound I'm supposed to use mono sounds.
For the dsbd.guid3DAlgorithm I searched in the SDK which values are valid. I tried every single value that was there but the creation failed. So it seems as if the DSBCAPS_CTRL3D flag is the reason for failing. But this is the flag that I need for 3D sound.
I was looking in the examples that came with the SDK and they do it the same way. And if I recompile them everything works fine. It is only my piece of code that doesn't work.

Edited by - LongingForDeath on March 20, 2001 9:41:04 AM

Share this post

Link to post
Share on other sites

  • 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!