Module spectrum_analyzer::scaling [−][src]
Expand description
This module contains convenient public transform functions that you can use
as parameters in crate::samples_fft_to_spectrum
for scaling the
frequency value (the FFT result). They act as “idea/inspiration”. Feel free
to either compose them or create your own derivation from them.
Structs
Helper struct for SpectrumScalingFunction
, that gets passed into the
function together with the actual value. This structure can be used to scale
each value. All properties reference the current data of a
crate::spectrum::FrequencySpectrum
.
Functions
Combines several scaling functions into a new single one.
Divides each value by N. Several resources recommend that the FFT result should be divided by the length of samples, so that values of different samples lengths are comparable.
Calculates the base 10 logarithm of each frequency magnitude and multiplies it with 20. This scaling is quite common, you can find more information for example here: https://www.sjsu.edu/people/burford.furman/docs/me120/FFT_tutorial_NI.pdf
Scales each frequency value/amplitude in the spectrum to interval [0.0; 1.0]
.
Function is of type SpectrumScalingFunction
. Expects that SpectrumDataStats::min
is
not negative.
Type Definitions
Describes the type for a function that scales/normalizes the data inside crate::FrequencySpectrum
.
The scaling only affects the value/amplitude of the frequency, but not the frequency itself.
It gets applied to every single element.
///
A scaling function can be used for example to subtract the minimum (min
) from each value.
It is optional to use the second parameter SpectrumDataStats
.
and the type works with static functions as well as dynamically created closures.