Help with IIR Filter


#1

Hi all, I’m new to JUCE and my knowledge of C++ isn’t great either. I’d like to add a filter to a tutorial I’ve been following but I’m unsure of how to process the sound with the filter.

My processing code looks like this:

void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) override
{
    // Your audio-processing code goes here!
	float* const leftSpeaker = bufferToFill.buffer->getWritePointer(0, bufferToFill.startSample);
	float* const rightSpeaker = bufferToFill.buffer->getWritePointer(1, bufferToFill.startSample);
	for (int sample = 0; sample < bufferToFill.numSamples; ++sample)
	{
		leftSpeaker[sample] = waveTable[(int)phase] * amplitude;
		rightSpeaker[sample] = waveTable[(int)phase] * amplitude;		
		updateFrequency();
	}

}

I’ve created the filter and set the coeffecients in prepare to play, as well as calculated the wave there too, but I’m unsure how and where to use the process samples function which I think is what I have to use?


#2

You need to setup a ProcessContext and then call the process method in the IIR filter. See the IIR DSP Demo code here and here to see how this can be done.