Enum wavv::Samples[][src]

pub enum Samples {

Enum to hold samples for different bit depth



8 bit audio


16 bit audio


24 bit audio


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.


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();

    	    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

impl Send for Samples

impl Sync for Samples

impl Unpin for Samples

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.