FFT in a JUCE Plug-In

Hello! I’m designing a plugin in which I need to perform the fft to the input channels. I’ve read JUCE dsp::fft documentation but it’s still not clear to me and I don’t know how to implement it. Could somebody give me a hand on this??

Thank you!

have you seen JUCE: Tutorial on FFT? Its really nice as an entry point. Or do you have specific questions that go beyond this tutorial?

Thank you for your fast response, Peter!
Well, I’ve seen that tutorial but it’s not exacly what I’m looking for. I need to apply a fft for each one of my input channels (twelve), filter each channel with other fft ( constant values, nothing to do with input channels) and then compute the inverse fft to deliver it to the output. I can’t see any examples of applying fft to the input channels… that’s why I was asking here, I always get help from this forum :slight_smile:

Ok! I am not entirely sure if I really understand your problem, but here are my two cents:

  • you probably want your FFT size independent from the buffer size? If so you need some fifo like in the tutorial to collect enough data for the next round of FFT
  • do you need to combine the FFT data of the twelve channels or is the processing independent for each channel? in any case you will do the twelve FFTs sequentially, but if you want to combine the data, or have different FFT parameters for each channel you might also want to use twelve juce::dsp::FFT objects. Its expensive to create these, so create these once and not during the process
  • in your processBlock you iterate the channels and whenever there is enough data in the fifo you apply the FFT on it. So you are now in the frequency domain and can do your spectral dsp.
  • once you have done your spectral dsp for all the channels you apply the inverseFFT to get the processed time domain data back (either for all the twelve channels independently, or only once if in your usecase all the 12 channels are combined in the frequency domain). You can then copy this data to your process block.
    Actually juce::dsp::FFT takes care for everything with regards to the transform itself. You just need to to the fifo-ing and feed the data into the juce:dsp::FFT objects.
    Does this help? Or can you be more specific on where you have the difficulty?
    Kind Regards
1 Like

Thank you very much! It’s been very clarifying.
I’ll try with those tips and get back here if I find more trouble!

Hi Peter! I’ve realised my main problem is that I’m not familiarized with the implementation of the dsp::FFT module. I’m having trouble with the inisialization of the fft object in the constructor, and I don’t know how to apply de FFT to the input channel… Thank you in advance for reading me

That feels… dangerous. You should not really filter like that in the spectral domain, you have to remember that a spectrum multiplication is a convolution is the time domain, which means that you will alias.
So be sure first that what you are doing makes mathematical sense, as it’s not clear at all to me that it does.

Maybe can you share the part of your code you struggle with, and describe what exactly is the troublesome part? Or share it as pseudo-code. This makes it easier to help you.

1 Like

Agreed, show us what you want to do, and we can tell you if it’s something valid or not (as I’ve said, the odds are that it’s not valid due to time aliasing, but show us to be sure).