WorldPitchDetector<T>
Models & Types · AiDotNet.Audio.Pitch
F0 estimation with WORLD’s DIO (Distributed Inline-filter Operation), refined by StoneMask.
Inheritance: PitchDetectorBase<T> → WorldPitchDetector<T>
For Beginners
DIO looks at the signal through a bank of low-pass filters and measures the spacing of zero crossings and peaks in each one; the most self-consistent spacing becomes a rough pitch. StoneMask then sharpens each rough pitch using the instantaneous frequency of its first harmonics.
How It Works
This is the F0 extractor FastSpeech 2 (Ren et al. 2021, Appendix C.2) and the acoustic models built on it take
their pitch targets from: PyWorld’s dio followed by stonemask. The port follows WORLD’s C++
source line for line, including its in-place spectrum handling, so it reproduces PyWorld’s contours rather
than approximating them. Frequencies are in Hz; unvoiced frames are 0.
Constructors
| Constructor | Summary |
|---|---|
WorldPitchDetector(int sampleRate, double minPitch, double maxPitch, double channelsInOctave, int speed, double allowedRange, bool refineWithStoneMask) |
Creates a DIO + StoneMask detector with WORLD’s defaults (F0 71-800 Hz, 2 channels per octave, speed 1, allowed range 0.1). |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<PitchFrame<T>> ExtractDetailedPitchContour(Tensor<T> audio, int hopSizeMs) |
|
Tensor<T> StoneMask(Tensor<T> x, Tensor<T> f0, Tensor<T> temporalPositions) |
StoneMask’s refinement (PyWorld’s stonemask) of an F0 contour at its frames’ times. |
ValueTuple<T, T>? DetectPitchWithConfidence(Tensor<T> audioFrame) |
|
ValueTuple<Tensor<T>, Tensor<T>> EstimateF0(Tensor<T> audio, double framePeriodMs) |
Estimates the F0 contour of audio with one value per framePeriodMs, starting at time 0 (PyWorld’s dio, then stonemask when enabled). |
ValueTuple<Tensor<T>, Tensor<T>> Harvest(Tensor<T> x, double framePeriodMs) |
F0 by WORLD’s Harvest (Morise 2017; PyWorld’s harvest), one value per framePeriodMs from time 0, between this detector’s F0 floor and ceiling. |
int GetSamplesForDio(int fs, int xLength, double framePeriod) |
Number of frames DIO produces (WORLD GetSamplesForDIO). |
int GetSamplesForHarvest(int fs, int xLength, double framePeriod) |
Number of frames Harvest produces (WORLD GetSamplesForHarvest). |