Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alesgenova/pitch-detection
A collection of algorithms to determine the pitch of a sound sample.
https://github.com/alesgenova/pitch-detection
audio-analysis frequency pitch-detection rust
Last synced: 3 days ago
JSON representation
A collection of algorithms to determine the pitch of a sound sample.
- Host: GitHub
- URL: https://github.com/alesgenova/pitch-detection
- Owner: alesgenova
- License: mit
- Created: 2019-03-10T21:58:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-08T16:07:49.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T12:13:27.985Z (7 months ago)
- Topics: audio-analysis, frequency, pitch-detection, rust
- Language: Rust
- Homepage:
- Size: 979 KB
- Stars: 212
- Watchers: 8
- Forks: 26
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![workflow status](https://github.com/alesgenova/pitch-detection/workflows/main/badge.svg?branch=master)](https://github.com/alesgenova/pitch-detection/actions?query=workflow%3Amain+branch%3Amaster)
[![crates.io](https://img.shields.io/crates/v/pitch-detection.svg)](https://crates.io/crates/pitch-detection)# pitch_detection
## Usage
```rust
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 = (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);
}
```
## Live Demo
[![Demo Page](https://raw.githubusercontent.com/alesgenova/pitch-detection-app/master/demo.png)](https://alesgenova.github.io/pitch-detection-app/)
[Source](https://github.com/alesgenova/pitch-detection-app)## Documentation
LaTeX formulas can be used in documentation. This is enabled by a method outlined in [rust-latex-doc-minimal-example](https://github.com/victe/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.