CalibraMelodyEval

Offline melody/song evaluation for post-recording analysis.

What is Melody Evaluation?

Melody evaluation compares a complete recorded performance against a reference melody after the fact. Unlike live evaluation (real-time), this analyzes pre-recorded audio.

Use it for:

  • Post-recording feedback: Score a recording after the session ends

  • Batch processing: Analyze multiple recordings at once

  • Detailed analysis: More thorough analysis than real-time allows

When to Use

ScenarioUse This?Why
Analyze recorded audioYesCore use case
Real-time scoringNoUse CalibraLiveEval
Evaluate scales/exercisesNoUse CalibraNoteEval
Just detect pitchNoUse CalibraPitch

Quick Start

Kotlin

val reference = LessonMaterial.fromAudio(
samples = referenceAudio,
sampleRate = 16000,
segments = listOf(
Segment(0, 0.0f, 3.5f, "First line"),
Segment(1, 3.5f, 7.0f, "Second line")
),
keyHz = 261.63f // Middle C
)

val student = LessonMaterial.fromAudio(
samples = studentAudio,
sampleRate = 16000,
segments = emptyList(), // Uses reference segments
keyHz = 261.63f
)

val extractor = CalibraPitch.createContourExtractor(ContourExtractorConfig.SCORING)
val result = CalibraMelodyEval.evaluate(reference, student, extractor)
extractor.release()

println("Overall: ${result.overallScorePercent}%")
result.segmentResults.forEach { (index, attempts) ->
println("Segment $index: ${attempts.last().scorePercent}%")
}

Swift

let reference = LessonMaterial.fromAudio(
samples: referenceAudio,
sampleRate: 16000,
segments: [
Segment(index: 0, startSeconds: 0.0, endSeconds: 3.5, label: "First line"),
Segment(index: 1, startSeconds: 3.5, endSeconds: 7.0, label: "Second line")
],
keyHz: 261.63
)

let student = LessonMaterial.fromAudio(
samples: studentAudio,
sampleRate: 16000,
segments: [],
keyHz: 261.63
)

let extractor = CalibraPitch.createContourExtractor(
config: .scoring
)
let result = CalibraMelodyEval.evaluate(
reference: reference,
student: student,
contourExtractor: extractor
)
extractor.release()

print("Overall: \(result.overallScorePercent)%")

Platform Notes

iOS

  • Audio must be 16kHz mono; use SonixDecoder to decode and resample

  • Contour extractor must be released after use

Android

  • Audio must be 16kHz mono; use SonixDecoder to decode and resample

  • Runs on background thread; wrap in coroutine if needed

Common Pitfalls

  1. Wrong sample rate: Audio must be 16kHz; use SonixDecoder with default settings

  2. Forgetting to release extractor: Call extractor.release() when done

  3. Empty segments: If student.segments is empty, reference.segments is used

  4. Key mismatch: Set studentKeyHz if student sings in different key

See also

For real-time evaluation during singing

For note-by-note exercise evaluation

For input format specification

For understanding evaluation results

Functions

Link copied to clipboard

Evaluate a melody performance against a reference.