# DSP getParameterData silent crash unity

**URL:** <https://qa.fmod.com/t/dsp-getparameterdata-silent-crash-unity/11564>\
**Category:** Unity\
**Created:** [July 17, 2014, 9:16pm UTC](https://qa.fmod.com/t/dsp-getparameterdata-silent-crash-unity/11564 "2014-07-17T21:16:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alexander/32/12_2.png) [@Alexander](https://qa.fmod.com/u/Alexander)\
**Post date:** [July 17, 2014, 9:16pm UTC](https://qa.fmod.com/t/dsp-getparameterdata-silent-crash-unity/11564/1 "2014-07-17T21:16:30Z")

</div>

```
    //FMOD_DSP_TYPE_FFT
    result = system.createDSPByType(FMOD.DSP_TYPE.FFT, out spectrum);
    ERRCHECK(result);
    
    FMOD.DSP_PARAMETER_FFT waveFormBuffer;
    IntPtr waveFormPtr = Marshal.AllocHGlobal(Marshal.SizeOf(waveFormBuffer));
    Marshal.StructureToPtr(waveFormBuffer, waveFormPtr, false);

    uint bytes = 0;
    result = spectrum.getParameterData((int)FMOD.DSP_FFT.SPECTRUMDATA, out waveFormPtr, out bytes);

```

  
When you run this in the Editor, or in standalone builds, on an "exit" it does a silent crash of Unity.

There are no initialization errors, and if I remove the DSP effect, there is no silent crash. The specific line that seems to cause the crash is the getParameterData call. If you call that a single time it will cause the crash.

Am I perhaps not initializing this correctly? Maybe the marshal/memory allocation calls are incorrect?

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [July 22, 2014, 7:31am UTC](https://qa.fmod.com/t/dsp-getparameterdata-silent-crash-unity/11564/2 "2014-07-22T07:31:18Z")

</div>

You don’t need to allocate unmanaged memory to pass into FMOD. FMOD is not copying the data out, it is returning a pointer to it’s internal data (obviously unmanaged). Getting the spectrum should look like this.

```
        IntPtr unmanagedData;
        uint unmanagedDataLen = 0;
        result = spectrum.getParameterData((int)FMOD.DSP_FFT.SPECTRUMDATA, out unmanagedData, out unmanagedDataLen);
        FMOD.DSP_PARAMETER_FFT waveFormBuffer = (FMOD.DSP_PARAMETER_FFT)Marshal.PtrToStructure(unmanagedData, typeof(FMOD.DSP_PARAMETER_FFT));
```

---

<div class="post-metadata">

**Author:** ![Alexander](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alexander/32/12_2.png) [@Alexander](https://qa.fmod.com/u/Alexander)\
**Post date:** [July 24, 2014, 8:20pm UTC](https://qa.fmod.com/t/dsp-getparameterdata-silent-crash-unity/11564/3 "2014-07-24T20:20:47Z")

</div>

Thanks, excellent answer for an off in the stupid moment =p
