Struct servo_media_audio::analyser_node::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
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)
https://webaudio.github.io/web-audio-api/#blackman-window
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])
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