Enum wavv::Samples [−][src]
Enum to hold samples for different bit depth
Variants
BitDepth8(Vec<u8>)
8 bit audio
BitDepth16(Vec<i16>)
16 bit audio
BitDepth24(Vec<i32>)
24 bit audio
Implementations
impl Samples
[src]
pub fn from_bytes(header: &Header, bytes: &[u8]) -> Result<Self, Error>
[src]
Create new Samples
instance from a slice of bytes
this requires a Header
instance to be passed to determine
the sample size and channel data etc.
Examples
use wavv::{Header, Samples}; fn main() { let bytes = [ 0x01, 0x00, // audio format 0x01, 0x00, // num channels 0x44, 0xac, 0x00, 0x00, // sample rate 0x88, 0x58, 0x01, 0x00, // byte rate 0x04, 0x00, // block align 0x18, 0x00, // bits per sample ]; let header = Header::from_bytes(&bytes).unwrap(); assert_eq!(header.num_channels, 1); assert_eq!(header.bit_depth, 24); assert_eq!(header.sample_rate, 44_100); let bytes = [ 0x00, 0x00, 0x00, // sample 1 0x00, 0x24, 0x17, // sample 2 0x1e, 0xf3, 0x3c, // sample 3 0x13, 0x3c, 0x14, // sample 4 ]; let samples = Samples::from_bytes(&header, &bytes).unwrap(); assert_eq!( samples, Samples::BitDepth24(vec![ 0x00000000, // sample 1 0x17240000, // sample 2 0x3cf31e00, // sample 3 0x143c1300, // sample 4 ]) ) }
Trait Implementations
impl Debug for Samples
[src]
impl PartialEq<Samples> for Samples
[src]
impl StructuralPartialEq for Samples
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,