gwav

Crates.iogwav
lib.rsgwav
version0.1.0
created_at2025-11-30 16:53:30.557755+00
updated_at2025-11-30 16:53:30.557755+00
descriptionRudimentary WAV parsing library
homepage
repository
max_upload_size
id1958481
size12,206
(maki-rs)

documentation

README

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!");
}
Commit count: 0

cargo fmt