Now that XAudio2 is clear, time to be confused with X3DAudio

  • Finished rolling up the SampleSounds(s) into BasicAudio.
  • Starting on 3D audio, using How to: Integrate X3DAudio with XAudio2
    • Adding the 3D calls to the main() in ConsoleSound2, just after the BasicAudio class has been initialized.
    • Had to add x3daudio.lib to the project and <x3daudio.h> to the #includes.
    • This looks to be the meat of the calculation. It looks like X3DCalculate() works on the relative position of an Emitter and the Listener and uses that to populate a DSP. Once that’s done, then the Audio2 source is manipulated appropriately.
    •         X3DAudioCalculate( g_audioState.x3DInstance, &g_audioState.listener, &g_audioState.emitter, dwCalcFlags,
                                 &g_audioState.dspSettings );
      
              IXAudio2SourceVoice* voice = g_audioState.pSourceVoice;
              if( voice )
              {
                  // Apply X3DAudio generated DSP settings to XAudio2
                  voice->SetFrequencyRatio( g_audioState.dspSettings.DopplerFactor );
                  voice->SetOutputMatrix( g_audioState.pMasteringVoice, INPUTCHANNELS, g_audioState.nChannels,
                                          g_audioState.matrixCoefficients );
      
                  voice->SetOutputMatrix(g_audioState.pSubmixVoice, 1, 1, &g_audioState.dspSettings.ReverbLevel);
      
                  XAUDIO2_FILTER_PARAMETERS FilterParametersDirect = { LowPassFilter, 2.0f * sinf(X3DAUDIO_PI/6.0f * g_audioState.dspSettings.LPFDirectCoefficient), 1.0f }; // see XAudio2CutoffFrequencyToRadians() in XAudio2.h for more information on the formula used here
                  voice->SetOutputFilterParameters(g_audioState.pMasteringVoice, &FilterParametersDirect);
                  XAUDIO2_FILTER_PARAMETERS FilterParametersReverb = { LowPassFilter, 2.0f * sinf(X3DAUDIO_PI/6.0f * g_audioState.dspSettings.LPFReverbCoefficient), 1.0f }; // see XAudio2CutoffFrequencyToRadians() in XAudio2.h for more information on the formula used here
                  voice->SetOutputFilterParameters(g_audioState.pSubmixVoice, &FilterParametersReverb);
              }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s