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.

  • $\begingroup$ Do you want a linear filter, or what kind of filter do you have in mind? (see the discussion under my answer) $\endgroup$ – Marcus Müller Jul 12 '16 at 22:21
  • $\begingroup$ 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". $\endgroup$ – hotpaw2 Jul 12 '16 at 22:52
  • $\begingroup$ @MarcusMüller I have made my question more accurate. $\endgroup$ – mavavilj Jul 13 '16 at 8:23
  • $\begingroup$ @mavavilj Ok, so my answer applies here. $\endgroup$ – Marcus Müller Jul 13 '16 at 8:47
  • $\begingroup$ 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/… $\endgroup$ – Dan Boschen Jul 13 '16 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.

EDIT: with your clarification:

Yes, any FIR will need "history" of samples. But also, yes, you can recompute the coefficients anytime, and "switch over" to a different FIR. However, you must make sure your new FIR's "delay"/memory elements were already filled with the previous input samples, otherwise you'll get inconsistencies.

  • $\begingroup$ The OP does not talk about linear filter. You can think of a one-sample threshold filter for instance. $\endgroup$ – Laurent Duval Jul 12 '16 at 21:14
  • $\begingroup$ @LaurentDuval ahhh true. I was just assuming OP wants to build something linear. Maybe she/he wants to comment on that? $\endgroup$ – Marcus Müller Jul 12 '16 at 22:21
  • $\begingroup$ How do I determine the amount of "history" I need? What about the switching procedure you talk about, how does it work in practice? $\endgroup$ – mavavilj Jul 13 '16 at 8:55
  • $\begingroup$ amount of history = FIR length - 1 $\endgroup$ – Marcus Müller Jul 13 '16 at 9:40
  • $\begingroup$ switching = use a different FIR ? I can't really explain it better than that. You stop using the first, but start using the second. $\endgroup$ – Marcus Müller Jul 13 '16 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.