# Problem getting Spectrum in newer fmod versions

**URL:** <https://qa.fmod.com/t/problem-getting-spectrum-in-newer-fmod-versions/11624>\
**Category:** FMOD Engine\
**Created:** [September 2, 2014, 7:07am UTC](https://qa.fmod.com/t/problem-getting-spectrum-in-newer-fmod-versions/11624 "2014-09-02T07:07:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Webby2k](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@Webby2k](https://qa.fmod.com/u/Webby2k)\
**Post date:** [September 2, 2014, 7:07am UTC](https://qa.fmod.com/t/problem-getting-spectrum-in-newer-fmod-versions/11624/1 "2014-09-02T07:07:36Z")

</div>

Hi guys,

I’ve been working on a project using fmod in it for more than a year. Unfortnately I had to format my computer and downloaded the latest version of fmod studio that has quite a few changes in using its syntax.

Now I’m not capable of getting the spectrum out of a sound. In the earlier version I used this way [http://52.88.2.202/questions/question/forum-40164](http://52.88.2.202/questions/question/forum-40164) wich was working really great. But in recent fmod versions the same source code is not working anymore. While the old method to write the spectrum into a buffer was like:

```
char s[256];
unsigned int len;
float *data = 0;
float freq[32];

result = dspfft->getParameterData(FMOD_DSP_FFT_SPECTRUM, (void **)&data, &len, s, 256);

```

the newer Version substitutes the FMOD\_DSP\_FFT\_SPECTRUM with FMOD\_DSP\_FFT\_SPECTRUMDATA and more importantly requires a different Buffer Parameter to write the spectrum through, which I guess is the FMOD\_DSP\_PARAMETER\_FFT. But I don’t know how to use it.

I found this article [http://52.88.2.202/questions/question/dsp-getparameterdata-silent-crash-unity](http://52.88.2.202/questions/question/dsp-getparameterdata-silent-crash-unity) that says it goes like this (I’m using Visual C++):

```
System::IntPtr unmanagedData;
    unsigned int unmanagedDataLen = 0;
    result = spectrum->getParameterData(FMOD.DSP_FFT.SPECTRUMDATA, (void **)& unmanagedData, unmanagedDataLen);
    FMOD_DSP_PARAMETER_FFT waveFormBuffer = (FMOD_DSP_PARAMETER_FFT)Marshal::PtrToStructure(unmanagedData, FMOD_DSP_PARAMETER_FFT::typeid);

```

But this goes nowhere. First I don’t understand why would I pass a managed pointer to a function that writes unmanaged data into it. Can’t I pass directly a FMOD\_DSP\_PARAMETER\_FFT structure to the getParameterData method? Secondly, the PtrToStructure function can’t be used / compiled this way, since the FMOD\_DSP\_PARAMETER\_FFT is not a managed type and the return type is also a managed System::Object, which can’t be converted to an unmanaged FMOD\_DSP\_PARAMETER\_FFT structure.

Can somebody please give me a short example how to get the spectrum in latest releases? It would be also very helpful for other users to provide a spectrum example in future fmod studio api releases.

On the other hand, up to which version can I use my old syntax using the big float buffer? Is this version still available for download?

Thanks in advance for your help

---

<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:** [September 2, 2014, 7:53am UTC](https://qa.fmod.com/t/problem-getting-spectrum-in-newer-fmod-versions/11624/2 "2014-09-02T07:53:57Z")

</div>

```
FMOD_DSP_PARAMETER_FFT *fft;
fftdsp->getParameterData(FMOD_DSP_FFT_SPECTRUMDATA, (void **)&fft, 0, 0, 0));
for (int channel = 0; channel < fft->numchannels; channels++)
{
    for (int bin = 0; bin < fft->length; bin++)
    {
        float val = fft->spectrum[channel][bin];
    }
}
```

---

<div class="post-metadata">

**Author:** ![Webby2k](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@Webby2k](https://qa.fmod.com/u/Webby2k)\
**Post date:** [September 3, 2014, 6:44am UTC](https://qa.fmod.com/t/problem-getting-spectrum-in-newer-fmod-versions/11624/3 "2014-09-03T06:44:51Z")

</div>

> [@](#):
>
> ```
> FMOD_DSP_PARAMETER_FFT *fft;
> fftdsp->getParameterData(FMOD_DSP_FFT_SPECTRUMDATA, (void **)&fft, 0, 0, 0));
> for (int channel = 0; channel < fft->numchannels; channels++)
> {
> for (int bin = 0; bin < fft->length; bin++)
> {
> float val = fft->spectrum[channel][bin];
> }
> }
> 
> ```

Thank you, that was exactly what I needed. Now it works perfectly again 🙂
