Expand description
An easy to use and fast no_std
library (with alloc
) to get the frequency
spectrum of a digital signal (e.g. audio) using FFT.
§Examples
§Scaling via dynamic closure
use spectrum_analyzer::{samples_fft_to_spectrum, FrequencyLimit};
// get data from audio source
let samples = vec![0.0, 1.1, 5.5, -5.5];
let res = samples_fft_to_spectrum(
&samples,
44100,
FrequencyLimit::All,
Some(&|val, info| val - info.min),
);
§Scaling via static function
use spectrum_analyzer::{samples_fft_to_spectrum, FrequencyLimit};
use spectrum_analyzer::scaling::divide_by_N_sqrt;
// get data from audio source
let samples = vec![0.0, 1.1, 5.5, -5.5];
let res = samples_fft_to_spectrum(
&samples,
44100,
FrequencyLimit::All,
// Recommended scaling/normalization by `rustfft`.
Some(÷_by_N_sqrt),
);
Modules§
- error
- Errors related to the spectrum analysis via FFT. Most probably, the errors will result in wrong input data, before the actual calculation has begun.
- scaling
- This module contains convenient public transform functions that you can use
as parameters in
samples_fft_to_spectrum
for scaling the frequency value (the FFT result). - windows
- Several window functions which you can apply before doing the FFT. For more information:
Structs§
- Frequency
Spectrum - Convenient wrapper around the processed FFT result which describes each frequency and its value/amplitude from the analyzed samples.
Enums§
- Frequency
Limit - Can be used to specify a desired frequency limit.
- Frequency
Limit Error - Possible errors when creating a
FrequencyLimit
-object.
Functions§
- samples_
fft_ to_ spectrum - Takes an array of samples (length must be a power of 2), e.g. 2048, applies an FFT (using the specified FFT implementation) on it and returns all frequencies with their volume/magnitude.
Type Aliases§
- Frequency
- A frequency in Hertz. A convenient wrapper type around
f32
. - Frequency
Value - The value of a
Frequency
in a frequency spectrum. Also called the magnitude.