RustAudio / dasp

The fundamentals for Digital Audio Signal Processing. Formerly `sample`.
Other
883 stars 64 forks source link

Add filtering support and subcrate #148

Open linclelinkpart5 opened 3 years ago

linclelinkpart5 commented 3 years ago

Closes #145

Adds a new subcrate dasp_filter, which includes Coefficients and Biquad types. This crate uses the same feature gating as the other crates in dasp.

In addition, similar to how envelope is a subfeature in dasp_signal, I also added filter as a subfeature. This involves adding feature flags for the dasp_signal subcrate, plus an extension trait (SignalFilter) and iterator type (FilteredSignal) in dasp_signal, both of which are feature-gated.

mitchmindtree commented 3 years ago

Once again, great stuff @linclelinkpart5 - thanks for the PR!

I wonder if we should allow for alternatives to the BiQuad filter to be used too? Then again, we might be better off waiting until this is requested, at which point we can maybe add a Filter trait or something along these lines. I'm happy to merge this as is in the meantime.

Before we merge, could you update the action in .github/workflow to add a step for auto-publishing the dasp_filter crate? It makes it a bit easier for contributors to get new versions published, as we just have to merge a PR that changes the version.

Edit: Also if you could update the CHANGELOG that would be very helpful.

linclelinkpart5 commented 3 years ago

@mitchmindtree Certainly! I'll go ahead and make the change to .github/workflow and update CHANGELOG. I'm assuming I can add the changes to the "Unreleased" section?

linclelinkpart5 commented 3 years ago

As for the general concept of filtering, I need to do a bit more research to see what other kinds of useful types of digital filters there are. As far as I was able to tell, using biquads was the magic ticket: they're flexible enough to do single pole (or what I guess would be called "uniquad", but I've never come across that term) filters, and any filters of higher orders can be represented as a series of biquad filters. In fact, it's recommended!

A feature that I'd love to tackle once this lands in master would be to allow nicer constructors for the Coefficients struct. For instance, a constructor that given the correct args, will produce the coefficients for a highpass/lowpass/shelf/etc filter. All of these types can be represented in the biquad form.

Adam-Gleave commented 3 years ago

Are there any updates on this? Looks good :eyes: