I am trying to use the FIR filter with ProcessBlock.
I can make it work with Process but not ProcessBlock. When I say it does not work I mean, there is no audio output.
Example that works using Process (with static FIR<FIRFILTER_USER_MEMORY> flt;):
void AudioCallback(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out,
size_t size)
{
for(size_t i = 0; i < size; ++i)
{
float input=in[0][i];
float output = flt.Process(input);
out[0][i] = output; /*< Left */
}
}
When I do that it works. The seed takes the audio signal input, apply the FIR filter and ouput the expected signal on its audio output.
Example that does not work:
void AudioCallback(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out,
size_t size)
{
float input[size]={};
float output[size]={};
for(size_t i = 0; i < size; ++i)
{
input[i]=in[0][i];
}
size_t block_size = size;
float* pSrc=&input[0];
float* pDst=&output[0];
flt.ProcessBlock(pSrc, pDst, block_size);
for(size_t i = 0; i < size; ++i)
{
out[0][i] = output[i];
}
}
Since ProcessBlock expects float* and in and out are const float* const* and float**, I am trying to use a for loop to transfer the values of into floats and pass the pointers into ProcessBlockā¦
What you should do is actually post complete program code, since itās not clear if you even allocate and assign the buffer to be used with user memory implementation in that template. And maybe try running debug version to see if anything interesting gets detected by asserts used int FIR filter code.
I canāt test it myself right now, but you could probably replace your whole audio callback with something like flt.ProcessBlock(const_cast<float*>(in[0]), out[0], size) or something similar. Not sure if that would help with the actual issue.
The length should be determined as follows length >= max_filter_size + max_processing_block - 1
And you have just static float flt_state[flt_size + 1];, so it should be flt_size + 47 (or better yet, define a constant to be used there and when initializing codec). It likely works with a single element processing because effectively it runs code as if max_processing_block = 1 and length requirement is satisfied.