-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from phip1611/dev
dev branch for v0.3.0 Release
- Loading branch information
Showing
10 changed files
with
682 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Changelog | ||
|
||
## v0.3.0 | ||
- `FrequencySpectrum::min()` and `FrequencySpectrum::max()` | ||
now return tuples/pairs (issue #6) | ||
- `FrequencySpectrum` now has convenient methods to get | ||
the value of a desired frequency from the underlying vector | ||
of FFT results (issue #8) | ||
- `FrequencySpectrum` now has a field + getter for `frequency_resolution` | ||
(issue #5) | ||
|
||
For all issues see: https://github.com/phip1611/spectrum-analyzer/milestone/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ description = """ | |
A simple and fast `no_std` library to get the frequency spectrum of a digital signal (e.g. audio) using FFT. | ||
It follows the KISS principle and consists of simple building blocks/optional features. | ||
""" | ||
version = "0.2.2" | ||
version = "0.3.0" | ||
authors = ["Philipp Schuster <[email protected]>"] | ||
edition = "2018" | ||
keywords = ["fft", "spectrum", "frequencies", "audio", "dsp"] | ||
|
@@ -18,6 +18,7 @@ documentation = "https://docs.rs/spectrum-analyzer" | |
|
||
[dependencies] | ||
rustfft = "5.0.1" | ||
float-cmp = "0.8.0" # approx. compare floats | ||
|
||
[dev-dependencies] | ||
minimp3 = "0.5.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2021 Philipp Schuster | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
//! This module contains convenient public transform functions that you can use | ||
//! as parameters in [`crate::samples_fft_to_spectrum`]. | ||
/// Practical implementations for [`crate::SimpleSpectrumScalingFunction`]. | ||
pub mod basic { | ||
/// 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 | ||
/// | ||
/// ## Usage | ||
/// ```rust | ||
///use spectrum_analyzer::{samples_fft_to_spectrum, scaling, FrequencyLimit}; | ||
///let window = [0.0, 0.1, 0.2, 0.3]; // add real data here | ||
///let spectrum = samples_fft_to_spectrum( | ||
/// &window, | ||
/// 44100, | ||
/// FrequencyLimit::All, | ||
/// Some(&scaling::basic::scale_20_times_log10), | ||
/// None, | ||
/// ); | ||
/// ``` | ||
pub fn scale_20_times_log10(frequency_magnitude: f32) -> f32 { | ||
20.0 * frequency_magnitude.log10() | ||
} | ||
} | ||
|
||
/// Practical implementations for [`crate::spectrum::ComplexSpectrumScalingFunction`]. | ||
pub mod complex { | ||
use alloc::boxed::Box; | ||
use crate::ComplexSpectrumScalingFunction; | ||
|
||
/// Returns a function factory that generates a function that scales | ||
/// each frequency value/amplitude in the spectrum to interval `[0.0; 1.0]`. | ||
pub fn scale_to_zero_to_one() -> ComplexSpectrumScalingFunction { | ||
Box::new( | ||
move |_min: f32, max: f32, _average: f32, _median: f32| { | ||
Box::new( | ||
move |x| x / max | ||
) | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.