Struct 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

Source

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.

Source

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.

Source

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.
Source

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 - self is 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. data is not preprocessed other than windowing and casting to complex.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.