# Do filters work on a "per sample basis"?

I'm confused because of filter length, whether (such) filters can be used to filter audio on a "per sample basis"?

By per sample basis I mean that I would like to filter audio one sample at a time, but vary the filter parameters even one sample at a time.

What then confuses me is, can the filter have any effect if only one sample is input to it? Or whether the filter needs a longer sample (e.g. that matches the filter length)?

Since the filter type seems crucial, I'm specifically interested in the Parks-Mccellan FIR and the context is dynamic equalization (in which it seems like the parameters such as gain would need to be varied on a close to per sample basis). I.e. I'm interested in whether the PM algorithm can be utilized for dynamic equalization in such way that one recomputes the PM between some samples and then filters those samples, i.e. in a block-like fashion.

• Do you want a linear filter, or what kind of filter do you have in mind? (see the discussion under my answer) Jul 12, 2016 at 22:21
• Answer depends on the kind of filter. What kind of filter is confusing you? An LTI filter that affects frequency (has a frequency response) requires context around each sample, both on the input and the output, for the meaning of "frequency". Jul 12, 2016 at 22:52
• @MarcusMüller I have made my question more accurate. Jul 13, 2016 at 8:23
• @mavavilj Ok, so my answer applies here. Jul 13, 2016 at 8:47
• Yes filters work on a "per sample" basis in that the output is updated once per sample based on current input, with the "state" of the filter being all prior inputs up to the memory depth (length) of the filter. So of course you could vary the parameters (how you weight each prior sample) on a sample by sample basis. With regards to equalization, see dsp.stackexchange.com/questions/31318/… Jul 13, 2016 at 12:35

Obviously, filters need more than one sample of input – I mean, a single sample is a single number, and how would a single number have something like a frequency? Filtering is something you apply to a digital signal, and signal is defined by being a changing entity – i.e. different samples.

Hence, digital filters always need sequences of samples. The typical (non-rate-changing) filter works in a matter that each time you "push in" a new sample, an output sample "pushes out" of the filter.

You should definitely brush up your knowledge on what a digital filter is, and especially how FIR filters work. The important point here is the understanding that application of a filter to a signal is a discrete convolution.

You're absolutely free to change the system with which you convolve any time – but you'd break the time-invariance that makes LTI (linear, time invariant) systems such as FIRs so "easy" to handle.