PostProcess

Post-processing utilities for pitch arrays.

Use this for processing entire pitch contours (e.g., from recorded audio). For realtime processing, use Detector with enableProcessing = true.

Usage:

val rawPitches = floatArrayOf(440f, 442f, 880f, 438f) // Has octave error

// Full processing
val processed = CalibraPitch.PostProcess.process(rawPitches)

// Individual operations
val smoothed = CalibraPitch.PostProcess.smooth(rawPitches)
val corrected = CalibraPitch.PostProcess.correctOctaveErrors(rawPitches)
val filtered = CalibraPitch.PostProcess.medianFilter(rawPitches)

Functions

Link copied to clipboard
fun cleanup(contour: PitchContour, options: ContourCleanup, hopMs: Int = 10): PitchContour

Apply cleanup options to a pitch contour.

Link copied to clipboard
fun correctBoundaryOctaves(pitchesHz: FloatArray, hopMs: Int = 10, boundaryWindowMs: Float = 50.0f): FloatArray

Correct octave errors at phrase boundaries (onset/offset).

Link copied to clipboard
fun correctOctaveErrors(pitchesHz: FloatArray, thresholdCents: Float = 500.0f, referencePitchHz: Float = 0.0f): FloatArray

Apply octave error correction only.

Link copied to clipboard
fun fixBoundaryOctaves(contour: PitchContour, boundaryWindowMs: Float = 50.0f): PitchContour

Fix boundary octave errors in a pitch contour.

Link copied to clipboard

Fix octave errors in a pitch contour.

Link copied to clipboard
fun medianFilter(pitchesHz: FloatArray, kernelSize: Int = 5): FloatArray

Apply median filter for spike removal.

Link copied to clipboard
fun process(pitchesHz: FloatArray): FloatArray

Process a pitch contour with smoothing and octave correction using default settings.

fun process(pitchesHz: FloatArray, smoothingWindowSize: Int = 7, octaveThresholdCents: Float = 500.0f, enableSmoothing: Boolean = true, enableOctaveCorrection: Boolean = true): FloatArray

Process a pitch contour with configurable smoothing and octave correction.

Link copied to clipboard
fun rejectOutliers(pitchesHz: FloatArray, hopMs: Int = 10, minDurationMs: Float = 80.0f): FloatArray

Reject short pitch runs (blips) based on minimum duration.

Link copied to clipboard
fun removeBlips(contour: PitchContour, minDurationMs: Float = 80.0f): PitchContour

Remove short pitch runs (blips) from a contour.

Link copied to clipboard

Apply smoothing to a pitch contour.

fun smooth(pitchesHz: FloatArray, windowSize: Int = 7): FloatArray

Apply smoothing filter only.