Create a sonogram* from a wave form, or .wav file. This crate can take a .wav file and convert it into a spectrogram. The spectrogram can be saved as a PNG file. An example CLI progam is included that helps convert .wav files to .png spectrograms.
The code is intended to be used as a library that can be used to convert in-memory wave forms to a spectrograph.
Example output PNG:
*Note: sonogram, spectrograph, spectrogram, or power spectral density plot are common names of similar things.
sh
cargo run --release --bin sonogram -- --wav input.wav --png ouput.png
``Rust
// You'll need to fill
waveform` with data.
let waveform: Vec
// Build the model let mut spectrograph = SpecOptionsBuilder::new(512, 128) .loaddatafrom_memory(waveform) .build();
// Compute the spectrogram giving the number of bins and the window overlap. spectrograph.compute(2048, 0.8);
// Save the spectrogram to PNG. let pngfile = std::path::Path::new("path/to/file.png"); spectrograph.saveaspng(&pngfile, false)?;
```
The code in this repository is based on the C++ code developed by Christian Briones.
This source is released under the GPLv3 license. Read the LICENSE file for legal information.