• 14
• 12
• 9
• 10
• 9

# DirectAudio and Listener Position

This topic is 3956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I have been implementing a small sound library but somehow, i can't get the 3d sounds to work in relation to the listener. Whatever i do, it seems the listener it's allways at position (0,0,0). I can move the sounds and they do change volume in relation to the distance to the listener, but if the sound is in a constant position, and if i move the listener position, nothing happens. RollOf Factor doesn't seem to do much either. Can someone take a look at my configuration and spot what am i doing wrong ?

typedef struct tsound
{
IDirectMusicPerformance8* m_pPerformance;
IDirectMusicSegment8* m_pSegment;
IDirectMusicAudioPath8* m_p3DAudioPath;
IDirectSound3DBuffer8* m_pDSB;
struct tsound   *next;
}*sound_entity;

// directmusic performance object
IDirectMusicPerformance8* m_pPerformance;


That's the basic structure, now i initialize the sound library :
m_pPerformance = NULL;
if (FAILED(hr = CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC,
return hr;

// Create performance object
if (FAILED(hr = CoCreateInstance( CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, IID_IDirectMusicPerformance8, (void**)&m_pPerformance )))
return hr;

// This initializes both DirectMusic and DirectSound and
// sets up the synthesizer.
if (FAILED(hr = m_pPerformance->InitAudio( NULL, NULL,myhWnd,
DMUS_APATH_DYNAMIC_3D, 64,DMUS_AUDIOF_ALL, NULL )))
return hr;


And i load a sound :

IID_IDirectMusicSegment8, name,(LPVOID*) &I_Sound->m_pSegment );

// by default don't repeat soundss
hr = I_Sound->m_pSegment->SetRepeats( 0 );

hr = I_Sound->m_pPerformance->CreateStandardAudioPath( DMUS_APATH_DYNAMIC_3D,
64, TRUE, &I_Sound->m_p3DAudioPath );

// Get the IDirectSound3DBuffer8 from the 3D audiopath
hr = I_Sound->m_p3DAudioPath->GetObjectInPath( DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER, 0, GUID_NULL, 0, IID_IDirectSound3DBuffer8, (LPVOID*) I_Sound->m_pDSB );

// get the listener from the 3d audiopath
hr = I_Sound->m_p3DAudioPath->GetObjectInPath(0, DMUS_PATH_PRIMARY_BUFFER,
0, GUID_NULL, 0,IID_IDirectSound3DListener8,
LPVOID*)&m_pListener);

I_Sound->m_pDSB->SetMode(DS3DMODE_NORMAL,DS3D_IMMEDIATE);


Using DS3DMODE_NORMAL or DS3DMODE_HEADRELATIVE gives me the same result. I don't get a error report in any of this functions, and when i call

hr = m_pListener->SetPosition(pos[0], pos[1], pos[2], DS3D_IMMEDIATE);


i get a S_OK , but nothing changes, is as if the listener is not working or is being completely ignored. Any ideias on what can be wrong here ?? thanks, Bruno