Tessera Range Session
Guided vocal range detection session with observable state.
What is a Range Session?
A stateful, phase-driven workflow for detecting a singer's comfortable vocal range: countdown → detect low → transition → detect high → complete. Emits VocalRangeState via state (a StateFlow) so UI can track progress, current pitch, stability, and the final result.
Supports auto-flow (automatic phase progression) and manual control (caller drives transitions via startPhase / advancePhase).
When to Use
| Scenario | Use This | Why |
|---|---|---|
| Interactive "find your range" flow in the app | Yes | Guided phases + observable state |
| Batch range estimation from a recording | No | Use TesseraRange.computeVocalRange |
| Multi-metric analysis (breath + agility + range) | No | Use Tessera.analyze or TesseraSession |
Quick Start
Kotlin
val session = TesseraRangeSession.create(
detectorConfig = PitchDetectorConfig.BALANCED
)
// Observe state
session.state.collect { state -> updateUI(state) }
// Start auto-flow and feed audio
session.start()
recorder.audioBuffers.collect { buffer ->
session.addAudio(buffer.samples, sampleRate = 16000)
}
// Lock a detected note, or cancel
session.confirmNote()
session.release()Swift
let session = TesseraRangeSession.create(
detectorConfig: PitchDetectorConfig.Builder().algorithm(.yin).enableProcessing().build()
)
// Observe state via AsyncSequence
for await state in session.state {
updateUI(state)
}
session.start()
for await buffer in recorder.audioBuffers {
session.addAudio(samples: buffer.samples, sampleRate: Int32(hwRate))
}
session.confirmNote()
session.release()Common Pitfalls
start()is for auto-flow only: Ifconfig.autoFlow = false, call startPhase / advancePhase instead —start()throws.Audio is only processed during detection phases: Samples sent outside DETECTING_LOW / DETECTING_HIGH (i.e., during IDLE, COUNTDOWN, TRANSITION, COMPLETE, or CANCELLED) are silently ignored.
Call
release()when done: Holds native detector resources.confirmNote()locks the current best: It's a user-confirmation action, not an auto-trigger. Returnsfalseif no stable note yet.
See also
For batch (non-interactive) range estimation
For multi-metric batch analysis
The observable state type
The final result with natural shruti
Session configuration (auto-flow, countdown, etc.)