# spectrum data has 0 values of half of windowsize by FFTDsp.getParameterData

**URL:** <https://qa.fmod.com/t/spectrum-data-has-0-values-of-half-of-windowsize-by-fftdsp-getparameterdata/13330>\
**Category:** Unity\
**Created:** [August 2, 2017, 11:34am UTC](https://qa.fmod.com/t/spectrum-data-has-0-values-of-half-of-windowsize-by-fftdsp-getparameterdata/13330 "2017-08-02T11:34:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SmallSage](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@SmallSage](https://qa.fmod.com/u/SmallSage)\
**Post date:** [August 2, 2017, 11:34am UTC](https://qa.fmod.com/t/spectrum-data-has-0-values-of-half-of-windowsize-by-fftdsp-getparameterdata/13330/1 "2017-08-02T11:34:23Z")

</div>

```
 public void SpectrumData()
        {
            if (sampleChannel == null)
            {
                var rusult = EventInstance.getChannelGroup(out sampleChannel);
                if (rusult == RESULT.OK)
                {
                    RuntimeManager.LowlevelSystem.createDSPByType(DSP_TYPE.FFT, out FFTDsp);
                    FFTDsp.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)fFTWindow);
                    FFTDsp.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, 128);
                    sampleChannel.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, FFTDsp);
                }
                else return;
            }

            FFTDsp.getParameterData((int)FMOD.DSP_FFT.SPECTRUMDATA, out _unmanagedDataTemp, out _spectrumLenTemp);
            _fftData = (FMOD.DSP_PARAMETER_FFT)Marshal.PtrToStructure(_unmanagedDataTemp, typeof(FMOD.DSP_PARAMETER_FFT));
            Array.Clear(sample, 0, sampleSize);
            if (_fftData.numchannels > 0 && _fftData.spectrum[0].Length >= sampleSize)
            {
                Array.Copy(_fftData.spectrum[0], sample, sampleSize);
            }
        }

```

![enter image description here](https://github.com/SmallJJ/MissingIceCream/blob/master/Document/ss.PNG?raw=true)

zero value always starts at 63 when windowsize set as 128

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 4, 2017, 12:09am UTC](https://qa.fmod.com/t/spectrum-data-has-0-values-of-half-of-windowsize-by-fftdsp-getparameterdata/13330/2 "2017-08-04T00:09:17Z")

</div>

Without going into the math too much i’ll just say this is correct, ie from wikipedia

There is a topic already, in this FMOD QA post

[http://www.fmod.org/questions/question/how-to-set-dsp-fft-window-size/](http://www.fmod.org/questions/question/how-to-set-dsp-fft-window-size/)

“Yes. To be precise the first half of the FFT buffer contains the positive frequencies, which is what you’re interested in. The second half contains the negative frequencies, which is symmetrical to the positive frequencies.”

and its mentioned here

[https://fmod-com-staging.herokuapp.com/resources/documentation-api?page=content/generated/FMOD\_DSP\_PARAMETER\_FFT.html](https://fmod-com-staging.herokuapp.com/resources/documentation-api?page=content/generated/FMOD_DSP_PARAMETER_FFT.html)

“Only read/display half of the buffer typically for analysis as the 2nd half is usually the same data reversed due to the nature of the way FFT works.”
