Open mark-buer opened 8 years ago
@mark-buer sorry about the late reply! This sounds like it could be a useful addition. Just to clarify, by saturating do you mean clipping results of addition and multiplication to the minimum and maximum values for each Sample
type?
by saturating do you mean clipping results of addition and multiplication to the minimum and maximum values for each Sample type?
Yep.
Saturating (clipping) arithmetic seems like a natural choice in certain circumstances.
In a somewhat related topic... I also encountered problems with Rust's checked wrapping arithmetic as used by the current implementations for add_amp
etc. For example, Rust panicked when adding two large valued i16 samples together when the library was compiled for debug mode. Thus, I wonder if there is also a need for the library to provide unchecked wrapping arithmetic variants?
Should there be variants of sample::[Sample,Frame]::[add_amp,mul_amp] which use saturating arithmetic?