Hey, I am currently trying to get the FFT parameterData, but following all examples I can find online, the fft response has a numchannels of 0 always.

Am I thinking about this wrong? Or is something up with my code maybe?

 // This is defined outside the loop
FMOD::DSP* dsp;
    system->createDSPByType(FMOD_DSP_TYPE::FMOD_DSP_TYPE_FFT, &dsp);

    // This is in the loop
    dsp->getParameterData(FMOD_DSP_FFT_SPECTRUMDATA, (void **)&fft, 0, 0, 0);

    Common_Draw("Channels %d", fft->numchannels);
    for (int channelz = 0; channelz < fft->numchannels; channelz++)
                Common_Draw("count %f", channelz);
                for (int bin = 0; bin < fft->length; bin++)
                    float val = fft->spectrum[channelz][bin];
                    Common_Draw("FFT  %f", val);

I am using the record.cpp example for the low-level api.

Thank you for any feedback.

  • You must to post comments
Best Answer

Hi ,
I put this code into the recording example and it seemed to work fine.

The key would be where to put your ‘outside the loop’ code though.
The playsound only happens after a few updates, so it has to go after the playSound call so that channel is valid.

Are you checking error return values? I have a feeling you would be getting errors. (ie FMOD_ERR_INVALID_HANDLE in addDSP).

  • brett

    oh yeah, inside your loop ie ‘// This is in the loop’ should be wrapped in a check to see if dsp is valid or not.


    if (dsp)
    // your inside loop code

    as the first time through it will be using ‘0’ as your pointer value which is invalid. Looking at a debugger should reveal this.

  • Scott Hedstrom

    Thank you Brett! That did the trick.

    I think I messed some other stuff up in the file, because I’m getting some weird unrelated errors now that its running. (I messed with it for a while).

    Is there any way I can get you to the contents of your record.cpp file so I don’t have to uninstall/reinstall? I cant seem to find the files anywhere except thru the api installer.

    No worries if not, and thanks so much!

  • brett

    Hi Scott, I put the modified record example here

  • Scott Hedstrom

    Hey Brett,

    Using that code, the FFT will come back a for a few rounds, then it throws this error:

    Exception thrown: read access violation.
    string was 0x2371A3C5840.

    I tried to catch all the possible fails, but still not working, any ideas:

    for (int channelz = 0; channelz numchannels; channelz++)
    int length = fft->length – 1;
    if(length != NULL){
    for (int bin = 0; bin < length; bin++)
    //for (int bin = 0; bin spectrum[channelz][bin];
    if (!isnan(val)) {
    Common_Draw(“FFT %f”, val);


  • brett

    can you use the debugger to inspect the variables? I dont think length being null is a good check. For a start it should not be NULL but 0 (null is typically only used for pointers) and also if fft->length was 0 then length would be -1 anyway.
    The for loop wouldnt execute if length was 0 or -1 anyway.

    Have you determined that’s why it has the problem? Where is the read, and what variable is it talking about?

Showing 1 result
Your Answer

Please first to submit.