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.
Sourcepub fn par_compute(&self, data: Option<&[f32]>) -> Spectrogram
pub fn par_compute(&self, data: Option<&[f32]>) -> Spectrogram
Do the discrete fourier transform to create the spectrogram.
This function will use rayon to parallelize the FFT computation. It may create more FFT plans than there are threads, but will reuse them if called multiple times.
§Arguments
-
self-selfis immutable so that the FFT plans can be shared between threads. Since the FFT plans are not thread safe, they are wrapped in a Mutex. -
data- The time domain data to compute the spectrogram from.datais not preprocessed other than windowing and casting to complex.
Auto Trait Implementations§
impl Freeze for SpecCompute
impl !RefUnwindSafe for SpecCompute
impl Send for SpecCompute
impl Sync for SpecCompute
impl Unpin for SpecCompute
impl !UnwindSafe for SpecCompute
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more