gwav 0.1.0

Rudimentary WAV parsing library
Documentation
  • Coverage
  • 0%
    0 out of 28 items documented0 out of 8 items with examples
  • Size
  • Source code size: 12.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 338.3 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • maki-rs

gwav

Rudimentary WAV parsing library

Basic usage


fn main() {
    let wav = gwav::io::Wav::read("audio.wav").expect("Failed to load audio.wav");
    println!(
        "{:?} has {} samples!",
        wav.path(),
        wav.samples.borrow().len()
    );

    //create wav with same properties as loaded wav
    let mut out_wav = gwav::io::Wav::new(wav.fmt_subchunk);
    
    //multiply every sample by 0.1
    let new_samples = wav
        .samples
        .borrow()
        .clone()
        .into_iter()
        .map(|x| //for each sample
            x.into_iter() 
            .map(|y| y * 0.1) //for each sample in channel
            .collect::<Vec<f64>>()
        )
        .collect::<Vec<Vec<f64>>>();

    out_wav.add_samples(0, &new_samples);
    std::fs::write("audio_out.wav", out_wav.as_bytes().unwrap())
        .expect("Cannot write to audio_out.wav");
    println!("exported audio_out.wav!");
}