I’m new here and I was trying to make a highpass filter plugin, but for some reason it keeps producing a buzz sound. Can someone please tell me what I’m doing wrong please?
This is my processBlock function:
processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
for (int channel = 0; channel < totalNumOutputChannels; ++channel)
{
float* channelData = buffer.getWritePointer(channel);
mFrequencySmoothed = mFrequencySmoothed - 0.4*(mFrequencySmoothed - mFrequencyParameter->get());
filter->setCoefficients(IIRCoefficients::makeHighPass(getSampleRate(), mFrequencySmoothed));
filter->processSamples(channelData, buffer.getNumSamples());
}
}
This is how I created the filter pointer and my prepareToPlay function:
IIRFilter *filter;
void prepareToPlay (double sampleRate, int samplesPerBlock)
{
filter = new IIRFilter();
}