What is a best way to perform fft ahead of actual sound playback?

I’m using data from FFT DSP to perform beat detection and want the actual sound to be played several seconds after the fft.

First option is to put delay dsp after the fft, but doing so results in more memory usage and offset time is limited to 10 seconds.

Another option is to create two channels, one for fft and another for playback. But how can I sync them correctly? May be the Channel::setDelay() of any help in this case?

I make call GetParameterData in a 60 fps game loop. Obviously, the underlying DSP chain operates in different intervals, but does it have any drawbacks? If the fft performed as input samples fill the window, is there any way to get a callback?

To keep your analysis in sync with the mixer, the best callback to use is a dsp callback.

Also did you know you don’t need to use the FFT dsp, you can perform the FFT yourself?


    FMOD_MEMORY_ALLOC_CALLBACK              alloc;          /* [r] Memory allocation callback. Use this for all dynamic memory allocation within the plugin. */
    FMOD_MEMORY_REALLOC_CALLBACK            realloc;        /* [r] Memory reallocation callback. */
    FMOD_MEMORY_FREE_CALLBACK               free;           /* [r] Memory free callback. */
    FMOD_DSP_SYSTEM_GETSAMPLERATE           getsamplerate;  /* [r] Callback for getting the system samplerate. */
    FMOD_DSP_SYSTEM_GETBLOCKSIZE            getblocksize;   /* [r] Callback for getting the system's block size.  DSPs will be requested to process blocks of varying length up to this size.*/
    FMOD_DSP_STATE_DFTCALLBACKS            *dft;            /* [r] Struct containing callbacks for performing FFTs and inverse FFTs. */
    FMOD_DSP_STATE_PAN_CALLBACKS           *pancallbacks;   /* [r] Pointer to a structure of callbacks for calculating pan, up-mix and down-mix matrices. */
    FMOD_DSP_SYSTEM_GETSPEAKERMODE          getspeakermode; /* [r] Callback for getting the system's speaker modes.  One is the mixer's default speaker mode, the other is the output mode the system is downmixing or upmixing to.*/
    FMOD_DSP_STATE_GETCLOCK                 getclock;       /* [r] Callback for getting the clock of the current DSP, as well as the subset of the input buffer that contains the signal */

the dft callbacks let you input pcm and get frequency domain information back out.