Struct spectrum_analyzer::FrequencySpectrum [−][src]
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]
&self,
total_scaling_fn: SpectrumTotalScaleFunctionFactory
)
Applies the function generated by total_scaling_fn
to each element and updates
min
, max
, etc. afterwards accordingly.
Parameters
total_scaling_fn
Seecrate::spectrum::SpectrumTotalScaleFunctionFactory
.
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]
&self,
scale_fn: Option<&dyn Fn(f32) -> u32>
) -> BTreeMap<u32, f32>
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
Auto Trait Implementations
impl !RefUnwindSafe for FrequencySpectrum
impl Send for FrequencySpectrum
impl !Sync for FrequencySpectrum
impl Unpin for FrequencySpectrum
impl UnwindSafe for FrequencySpectrum
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,