wav2json 0.2.0

A library that decodes wav audio files into json waveform data
Documentation

wav2json

A library that decodes wav audio files into json waveform data

Crates.io Documentation MIT licensed

More information about this crate can be found in the crate documentation.

Usage

To use wav2json, first add this to your Cargo.toml:

[dependencies]
wav2json = "0.2.0"

Next, add this to your crate:

use wav2json::Wav;

fn main() {
    // ...
}

Examples

Generate a json waveform data file:

use std::{error::Error, fs::File, time::Instant};
use wav2json::Wav;

fn main() -> Result<(), Box<dyn Error>> {
    let start = Instant::now();

    // Support for local and network files.
    // let mut wav = Wav::new("http://[host]/sample-15s.wav")?.set_json_width(1920);
    let mut wav = Wav::new("examples/sample-15s.wav")?.set_json_width(1920);
    let result_data = wav.decode()?;

    println!("duration: {}", start.elapsed().as_millis());

    // Generate json data files that can be rendered.
    let json_file = File::create("examples/data.json")?;
    serde_json::to_writer(json_file, &result_data)?;

    Ok(())
}

Copy the resulting json data into the index.html file, and then open the web page to see the effect as shown in the following image

Waveform picture

License

wav2json is provided under the MIT license. See LICENSE.