Closed netlcod closed 1 year ago
In the line bqfilter->apply(batch); filtering gives wrong result. But if you replace it with bqfilter->apply(batch.data(), samples+1), the result becomes adequate. Result with samples+1:
What i do wring? Or it is library bug?
It seems to me that the library is the problem. When get_element gets a invalid index, it returns 0. So for the last sample it returns 0 instead of a valid value.
In the file kfr/base/expression.cpp at line 726
begin_pass(in, inshape.adapt(start), inshape.adapt(stop));
the array size is reduced. If you replace it to the line
begin_pass(in, start, stop);
the filters work normally.
So I have a question, I need to replace
begin_pass(in, inshape.adapt(start), inshape.adapt(stop));
to the line
begin_pass(in, start, stop);
or i need replace in file shape.hpp in line 283
return other.template trim<dims>()->min(**this - 1);
to the
return other.template trim<dims>()->min(**this);
@dancazarin ?
@netlcod
Thank you for reporting this issue. The adapt
function is required here for multidimensional arrays (tensors), so it isn't an option to remove it. But the adapt function assumes a valid index passed to it which isn't a case for the stop
index (past-the-end index). This also affected all expressions that relied on start and stop arguments in their begin_pass and end_pass functions.
I've pushed a fix, could you try to pull dev
branch and rerun your tests?
@dancazarin yes, it works, thanks!
I am trying to apply a high-pass filter as shown in the code. The problem occurs when the signal has DC offset. The last filtered sample is an outlier.