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)

https://webaudio.github.io/web-audio-api/#blackman-window

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])

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V