| Crates.io | qzn3t-pitch-detection |
| lib.rs | qzn3t-pitch-detection |
| version | 0.4.4 |
| created_at | 2025-11-06 02:59:01.862547+00 |
| updated_at | 2025-12-18 00:22:20.366962+00 |
| description | A collection of algorithms to determine the pitch of a sound sample. |
| homepage | https://github.com/alesgenova/pitch-detection |
| repository | https://github.com/worikgh/qzn3t/tree/mistress/pitch-detection |
| max_upload_size | |
| id | 1919000 |
| size | 1,424,056 |
use pitch_detection::detector::mcleod::McLeodDetector;
use pitch_detection::detector::PitchDetector;
fn main() {
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 dt = 1.0 / SAMPLE_RATE as f64;
let freq = 300.0;
let signal: Vec<f64> = (0..SIZE)
.map(|x| (2.0 * std::f64::consts::PI * x as f64 * dt * freq).sin())
.collect();
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);
}
LaTeX formulas can be used in documentation. This is enabled by a method outlined in rust-latex-doc-minimal-example. To build the docs, use
cargo doc --no-deps
The --no-deps flag is needed because special headers are included to auto-process the math in the documentation. This
header is specified using a relative path and so an error is produced if cargo tries generate documentation for
dependencies.