RustAudio / dasp

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

dasp::Frame: Generic impl for all `[impl Sample;const N: usize]` #180

Closed rawler closed 10 months ago

rawler commented 1 year ago

Replace the hard-coded macro implementing Frame for [impl Sample;0-32], with a generic impl based on const-generics.

I discovered the need for this, when trying to simplify some macro- -implementations in the ebur128 crate with const-generics.

We cannot remove the need for NumChannels, since (see reference 1) "Associated Const Equality" is not yet stable. We can however adapt the NumChannels strategy from N1..N32 to a NChannels<N>-generic type.

Some opportunities like removing unsafe from zip_map, remain out of reach due to pending stabilization of the standard library.

1: https://github.com/rust-lang/rust/issues/92827

rawler commented 1 year ago

I chose to leave out the custom impl:s of scale_amp and add_amp. I believe the trait-provided generic impl:s should be optimized by the compiler into something equivalent. These can easily be added back, if desired.

rawler commented 1 year ago

Would solve issue #179.

thomascastleman commented 10 months ago

I'd be interested in seeing this functionality get added - is there a particular reason this never got merged?