-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from siefkenj/docs
Add docs to pitch detectors
- Loading branch information
Showing
12 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build] | ||
# Including this header allows for math to be rendered in the docs. | ||
rustdocflags = ["--html-in-header", "./src/docs-header.html"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function() { | ||
renderMathInElement(document.body, { | ||
delimiters: [ | ||
{left: "$$", right: "$$", display: true}, | ||
{left: "\\(", right: "\\)", display: false}, | ||
{left: "$", right: "$", display: false}, | ||
{left: "\\[", right: "\\]", display: true} | ||
] | ||
}); | ||
}); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,47 @@ | ||
//! # Pitch Detection | ||
//! *pitch_detection* implements several algorithms for estimating the | ||
//! fundamental frequency of a sound wave stored in a buffer. It is designed | ||
//! to be usable in a WASM environment. | ||
//! | ||
//! # Detectors | ||
//! A *detector* is an implementation of a pitch detection algorithm. Each detector's tolerance | ||
//! for noise and polyphonic sounds varies. | ||
//! | ||
//! * [AutocorrelationDetector][detector::autocorrelation] | ||
//! * [McLeodDetector][detector::mcleod] | ||
//! * [YINDetector][detector::yin] | ||
//! | ||
//! # Examples | ||
//! ``` | ||
//! 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); | ||
//! } | ||
//! ``` | ||
|
||
pub use detector::internals::Pitch; | ||
|
||
pub mod detector; | ||
pub mod float; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters