Hi,
I’m trying to use the FIR filter class (nothing more than that right now, just testing some stuff). I’m not sure how to do a couple of things:
a) Running processSample on each sample in the buffer in a loop works (in so far as it compiles), but doesn’t seem to actually do anything to the audio. I’m generating low pass filter coefficients for the time being. I think I wanna use fir.process() instead, but I’m not exactly sure what I’m supposed to pass into that (the buffer writepointer is apparently not it!). Here’s what I have so far within the processBlock:
float* channelData = buffer.getWritePointer (channel);
for (int sample = 0; sample < buffer.getNumSamples(); ++sample)
{
fir.processSample(channelData[sample]);
}
b) I want to use an array of pre-designed coefficients for the filter, i.e literally have a bunch of numbers written into the code, but I’m not sure what format it should be in/how exactly to do that. Currently I’m generating the coefficients as:
fir.coefficients = dsp::FilterDesign<float>::designFIRLowpassWindowMethod(440.0f, sampleRate, 21, dsp::WindowingFunction<float>::blackman);
But I’m looking to do something like:
fir.coefficients = [0,1,2,3,4 <whatever>]
Just, y’know, correct!
c) This method is clearly not going to work for multiple channels. I presume I can just hard-code definitions for a filter for the left/right channels, but I image there’s a better way to do it (one that can scale to more channels etc automatically?).
d) More of an add-on question, but I’m intending to operate on the incoming audio buffer and not necessarily have that as the output. In other words, I don’t wanna operate directly on the buffer - can I copy the input audio buffer and operate on that, or is there a more elegant way to do that?
Thanks for any help, much appreciated!