I chose to use my own specified coefficients to create an iir filter, but there was always noise, and I don’t know what problem I overlooked? (This coefficient is not a problem as it does not produce any popping sound, which I have verified in Python)
void FilterAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
float* channel1Data = buffer.getWritePointer(0);
float* channel2Data = buffer.getWritePointer(1);
juce::dsp::IIR::Coefficients<float>coefs(std::array<float, 10>{ 0.00117571, 0. , -0.00235143, 0. , 0.00117571,1. , -3.9201592 , 5.76585759, -3.77123379, 0.92553541 });
juce::dsp::IIR::Filter<float>filter;
//filter.reset();
juce::ReferenceCountedObjectPtr<juce::dsp::IIR::Coefficients<float>> coefsPtr = new juce::dsp::IIR::Coefficients<float>(coefs);
filter.coefficients = coefsPtr;
filter.reset();
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
channel1Data[i] = filter.processSample(channel1Data[i]);
channel1Data[i] = filter.processSample(channel2Data[i]);
}
}
