Pitch Contour Extractor
class PitchContourExtractor
Batch pitch contour extractor — pass a complete recording, get a full contour.
Runs detection across the entire audio and applies configurable post-processing (octave correction, blip removal, smoothing) according to ContourExtractorConfig.cleanup.
When to Use
| Scenario | Use This | Why |
|---|---|---|
| Offline scoring / melody eval / intonation | Yes | Full contour with cleanup in one call |
| Live singing feedback | No | Use PitchDetector via PitchDetection.createDetector |
Construct instances via PitchDetection.createContourExtractor — do not instantiate directly.
Swift
let extractor = PitchDetection.createContourExtractor(config: .scoring) {
ModelLoader.shared.loadSwiftF0()
}
let contour = extractor.extract(audio: audioSamples, sampleRate: 48000)
print("Duration: \(contour.duration)s, \(contour.size) frames")
extractor.release()Content copied to clipboard
Common Pitfalls
Call
release()when done: Holds native detector resources.Audio must be mono: Pass single-channel
Floatsamples.SonixDecoder.decode()auto-converts stereo to mono (ADR-017).Resampling is internal: Pass audio at any sample rate — the extractor resamples to 16kHz internally (ADR-017).
See also
Pitch Detection. create Contour Extractor
Factory method
Configuration (DEFAULT, SCORING, DISPLAY, RAW)
For realtime detection instead of batch
The result type