I might be missing something completely trivial here, but it’s driving me crazy. I’m trying to implement one of the WDF filters from Pirkle’s book, the documentation for which is here
private:
WDFTunableButterLPF3 lpfLeft, lpfRight;
juce::AudioParameterFloat * cutoffFreqParameter;
cutoffFreqParameter
is attached to a GUI slider.
The createWDF()
is called in the class constructor, and I call the reset()
in the processor’s prepareToPlay()
.
void AnalogFiltersAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
lpfLeft.reset(sampleRate);
lpfRight.reset(sampleRate);
lpfLeft.setUsePostWarping(true);
lpfRight.setUsePostWarping(true);
}
This is my processBlock()
code:
void AnalogFiltersAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
auto fc = cutoffFreqParameter->get();
lpfLeft.setFilterFc((double)fc);
lpfRight.setFilterFc((double)fc);
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
auto currentOutChannels = getNumOutputChannels();
for (int channel = 0; channel < currentOutChannels; ++channel)
{
auto* channelData = buffer.getWritePointer (channel);
auto numSamples = buffer.getNumSamples();
for (auto sample = 0; sample < numSamples; sample++) {
float xn, yn;
xn = channelData[sample];
if (channel == 1) // right channel
yn = (float)lpfRight.processAudioSample((double)xn);
else
yn = (float)lpfLeft.processAudioSample((double)xn);
channelData[sample] = yn;
}
}
}
When I bypass the plugin, I get sound out in the AudioPluginHost as expected, but as soon as I turn the plugin on, even when the cutoff is set to 20,000Hz on the slider, there is no sound out.
I’ve checked setFilterFc()
with the debugger and confirmed that the filter objects are receiving the expected value for cutoff. When I break at channelData[sample] = yn;
I see that yn
is significantly smaller in magnitude than xn
(practically non-zero).
I can’t tell whether I’m misunderstanding how to use the WDFTunableButterLPF3
class or if I’m messing up somewhere in my processBlock()
loops. There shouldn’t be any issue of saving the inner loop state as far as I can tell, because I believe each WDFTunableButterLPF3
tracks that internally.
UPDATE: Here’s some more confusing tests and results in the AudioPluginHost:
Audio Input directly into Audio Output, buggy plugin not added to host yet: clean audio.
Buggy plugin added to host, nothing connected to inputs or outputs: choppy audio, even though it isn’t hooked up.
Audio Input connected to buggy plugin, outputs of plugin connected to Audio Ouptut: no sound??
Audio Input and Audio Output disconnected again: choppy audio.
Buggy plugin deleted from host: clean audio.