//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?
- Alex Morano asked 4 years ago
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));
Please login first to submit.