AnalysisEngine

Struct AnalysisEngine 

Source
pub struct AnalysisEngine {
    fft_size: usize,
    smoothing_constant: f64,
    min_decibels: f64,
    max_decibels: f64,
    data: Box<[f32; 32768]>,
    current_block: usize,
    fft_computed: bool,
    blackman_windows: Vec<f32>,
    smoothed_fft_data: Vec<f32>,
    computed_fft_data: Vec<f32>,
    windowed: Vec<f32>,
}
Expand description

The actual analysis is done on the DOM side. We provide the actual base functionality in this struct, so the DOM just has to do basic shimming

Fields§

§fft_size: usize

The number of past sample-frames to consider in the FFT

§smoothing_constant: f64§min_decibels: f64§max_decibels: f64§data: Box<[f32; 32768]>

This is a ring buffer containing the last MAX_FFT_SIZE sample-frames

§current_block: usize

The index of the current block

§fft_computed: bool

Have we computed the FFT already?

§blackman_windows: Vec<f32>

Cached blackman window data

§smoothed_fft_data: Vec<f32>

The smoothed FFT data (in frequency domain)

§computed_fft_data: Vec<f32>

The computed FFT data, in decibels

§windowed: Vec<f32>

The windowed time domain data Used during FFT computation

Implementations§

Source§

impl AnalysisEngine

Source

pub fn new( fft_size: usize, smoothing_constant: f64, min_decibels: f64, max_decibels: f64, ) -> Self

Source

pub fn set_fft_size(&mut self, fft_size: usize)

Source

pub fn get_fft_size(&self) -> usize

Source

pub fn set_smoothing_constant(&mut self, smoothing_constant: f64)

Source

pub fn get_smoothing_constant(&self) -> f64

Source

pub fn set_min_decibels(&mut self, min_decibels: f64)

Source

pub fn get_min_decibels(&self) -> f64

Source

pub fn set_max_decibels(&mut self, max_decibels: f64)

Source

pub fn get_max_decibels(&self) -> f64

Source

fn advance(&mut self)

Source

fn curent_block_mut(&mut self) -> &mut [f32]

Get the data of the current block

Source

fn convert_index(&self, index: usize) -> usize

Given an index from 0 to fft_size, convert it into an index into the backing array

Source

fn advance_index(&self, index: &mut usize)

Given an index into the backing array, increment it

Source

pub fn push(&mut self, block: Block)

Source

fn compute_blackman_windows(&mut self)

Source

fn apply_blackman_window(&mut self)

Source

fn compute_fft(&mut self)

Source

pub fn fill_time_domain_data(&self, dest: &mut [f32])

Source

pub fn fill_byte_time_domain_data(&self, dest: &mut [u8])

Source

pub fn fill_frequency_data(&mut self, dest: &mut [f32])

Source

pub fn fill_byte_frequency_data(&mut self, dest: &mut [u8])

Trait Implementations§

Source§

impl MallocSizeOf for AnalysisEngine

Source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

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> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T