DSP no appropriate default constructor available

dsp_module

#1

I added the dsp module in projucer, now when i try to create my FFT object, i get this error:

‘Error C2512 ‘juce::dsp::FFT’: no appropriate default constructor available’

Im using the FFT simple example as reference, and it compiles and runs fine, but i cant seem to initialize the fft object on my project. its a blank audio plugin with the line:
dsp::FFT ForwardFFT;
added to the header file

what am i doing wrong?


#2

You need to initialize the FFT object in the constructor initializer list like in the simple FFT example code (I guess in your case in the constructor of your AudioProcessor subclass) :

    SpectrogramComponent()
        : forwardFFT (fftOrder)
´´´

#3

I changed:
public:
AudioTattooAudioProcessor();
~AudioTattooAudioProcessor();

to:
public:
AudioTattooAudioProcessor() :ForwardFFT(10) {};
~AudioTattooAudioProcessor();

I get the same error along with a new one, saying the shared code processor already has a body.


#4

You must not add the constructor list in the declaration in the header file if your AudioProcessor has the constructor defined in the .cpp file. (So you need to put the initialization list in the .cpp file.)


#5

I think the issue i am having stems from my app being an audio processor and his being a component. the structure seems different for each. I have a process blocks in my cpp file while they have get next audio block in their header file. can you explain the difference between audio processor and a component to me?


#6

I got it working…why does there appear to be a constructor in the h and cpp files? that is confusing.thank you for the quick reply…saved me a few hours of hair pulling.


#7

The simple FFT example both declares and defines the constructor (as well as the other methods) for the SpectrogramComponent in the header file. The audio plugin template generated by Projucer on the other hand generates both header and .cpp files for the AudioProcessor and the AudioProcessorEditor. Neither way of doing it is wrong. (There are pros and cons for both approaches.)


#8

Thank you that makes sense, I have successfully generated an FFT of my incoming signal, I have zeroed out everything in the freq domain and inverted the FFT and it came out great. now when i try to put the new signal(should be silent) to the write pointer i created, i still get audio even when the data being sent is all -4.0 (ampl vs time). how do i update the write pointer?

my code: (fftData holds the new time domain signal after the inverse xform, breakpoints show this to be working correctly)

for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
	auto* channelData = buffer.getWritePointer(channel);
	for (int i = 0; i <buffer.getNumSamples(); ++i)
	{ 			
		pushNextSampleIntoFifo(channelData[i]);
		channelData[i] = fftData[i];
	}
    // ..do something to the data...
}