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

ScenarioUse ThisWhy
Offline scoring / melody eval / intonationYesFull contour with cleanup in one call
Live singing feedbackNoUse 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()

Common Pitfalls

  1. Call release() when done: Holds native detector resources.

  2. Audio must be mono: Pass single-channel Float samples. SonixDecoder.decode() auto-converts stereo to mono (ADR-017).

  3. Resampling is internal: Pass audio at any sample rate — the extractor resamples to 16kHz internally (ADR-017).

See also

PitchDetection.createContourExtractor

Factory method

Configuration (DEFAULT, SCORING, DISPLAY, RAW)

For realtime detection instead of batch

The result type

Functions

Link copied to clipboard

Extract a complete pitch contour from audio samples.

Link copied to clipboard
fun release()

Release resources. Must be called when done.