Struct spectrum_analyzer::FrequencySpectrum[][src]

pub struct FrequencySpectrum { /* fields omitted */ }

Convenient wrapper around the processed FFT result which describes each frequency and its value/amplitude in the analyzed slice of samples. It only consists of the frequencies which were desired, e.g. specified via crate::limit::FrequencyLimit when crate::samples_fft_to_spectrum was called.

Implementations

impl FrequencySpectrum[src]

pub fn new(data: Vec<(Frequency, FrequencyValue)>) -> Self[src]

Creates a new object. Calculates several metrics on top of the passed vector.

pub fn apply_total_scaling_fn(
    &self,
    total_scaling_fn: SpectrumTotalScaleFunctionFactory
)
[src]

Applies the function generated by total_scaling_fn to each element and updates min, max, etc. afterwards accordingly.

Parameters

pub fn average(&self) -> FrequencyValue[src]

Getter for lazily evaluated average.

pub fn median(&self) -> FrequencyValue[src]

Getter for lazily evaluated median.

pub fn max(&self) -> FrequencyValue[src]

Getter for lazily evaluated max.

pub fn min(&self) -> FrequencyValue[src]

Getter for lazily evaluated min.

pub fn range(&self) -> FrequencyValue[src]

[max()] - [min()]

pub fn data(&self) -> Ref<'_, Vec<(Frequency, FrequencyValue)>>[src]

Getter for data.

pub fn to_map(
    &self,
    scale_fn: Option<&dyn Fn(f32) -> u32>
) -> BTreeMap<u32, f32>
[src]

Returns a BTreeMap. The key is of type u32. (f32 is not Ord, hence we can’t use it as key.) You can optionally specify a scale function, e.g. multiply all frequencies with 1000 for better accuracy when represented as unsigned integer.

Parameters

  • scale_fn optional scale function, e.g. multiply all frequencies with 1000 for better accuracy when represented as unsigned integer.

Return

New BTreeMap from frequency to frequency value.

Trait Implementations

impl Debug for FrequencySpectrum[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.