Original Post
Problem: Using DX9, XAudio2, XACT - I can't detect an attenuation with increasing distance between listener and emitter. What am I missing?
The stereo direction from emitter to listener works well. Moving my eye direction "swings" the emitter sound appropriately, so I assume my DoWork routine which revises the listener position and emitter positions and invokes XACT3DCalculate and XACT3DApply to the cues is working as intended.
I pretty much lifted the code from the June 2010 SDK. Here's the major portion of my XACT initialization. This code is preceded by a successful load of the xgs file into pGlobalSettingsData, etc.
Following that initialization, the wave and sound banks are successfully loaded.
I start the sound as follows:
Other than attentuation with distance, the sounds play and I get the callback notification for the cue stop.
EDIT: I also tried adding a preset (and attached a sound) with a fast attenuation to -50db at 100 units. With the emitter distance at 100 units, there's no attenuation - i.e., same volume as emitter distance = 0.
[Edited by - Buckeye on December 19, 2010 7:49:56 PM]
The stereo direction from emitter to listener works well. Moving my eye direction "swings" the emitter sound appropriately, so I assume my DoWork routine which revises the listener position and emitter positions and invokes XACT3DCalculate and XACT3DApply to the cues is working as intended.
I pretty much lifted the code from the June 2010 SDK. Here's the major portion of my XACT initialization. This code is preceded by a successful load of the xgs file into pGlobalSettingsData, etc.
// Initialize & create the XACT runtime XACT_RUNTIME_PARAMETERS xrParams = {0}; xrParams.lookAheadTime = XACT_ENGINE_LOOKAHEAD_DEFAULT; xrParams.fnNotificationCallback = XACTNotificationCallback; xrParams.pGlobalSettingsBuffer = pGlobalSettingsData; xrParams.globalSettingsBufferSize = dwGlobalSettingsFileSize; xrParams.globalSettingsFlags = XACT_FLAG_GLOBAL_SETTINGS_MANAGEDATA; // this will tell XACT to delete[] the buffer when its unneeded hr = g_audioState.pEngine->Initialize( &xrParams ); if( FAILED( hr ) ) return hr; ZeroMemory( &g_audioState.listener, sizeof( X3DAUDIO_LISTENER ) ); g_audioState.listener.OrientFront = D3DXVECTOR3(1, 0, 0 ); g_audioState.listener.OrientTop = D3DXVECTOR3( 0, 1, 0 ); g_audioState.listener.Position = D3DXVECTOR3( 0, 0, 0 ); g_audioState.listener.Velocity = D3DXVECTOR3( 0, 0, 0 ); ZeroMemory( &g_audioState.emitter, sizeof( X3DAUDIO_EMITTER ) ); g_audioState.emitter.pCone = NULL; g_audioState.emitter.OrientFront = D3DXVECTOR3( 1, 0, 0 ); g_audioState.emitter.OrientTop = D3DXVECTOR3( 0, 1, 0 ); g_audioState.emitter.Position = D3DXVECTOR3( 0, 0, 0 ); g_audioState.emitter.Velocity = D3DXVECTOR3( 0, 0, 0 ); g_audioState.emitter.ChannelCount = 2; g_audioState.emitter.ChannelRadius = 1.0f; g_audioState.emitter.pChannelAzimuths = NULL; g_audioState.emitter.pVolumeCurve = NULL; g_audioState.emitter.pLFECurve = NULL; g_audioState.emitter.pLPFDirectCurve = NULL; g_audioState.emitter.pLPFReverbCurve = NULL; g_audioState.emitter.pReverbCurve = NULL; g_audioState.emitter.CurveDistanceScaler = 1.0f; g_audioState.emitter.DopplerScaler = NULL; g_audioState.DelayTimes[0] = 0.0f; g_audioState.DelayTimes[1] = 0.0f; // Init MatrixCoefficients. XACT will fill in the values ZeroMemory( &g_audioState.MatrixCoefficients, sizeof( FLOAT32 ) * 8 * 2 ); // query number of channels on the final mix WAVEFORMATEXTENSIBLE wfxFinalMixFormat; hr = g_audioState.pEngine->GetFinalMixFormat( &wfxFinalMixFormat ); if( FAILED( hr ) ) return hr; WORD nDstChannelCount = wfxFinalMixFormat.Format.nChannels; ZeroMemory( &g_audioState.dspSettings, sizeof( X3DAUDIO_DSP_SETTINGS ) ); g_audioState.dspSettings.pMatrixCoefficients = g_audioState.MatrixCoefficients; g_audioState.dspSettings.pDelayTimes = g_audioState.DelayTimes; g_audioState.dspSettings.SrcChannelCount = 2; g_audioState.dspSettings.DstChannelCount = nDstChannelCount; // Initialize 3D settings hr = XACT3DInitialize( g_audioState.pEngine, g_audioState.x3DInstance ); if( FAILED( hr ) ) return E_FAIL;Following that initialization, the wave and sound banks are successfully loaded.
I start the sound as follows:
g_audioState.pSoundBank->Prepare( snum, 0, 0, &pCue3D->pCue ); pCue3D->vEmitterPosition = emitterPos; g_audioState.emitter.Position = pCue3D->vEmitterPosition; XACT3DCalculate( g_audioState.x3DInstance, &g_audioState.listener, &g_audioState.emitter, &g_audioState.dspSettings ); XACT3DApply( &g_audioState.dspSettings, pCue3D->pCue ); pCue3D->pCue->Play();Other than attentuation with distance, the sounds play and I get the callback notification for the cue stop.
EDIT: I also tried adding a preset (and attached a sound) with a fast attenuation to -50db at 100 units. With the emitter distance at 100 units, there's no attenuation - i.e., same volume as emitter distance = 0.
[Edited by - Buckeye on December 19, 2010 7:49:56 PM]