Closed shimshir closed 9 years ago
The question is whether the function retains state.
State of what exactly, the state of the taps?! If so then there are (nh + 1) * nx different states, what should be done with them? I would be happy to implement additional behavior I just need a more detailed explanation of the requirements.
@shimshir The idea is to internally retain the last buffer used in the calculations, in this case nh*df
last elements from x
. However, I think a better option would be to initialize the delay line instead of saving the last state. Keeping an internal state would make it very hard for a user to filter two different buffers sequentially.
I've been thinking that maybe a better solution would be to only return values with a full delay line, ignoring the initial transient. The output of the filter function would be nx-nh+1
(instead of nx
) and the initial state would be the first nh
elements of x
. Since the length of r
is smaller than the length of x
, in-place filtering is possible (although there would be nh-1
"garbage values" at the end of the output array). Still, I think it would be a good trade off.
@aolofsson What do you think?
@lchamon Having the option to initialize the delay line would be a good solution, but wouldn't the function signature have to be changed/extended by the initialization vector. As far as I understand it you want something similar to the Python lfilter
function of the scipy package, particularly the zi
vector, am I right?
The idea is that the "initialization" would already be contained in x
: the first nh
elements of x
. In your implementation, it would be equivalent to removing the first loop and adjusting the indexing of r
.
And you are right: the idea is that the function keeps zi
/zf
from scipy internally (I believe it's similar to the *dbuf
from the TI DSP library that @aolofsson referenced in #158).
I didn't understand what is mean by "This function retains the address of the delay filter memory containing the previous delayed values to allow consecutive processing of blocks."