Sonogram: Wave to Spectrogram converter - in Rust
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.
Running usin the CLI
Completing an in-memory conversion
// You'll need to fill `waveform` with data.
let waveform: = vec!;
// Build the model
let mut spectrograph = new
.load_data_from_memory
.build;
// Compute the spectrogram giving the number of bins and the window overlap.
spectrograph.compute;
// Save the spectrogram to PNG.
let png_file = new;
spectrograph.save_as_png?;
Using your own colour gradient
let mut gradient = new;
gradient.add_colour; // Black
gradient.add_colour; // Purple
gradient.add_colour; // Blue
gradient.add_colour; // Cyan
gradient.add_colour; // Green
spec_builder.set_gradient;
License
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.