Plugin Crashing in AudioPluginHost

Hey everyone!

I am creating a VST3 plugin and need to run an FFT on the incoming audio. This is the code for the processBlock:

//===========================================================
void MyMidireaderAudioProcessor::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
    buffer.clear (i, 0, buffer.getNumSamples());

for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
    auto* channelData = buffer.getWritePointer (channel);

    
    window.multiplyWithWindowingTable (channelData, buffer.getNumSamples()); 
    forwardFFT.performFrequencyOnlyForwardTransform (channelData);
    
}

}

//===========================================================

It compiles just fine but when I try to run it in the JUCE AudioPluginHost App it crashes the moment I add the VST3 into the plugin host. I am using Visual Studio 2017 and the process memory graph is extremely high. I;m running out of memory. COuld I have suggestions on what I am doing wrong?

Your FFT and processBlock buffer size most likely don’t match. There’s no easy solution, you will need to do separate buffering for the FFT. (Gather samples into the buffer and once there are enough, then do the FFT.)

Anyway, it would be useful to know if the crash actually happens during processBlock or somewhere else in the code. Run your code under the debugger to confirm that…

With C++ the fact that the code compiles, doesn’t mean anything for what can happen at run time. Code that compiles fine can fail in spectacular ways when it is run.

1 Like

You were right. I used the first in first out method in the simpleFFT example and that sorted all this out. Looks like the AudioBuffer is not a fixed length. Didn’t know, lesson learnt! Thanks a lot!