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: usizeThe 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: usizeThe index of the current block
fft_computed: boolHave 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
impl AnalysisEngine
pub fn new( fft_size: usize, smoothing_constant: f64, min_decibels: f64, max_decibels: f64, ) -> Self
pub fn set_fft_size(&mut self, fft_size: usize)
pub fn get_fft_size(&self) -> usize
pub fn set_smoothing_constant(&mut self, smoothing_constant: f64)
pub fn get_smoothing_constant(&self) -> f64
pub fn set_min_decibels(&mut self, min_decibels: f64)
pub fn get_min_decibels(&self) -> f64
pub fn set_max_decibels(&mut self, max_decibels: f64)
pub fn get_max_decibels(&self) -> f64
fn advance(&mut self)
Sourcefn curent_block_mut(&mut self) -> &mut [f32]
fn curent_block_mut(&mut self) -> &mut [f32]
Get the data of the current block
Sourcefn convert_index(&self, index: usize) -> usize
fn convert_index(&self, index: usize) -> usize
Given an index from 0 to fft_size, convert it into an index into the backing array
Sourcefn advance_index(&self, index: &mut usize)
fn advance_index(&self, index: &mut usize)
Given an index into the backing array, increment it
pub fn push(&mut self, block: Block)
Sourcefn compute_blackman_windows(&mut self)
fn compute_blackman_windows(&mut self)
fn apply_blackman_window(&mut self)
fn compute_fft(&mut self)
pub fn fill_time_domain_data(&self, dest: &mut [f32])
pub fn fill_byte_time_domain_data(&self, dest: &mut [u8])
pub fn fill_frequency_data(&mut self, dest: &mut [f32])
pub fn fill_byte_frequency_data(&mut self, dest: &mut [u8])
Trait Implementations§
Source§impl MallocSizeOf for AnalysisEngine
impl MallocSizeOf for AnalysisEngine
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
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§
impl Freeze for AnalysisEngine
impl RefUnwindSafe for AnalysisEngine
impl Send for AnalysisEngine
impl Sync for AnalysisEngine
impl Unpin for AnalysisEngine
impl UnwindSafe for AnalysisEngine
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
Mutably borrows from an owned value. Read more
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>
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 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>
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert