Yin: Frequency Estimation For Rust
Yin provides a function for estimating the fundamental frequency of a signal, based on the following article:
[1] De Cheveigné, A., & Kawahara, H. (2002). YIN, a fundamental frequency estimator for speech and music. The Journal of the Acoustical Society of America, 111(4), 1917-1930.
Installation
Add the following to your Cargo.toml
yin = "0.1.0"
Usage
// Configure params for our estimator, see docs for details
let estimator = init;
let mut example = vec!;
let mut prev_value = -1.0;
// Periodic over every 4 values of i, giving us a frequency of: 80 / 4 == 20
for i in 0..80
let freq = estimator.estimate_freq;
assert_eq!;
Benchmarks
At the time of writing I have not taken too much time to optimize this implementation, and will be looking at improving the speed of this as needed. Current benchmark timings listed below:
44100hz sample rate, 100hz frequency, 160hz search range: [ 2.4157 ms 2.4244 ms 2.4330 ms ]
Benchmarks are done using criterion, and can be run by cloning the repository and using cargo bench