I might just be using it wrong, but the definition of FMOD_DSP_PARAMETER_FFT in C# seems completely wrong. I can’t do anything but get it to crash.
By reading the docs I believe I’ve figured out roughly how it should actually look, which is this struct (followed by an example of how to use it):
[StructLayout(LayoutKind.Sequential)]
private unsafe struct ActualDspParameterFft {
public int length;
public int numchannels;
// note: not float**, float[] or float[][]
public float* spectrum;
}
private unsafe void FeedFModFFTOutputIntoWaveform (Span<Vector2> waveform) {
AssertOk(FMod.FFTDsp.getParameterFloat((int)FMOD.DSP_FFT.RMS, out var rms));
AssertOk(FMod.FFTDsp.getParameterData((int)FMOD.DSP_FFT.SPECTRUMDATA, out var pSpectrum, out var nSpectrum));
var pFft = (ActualDspParameterFft*)pSpectrum;
// if the fft hasn't processed enough input yet its length or channels will be 0
if ((pFft->length <= 0) || (pFft->numchannels <= 0))
return;
var spectrumData = new Span<float>(pFft->spectrum, pFft->length);
// spectrumData contains the data for the first channel
}