Sign in to follow this  

DirectAudio and Listener Position

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;
    IDirectMusicLoader8* m_pLoader;
    IDirectMusicSegment8* m_pSegment;
    IDirectMusicAudioPath8* m_p3DAudioPath;
    IDirectSound3DBuffer8* m_pDSB;
    struct tsound   *next;

// directmusic performance object
IDirectMusicPerformance8* m_pPerformance;

// directmusic loader object
IDirectMusicLoader8* m_pLoader;

That's the basic structure, now i initialize the sound library :
m_pPerformance = NULL;
m_pLoader = NULL;
// Create loader object
if (FAILED(hr = CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, 
			                             IID_IDirectMusicLoader8, (void**)&m_pLoader )))
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, 
return hr;

And i load a sound :

hr = I_Sound->m_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment,
            IID_IDirectMusicSegment8, name,(LPVOID*) &I_Sound->m_pSegment );

   // Download the segment's instruments to the synthesizer
   hr = I_Sound->m_pSegment->Download( I_Sound->m_pPerformance );

    // 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,


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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this