pub struct SignalProcessor { /* private fields */ }Expand description
Signal processor for pre-processing sensor data
Implementations§
Source§impl SignalProcessor
impl SignalProcessor
Sourcepub fn with_sample_rate(self, rate: f32) -> Self
pub fn with_sample_rate(self, rate: f32) -> Self
Set the sample rate
Sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
Get the buffer size
Sourcepub fn sample_rate(&self) -> f32
pub fn sample_rate(&self) -> f32
Get the sample rate
Sourcepub fn ifft(&mut self, spectrum: &mut [Complex<f32>]) -> IoResult<Array1<f32>>
pub fn ifft(&mut self, spectrum: &mut [Complex<f32>]) -> IoResult<Array1<f32>>
Apply inverse FFT
Sourcepub fn fft_pow2(&mut self, signal: &Array1<f32>) -> IoResult<Vec<Complex<f32>>>
pub fn fft_pow2(&mut self, signal: &Array1<f32>) -> IoResult<Vec<Complex<f32>>>
Optimized FFT for power-of-2 sizes
Uses specialized FFT planning for power-of-2 sizes which can be more efficient. Falls back to standard FFT for non-power-of-2 sizes.
Sourcepub fn ifft_pow2(
&mut self,
spectrum: &mut [Complex<f32>],
) -> IoResult<Array1<f32>>
pub fn ifft_pow2( &mut self, spectrum: &mut [Complex<f32>], ) -> IoResult<Array1<f32>>
Optimized inverse FFT for power-of-2 sizes
Sourcepub fn power_spectrum_pow2(
&mut self,
signal: &Array1<f32>,
) -> IoResult<Vec<f32>>
pub fn power_spectrum_pow2( &mut self, signal: &Array1<f32>, ) -> IoResult<Vec<f32>>
Compute power spectrum efficiently for power-of-2 sizes
Returns the magnitude squared of the FFT.
Sourcepub fn zero_pad_pow2(signal: &Array1<f32>) -> Array1<f32>
pub fn zero_pad_pow2(signal: &Array1<f32>) -> Array1<f32>
Zero-pad signal to next power of 2 for optimal FFT performance
Sourcepub fn apply_filter(
&mut self,
signal: &Array1<f32>,
filter: Filter,
) -> IoResult<Array1<f32>>
pub fn apply_filter( &mut self, signal: &Array1<f32>, filter: Filter, ) -> IoResult<Array1<f32>>
Apply a filter to the signal
Sourcepub fn power_spectrum(&mut self, signal: &Array1<f32>) -> IoResult<Array1<f32>>
pub fn power_spectrum(&mut self, signal: &Array1<f32>) -> IoResult<Array1<f32>>
Compute power spectrum (magnitude squared)
Sourcepub fn magnitude_spectrum(
&mut self,
signal: &Array1<f32>,
) -> IoResult<Array1<f32>>
pub fn magnitude_spectrum( &mut self, signal: &Array1<f32>, ) -> IoResult<Array1<f32>>
Compute magnitude spectrum
Sourcepub fn phase_spectrum(&mut self, signal: &Array1<f32>) -> IoResult<Array1<f32>>
pub fn phase_spectrum(&mut self, signal: &Array1<f32>) -> IoResult<Array1<f32>>
Compute phase spectrum
Sourcepub fn zero_crossings(signal: &Array1<f32>) -> usize
pub fn zero_crossings(signal: &Array1<f32>) -> usize
Compute zero-crossings count
Sourcepub fn peak_to_peak(signal: &Array1<f32>) -> f32
pub fn peak_to_peak(signal: &Array1<f32>) -> f32
Compute peak-to-peak amplitude
Sourcepub fn envelope(&mut self, signal: &Array1<f32>) -> IoResult<Array1<f32>>
pub fn envelope(&mut self, signal: &Array1<f32>) -> IoResult<Array1<f32>>
Apply envelope detection via Hilbert transform approximation
Sourcepub fn spectrogram(
&mut self,
signal: &Array1<f32>,
n_fft: usize,
hop_length: usize,
window: WindowType,
) -> IoResult<Spectrogram>
pub fn spectrogram( &mut self, signal: &Array1<f32>, n_fft: usize, hop_length: usize, window: WindowType, ) -> IoResult<Spectrogram>
Compute spectrogram (Short-Time Fourier Transform)
Returns a 2D array where rows are time frames and columns are frequency bins. Only the positive frequency bins (0 to n_fft/2) are returned.
Sourcepub fn create_window(window_type: WindowType, size: usize) -> Vec<f32>
pub fn create_window(window_type: WindowType, size: usize) -> Vec<f32>
Create a window function
Sourcepub fn apply_window_to_frame(frame: &[f32], window_type: WindowType) -> Vec<f32>
pub fn apply_window_to_frame(frame: &[f32], window_type: WindowType) -> Vec<f32>
Apply window function to a frame (convenience method)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SignalProcessor
impl !RefUnwindSafe for SignalProcessor
impl Send for SignalProcessor
impl Sync for SignalProcessor
impl Unpin for SignalProcessor
impl !UnwindSafe for SignalProcessor
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
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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