How to defer setting order of dsp::FFT

dsp_module
#1

I have developed a few audio plugins that use the FFT class. In my applications, I do not know the required order until run time. This means that I have to repeatedly define my FFT object as a local, unless someone knows a better way. I would rather define it in my class header, i.e.,

private:    
dsp::FFT fft;

and then set the order in, for example, prepareToPlay()

prepareToPlay(...)
{
...
fft.setorder(order);
...
}

Is this a possibility? Thanks!

#2

I think you need to use the fft object via a (smart) pointer in that case and not as a value.

private:
  std::unique_ptr<dsp::FFT> fft;

void prepareToPlay(...)
{
  fft = std::make_unique<dsp::FFT>(order);
}
#3

Thanks! I’ll give it a try.

#4

Works just fine! Thanks again!