#pitch #frequency #detection #sound

no-std pitch-detection

A collection of algorithms to determine the pitch of a sound sample

2 unstable releases

0.2.0 Nov 13, 2020
0.1.0 Mar 17, 2019

#110 in Audio

Download history 38/week @ 2020-10-01 33/week @ 2020-10-08 36/week @ 2020-10-15 5/week @ 2020-10-22 6/week @ 2020-10-29 13/week @ 2020-11-05 39/week @ 2020-11-12 9/week @ 2020-11-19 5/week @ 2020-11-26 6/week @ 2020-12-03 5/week @ 2020-12-10 48/week @ 2020-12-17 18/week @ 2020-12-24 15/week @ 2020-12-31 14/week @ 2021-01-07 19/week @ 2021-01-14

95 downloads per month

MIT/Apache

15KB
372 lines

pitch_detection

Usage

use pitch_detection::detector::mcleod::McLeodDetector;
use pitch_detection::detector::autocorrelation::AutocorrelationDetector;

const SAMPLE_RATE : usize = 44100;
const SIZE : usize = 1024;
const PADDING : usize = SIZE / 2;
const POWER_THRESHOLD : f64 = 5.0;
const CLARITY_THRESHOLD : f64 = 0.7;

// Signal coming from some source (microphone, generated, etc...)
let signal = vec![0.0; SIZE];
let mut detector = McLeodDetector::new(SIZE, PADDING);

let pitch = detector.get_pitch(&signal, SAMPLE_RATE, POWER_THRESHOLD, CLARITY_THRESHOLD).unwrap();

println!("Frequency: {}, Clarity: {}", pitch.frequency, pitch.clarity);

Live Demo

Demo Page Source

Dependencies

~1MB
~23K SLoC