locked
Cannot get X3DAudioCalculate to work

    Question

  • Hi,

    I was able to successfully integrate XAudio2 into my game, and was now trying to get X3DAudio working, but haven't been able to. I'm trying to follow the step-by-step instructions from here: http://msdn.microsoft.com/en-us/library/windows/desktop/ee415798%28v=vs.85%29.aspx

    My problem is that X3DAudioCalculate is crashing (First-chance exception at 0x0FDE1BFE (XAudio2_8.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0x00000000.)

    I don't really know much at all about audio and audio processing, but from what I can tell I am correctly following the steps on MSDN. Here's the relevant code:

    void AudioManager::Impl::Play3DSound(SoundID soundID, const Matrix& emitterMatrix)
    {
        X3DAUDIO_EMITTER emitter;
        memset(&emitter, 0x00, sizeof(X3DAUDIO_EMITTER));
        emitter.ChannelCount = NumChannels;
        emitter.CurveDistanceScaler = FLT_MIN;
        emitter.OrientFront = X3DAUDIO_VECTOR(emitterMatrix[2][0], emitterMatrix[2][1], emitterMatrix[2][2]);
        emitter.OrientTop = X3DAUDIO_VECTOR(emitterMatrix[1][0], emitterMatrix[1][1], emitterMatrix[1][2]);
        emitter.Position = X3DAUDIO_VECTOR(emitterMatrix[3][0], emitterMatrix[3][1], emitterMatrix[3][2]);
        emitter.Velocity = X3DAUDIO_VECTOR(0, 0, 0);
    
        X3DAudioCalculate(X3DInstance,
                          &Listener,
                          &emitter,
                          X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_LPF_DIRECT | X3DAUDIO_CALCULATE_REVERB,
                          &DspSettings);
    
        PlaySound(soundID, true);
    }

    Here's an image showing the values of all variables passed to X3DAudioCalculate. I know a lot of things are NULL, but the documentation seems to indicate that NULL is okay for those parameters.

    Any help would be much appreciated... Thanks!




    • Edited by goobers.2 Sunday, January 19, 2014 4:57 AM
    Sunday, January 19, 2014 4:50 AM

Answers

  • X3DAudio is a very simple API, but the structure is rather complicated. The DirectX SDK version provided a 'chk' version of the library which had built-in asserts, but there's not an equivalent debug mode for the built-in Windows 8.x version unless you are using a 'chk' install of the Windows 8.x OS.

    My guess is that you are setting ChannelCount to a number larger than 1, which requires a non-NULL pChannelAzimuths--this is noted in the MSDN docs.

    PS: Note that X3DAudio use is demonstrated in these samples:

    Tuesday, January 21, 2014 7:08 PM

All replies

  • X3DAudio is a very simple API, but the structure is rather complicated. The DirectX SDK version provided a 'chk' version of the library which had built-in asserts, but there's not an equivalent debug mode for the built-in Windows 8.x version unless you are using a 'chk' install of the Windows 8.x OS.

    My guess is that you are setting ChannelCount to a number larger than 1, which requires a non-NULL pChannelAzimuths--this is noted in the MSDN docs.

    PS: Note that X3DAudio use is demonstrated in these samples:

    Tuesday, January 21, 2014 7:08 PM
  • Hi Chuck,

    Thanks for the links. Those samples helped getting it to work (somewhat). It will require some time to understand the 3d audio concepts, but at least its not crashing now :)

    Thursday, January 23, 2014 7:54 PM
  • The other important thing is to make sure that your X3Audio OrientFront, OrientTop, and Velocity vectors are not degenerate, do not include floating-point specials, or are otherwise invalid. This doesn't usually result in a crash, but it can certain result in really bad sounding audio.

    Friday, January 24, 2014 12:58 AM