Skip to main content

FftSpectrumAnalyzer

Struct FftSpectrumAnalyzer 

Source
pub struct FftSpectrumAnalyzer<T: Transcendental> { /* private fields */ }
Expand description

FFT-based spectrum analyzer.

Transforms real input blocks into magnitude spectra via the real FFT. The window function (Hann by default) is applied before the transform.

Implementations§

Source§

impl<T: Transcendental> FftSpectrumAnalyzer<T>

Source

pub fn new(fft_size: usize) -> Self

Create a new spectrum analyzer with FFT size fft_size and Hann window.

§Panics

Panics if fft_size is not a power of two.

Source

pub fn fft_size(&self) -> usize

Returns the FFT size.

Source

pub fn spectrum(&self) -> &[f32]

Returns the magnitude spectrum (in f32).

Source

pub fn amplitude_at(&self, freq: f32, sample_rate: f32) -> f32

Compute the amplitude at a specific frequency.

Trait Implementations§

Source§

impl<T: Transcendental> Algorithm<T> for FftSpectrumAnalyzer<T>

Source§

fn process( &mut self, input: Option<&[T]>, output: &mut [T], ) -> ProcessResult<()>

Process one block of signal. Read more
Source§

fn reset(&mut self)

Reset the algorithm to its initial state. Read more
Source§

fn metadata(&self) -> AlgorithmMetadata

Descriptive metadata (defaults to empty).
Source§

fn apply_command(&mut self, _value: T)

Receive a real-time command value from the control path. Read more
Source§

fn init(&mut self, _sample_rate: f32)

Initialise the algorithm with a sample rate. Read more
Source§

impl<T: Transcendental> Analyzer<T> for FftSpectrumAnalyzer<T>

Source§

type Output = Vec<f32>

Analysis result type
Source§

fn result(&self) -> &Self::Output

Get analysis result
Source§

fn reset_analysis(&mut self)

Reset accumulated data
Source§

impl<T: Transcendental> SpectrumAnalyzer<T> for FftSpectrumAnalyzer<T>

Source§

fn fft_size(&self) -> usize

FFT size
Source§

fn spectrum(&self) -> &[f32]

Get spectrum
Source§

fn amplitude_at(&self, freq: f32, sample_rate: f32) -> f32

Get amplitude at specific frequency

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

Source§

fn vzip(self) -> V