dasp
dasp copied to clipboard
Sample should have super traits
Few supertrait would be really usefull for Sample in order to use it as generic parameter:
- Default: would ease container resize and have an initial zero value when using Sample as type bound for a generic parameter, such as
buffer.resize(1024, S::default()); - Add: simplify addition between samples;
Hi @bkfox, thanks for the issue!
You can achieve your default case by using the Sample::equilibrium() method. This also provides slightly more predictable behaviour if you happen to be working with unsigned data for some reason where the signal equilibrium is not equal to the default value.
As an alternative to Add, you should be able to use the Sample::add_amp method.
Also, keep in mind that you can define your own sample trait for your project that better suits your needs if Sample doesn't tick all your boxes, e.g.
trait MySample: Sample + hound::Sample + Add + Default {}
impl<T> MySample for T where T: Sample + hound::Sample + Add + Default {}
I hope this helps!