Trait claxon::sample::Sample
[−]
[src]
pub trait Sample: Copy + Clone + Debug + Eq + Sum { type Wide: WideSample; fn from_wide(wide: Self::Wide) -> Option<Self>; fn zero() -> Self; }
A trait that allows decoding into integers of various widths.
A few observations are important here:
- In the FLAC format, samples are always signed.
- FLAC does not support more than 32 bits per sample.
Therefore, converting a sample to
i32
ori64
can never fail.
This trait should only be implemented for i8
, i16
and i32
.
Associated Types
type Wide: WideSample
The signed integer type that is wide enough to store differences.
The difference between two values of the sample type might not fit in a sample type any more, so a wider integer type is required. The wide type must be able to store at least twice a difference, so it must be two bits wider than the sample type itself.
Required Methods
fn from_wide(wide: Self::Wide) -> Option<Self>
Tries to narrow the sample, returning None
on overflow.
fn zero() -> Self
Returns 0.