| Crates.io | gwav |
| lib.rs | gwav |
| version | 0.1.0 |
| created_at | 2025-11-30 16:53:30.557755+00 |
| updated_at | 2025-11-30 16:53:30.557755+00 |
| description | Rudimentary WAV parsing library |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1958481 |
| size | 12,206 |
Rudimentary WAV parsing library
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!");
}