| Crates.io | wav_io |
| lib.rs | wav_io |
| version | 0.1.15 |
| created_at | 2022-03-21 07:56:50.485587+00 |
| updated_at | 2024-12-07 06:40:34.315221+00 |
| description | Wav file reader and writer |
| homepage | |
| repository | https://github.com/kujirahand/wav_io |
| max_upload_size | |
| id | 553917 |
| size | 73,597 |
This is a crate for reading and writing wav file.
Add wav_io to your project:
cargo add wav_io
use std::f32::consts::PI;
fn main() {
// make sine wave
let head = wav_io::new_mono_header();
let mut samples: Vec<f32> = vec![];
for t in 0..head.sample_rate {
let v = ((t as f32 / head.sample_rate as f32) * 440.0 * 2.0 * PI).sin() * 0.6;
samples.push(v);
}
// write to file
let mut file_out = std::fs::File::create("./sine.wav").unwrap();
wav_io::write_to_file(&mut file_out, &head, &samples).unwrap();
}