Struct sonogram::SpecCompute
source · pub struct SpecCompute { /* private fields */ }
Expand description
This contains all the initialised data. This can then produce the spectrogram, and if necessary, save it to the filesystem as a PNG image.
This Spectrograph
is created by SpecOptionsBuilder
.
Example
let mut spectrograph = SpecOptionsBuilder::new(2048)
.load_data_from_file(&std::path::Path::new(wav_file))?
.build();
// Compute the spectrogram. Need export it using `to_png()` or simlar.
spectrograph.compute();
Implementations§
source§impl SpecCompute
impl SpecCompute
sourcepub fn new(
num_bins: usize,
step_size: usize,
data: Vec<f32>,
window_fn: WindowFn
) -> Self
pub fn new(
num_bins: usize,
step_size: usize,
data: Vec<f32>,
window_fn: WindowFn
) -> Self
Create a new Spectrograph from data.
You probably want to use [SpecOptionsBuilder] instead.
sourcepub fn set_data(&mut self, data: Vec<f32>)
pub fn set_data(&mut self, data: Vec<f32>)
Update the sample data with a new set. Note, none of the settings from the builder are applied, all the samples are used in their raw form.
sourcepub fn compute(&mut self) -> Spectrogram
pub fn compute(&mut self) -> Spectrogram
Do the discrete fourier transform to create the spectrogram.
Arguments
n_fft
- How many fourier transform frequency bins to use. Must be a power of 2.