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](https://img.shields.io/crates/v/wav2json.svg)](https://crates.io/crates/wav2json)
[![Documentation](https://docs.rs/wav2json/badge.svg)][dox]
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

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

[dox]: https://docs.rs/wav2json

## Usage

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

```toml
[dependencies]
wav2json = "0.2.0"
```

Next, add this to your crate:

```rust
use wav2json::Wav;

fn main() {
    // ...
}
```

## Examples

Generate a json waveform data file:

```rust
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](https://github.com/caojianyu/wav2json/blob/main/examples/example.png)

## License

wav2json is provided under the MIT license. See [LICENSE](LICENSE).