15 releases

0.1.15 Dec 7, 2024
0.1.14 Feb 16, 2024
0.1.12 Oct 3, 2023
0.1.11 Jul 30, 2023
0.1.4 Mar 29, 2022

#89 in Audio

Download history 149/week @ 2024-10-07 26/week @ 2024-10-14 56/week @ 2024-10-21 30/week @ 2024-10-28 9/week @ 2024-11-04 29/week @ 2024-11-11 58/week @ 2024-11-18 29/week @ 2024-11-25 169/week @ 2024-12-02 112/week @ 2024-12-09 37/week @ 2024-12-16 18/week @ 2024-12-23 11/week @ 2024-12-30 56/week @ 2025-01-06 106/week @ 2025-01-13 30/week @ 2025-01-20

204 downloads per month
Used in 3 crates

MIT license

71KB
1.5K SLoC

wav_io

This is a crate for reading and writing wav file.

Suported format:

  • PCM 8, 16, 24, 32 bits Int
  • PCM 32, 64 bits Float

Functions

Install

Add wav_io to your project:

cargo add wav_io

Samples

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

Example

Dependencies

~230–680KB
~16K SLoC