Jump to content
  • Advertisement
Sign in to follow this  
darkwalker

DirectSound (Buffer3d)

This topic is 5175 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 some problems with Buffer3D. A time ago I have used directsound with no problem then I become cruious about 3d support(and where the problems begin). But then I encounter with an exception, I look around but can t see the problem. here is the portion code portion responsible from this problem :)
Buffer m_soundBuffer;
Buffer3D m_3dSoundBuffer;
..
..

BufferDescription desc = new BufferDescription();
desc.Control3D   = true;
desc.GlobalFocus = true;

// Below line is the cause of exception which says "Value does not fall within the expected range"					
m_soundBuffer = new Buffer(i_name, desc, i_sound.Device);
m_3dSoundBuffer	= new Buffer3D(m_soundBuffer);
m_3dSoundBuffer.Mode = Mode3D.Normal;

I am using vs.net2003, dx9c and my sound card is SBLive 5.1. Thanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
ive wrapped up the creation code so all you haev to do is call the interface.

h

class ADX_API Sound3D {
private:
LPDIRECTSOUND3DBUFFER g_pDS3DBuffer;
DS3DBUFFER g_dsBufferParams;
public:
Sound3D();
~Sound3D();
bool create(LPDIRECTSOUNDBUFFER sb);
LPDIRECTSOUND3DBUFFER getSound3DBuffer(){return g_pDS3DBuffer;}
};

class ADX_API Sound3DListener {
private:
LPDIRECTSOUND3DLISTENER g_pDSListener;
DS3DLISTENER g_dsListenerParams;
public:
Sound3DListener();
~Sound3DListener();
bool create(LPDIRECTSOUND8 ds);
LPDIRECTSOUND3DLISTENER getSound3DListener(){return g_pDSListener;}
};



cpp

bool Sound3DListener::create(LPDIRECTSOUND8 ds)
{
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;

DSBUFFERDESC dsbdesc;
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;

if( FAILED( ds ->CreateSoundBuffer( &dsbdesc, &pDSBPrimary, NULL ) ) )
{
return false;
}

if( FAILED( pDSBPrimary->QueryInterface( IID_IDirectSound3DListener,
(VOID**)&g_pDSListener ) ) )
{
SAFE_RELEASE( pDSBPrimary );
return false;
}

SAFE_RELEASE( pDSBPrimary );

if(FAILED(g_dsListenerParams.dwSize = sizeof(DS3DLISTENER)))
return false;

if(FAILED(g_pDSListener->GetAllParameters( &g_dsListenerParams )))
return false;

return true;
}
Sound3DListener::Sound3DListener()
{
g_pDSListener = NULL;
}
Sound3DListener::~Sound3DListener()
{
if(g_pDSListener)
{
g_pDSListener->Release();
g_pDSListener = NULL;
}
}

Sound3D::Sound3D()
{
g_pDS3DBuffer=NULL;
}
Sound3D::~Sound3D(){
if(g_pDS3DBuffer) {
g_pDS3DBuffer->Release();
g_pDS3DBuffer=NULL;
}
}

bool Sound3D::create(LPDIRECTSOUNDBUFFER sb){
if(FAILED(sb->QueryInterface(IID_IDirectSound3DBuffer,
(VOID**)&g_pDS3DBuffer )))
return false;

g_dsBufferParams.dwSize = sizeof(DS3DBUFFER);
if(FAILED(g_pDS3DBuffer->GetAllParameters( &g_dsBufferParams )))
return false;

g_dsBufferParams.dwMode = DS3DMODE_HEADRELATIVE;
if(FAILED(g_pDS3DBuffer->SetAllParameters( &g_dsBufferParams, DS3D_IMMEDIATE )))
return false;

DSBCAPS dsbcaps;
ZeroMemory( &dsbcaps, sizeof(DSBCAPS) );
dsbcaps.dwSize = sizeof(DSBCAPS);

if(FAILED(sb->GetCaps( &dsbcaps )))
return false;

return true;
}

Share this post


Link to post
Share on other sites
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!