Jump to content
  • Advertisement
Sign in to follow this  
Bruno

DirectAudio and Listener Position

This topic is 4077 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 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;
}*sound_entity;

// 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, 
                DMUS_APATH_DYNAMIC_3D, 64,DMUS_AUDIOF_ALL, NULL )))
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,
		                   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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!