5 unstable releases
0.3.1 | Jun 30, 2024 |
---|---|
0.3.0 | Jun 24, 2024 |
0.2.0 | Jun 23, 2024 |
0.1.1 | Jun 22, 2024 |
0.1.0 | Jun 22, 2024 |
#378 in Audio
222 downloads per month
14KB
109 lines
Frequency detector
use freq_det::FreqDetector;
let detector = FreqDetector::new(44100, 4096).unwrap();
let freq: f32 = detector.detect(&samples).unwrap();
It is that easy!
Consult with from_mic.rs to see how microphone sound can be analyzed.
Contributions
PRs are welcome!
lib.rs
:
Frequency detection made easy
use freq_det::FreqDetector;
let sample_count = 4096;
let sinusoid_440hz = (0..sample_count)
.map(|i| {
use std::f32::consts::TAU;
(i as f32 / 44100.0 * 440.0 * TAU).sin()
// noise
+ 0.9 * (i as f32 / 44100.0 * 100.0 * TAU).sin()
+ 0.9 * (i as f32 / 44100.0 * 120.0 * TAU).sin()
})
.collect::<Vec<_>>();
let freq_detector = FreqDetector::new(44100, sample_count).unwrap();
assert_eq!(freq_detector.detect(&sinusoid_440hz).unwrap().round(), 440.0);
Dependencies
~3.5MB
~73K SLoC