3D Sound

Started by
2 comments, last by melonjelly 20 years, 1 month ago
Hi! I hope anybody could help me. I have a weird problem going on with 3DSound using Direct Audio 8.1. I have ONE global 3D listener object managed by my audio-engine which I get from the primary sound buffer like this:
  
DSBUFFERDESC     dsbd;
LPDIRECTSOUNDBUFFER  lpdsbPrimary;
		 
ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;

if SUCCEEDED(directSound->CreateSoundBuffer(&dsbd, &lpdsbPrimary, NULL))
{
	// Get listener interface.

	if FAILED(lpdsbPrimary->QueryInterface(IID_IDirectSound3DListener8,(void**)&listener3D))
	{
		cerr << "Failed to get 3D audio listener in audio path." << endl;
		lpdsbPrimary->Release();
	}
}
  
everything works fine here and I don't get any errors. BUT whenever I try to change the position of my listender nothing happens!!! i.e. listener3D->SetPosition(10.0f, 0.0f, 10.0f, DS3D_IMMEDIATE); the listener seems to be stuck to my gameworld origin (because the closer I am to 0/0 the louder the sound - which plays on a 3D audio-path gets) Does anybody have an idea what's going on here? Thanks in advance! [edited by - melonjelly on August 29, 2002 2:56:35 AM]
Advertisement
hmmm... nobody has an idea? hmm...
Unfortunately I still have not figured out what''s going on...

Either my 3D soundbuffers don''t move as expected or my 3D listener does not change its position.


Please help!
You need to set the position of two things: The listener and the sound.

From what you describe you are not setting the sound position. Therefore it stays at its default position 0,0,0. Also setting the min and max range is important as it will affect how far away you must move before the volume changes.

You will need get get a DirectSound3DBuffer interface, and call the SetPosition function.

Cheers,
John

John Reynolds
Creative Asylum Ltd
www.creative-asylum.com
John ReynoldsCreative Asylum Ltdwww.creative-asylum.com
Hi,this is my source from 3Dsound.cpp, it works fine.
//-----------------------------------------------------------------------------
// Name: Set3DPosition()
// Desc: Set the 3D buffer parameters
// iID is the soundbuffer
// xp, yp, zp are the cartians vector values. default in meters''s
// Example: 0,0,0 is normal position.
// -10,0,10 is left front speaker
// 10,0,10 is right front speaker
// 10,0,-10 is right rear speaker
// -10,0,-10 is left rear speaker
// the yp has no efffect i think..?
//-----------------------------------------------------------------------------
BOOL Set3DPosition(int iID,float xp, float yp, float zp)
{
HRESULT hr;
// Get the 3D buffer from the secondary buffer
if( FAILED( hr = g_pSound[iID]->Get3DBufferInterface( 0, &g_pDS3DBuffer ) ) )
{
MessageBox( NULL, "Could not get 3D buffer.",
" PuppetShow",
MB_ICONERROR | MB_OK );

return FALSE;
}

g_pDS3DBuffer->SetPosition(xp,yp,zp,DS3D_IMMEDIATE);

return TRUE;

} // end Set3DPosition
Cogito Ergo Sum

This topic is closed to new replies.

Advertisement