Vocal Range Session
class VocalRangeSession
High-level vocal range detection session with observable state.
This class provides a simplified API that:
Emits state changes via StateFlow for reactive UI
Runs auto-flow by default (countdown -> low -> high -> done)
Supports manual phase control for custom flows
Auto-Flow Usage (Recommended)
val session = VocalRangeSession.create()
// Observe state in UI
session.state.collect { state ->
updateUI(state)
}
// Start detection - runs full flow automatically
session.start()
// Feed audio from your recorder (resample to 16kHz)
recorder.audioBuffers.collect { buffer ->
val samples16k = SonixResampler.resample(buffer.floatSamples, hwRate, 16000)
session.addAudio(samples16k)
}
// Cleanup
session.release()Content copied to clipboard
Manual Flow Control
val session = VocalRangeSession.create(VocalRangeSessionConfig(autoFlow = false))
session.startPhase(VocalRangePhase.DETECTING_LOW)
// ... feed audio ...
session.advancePhase() // Move to DETECTING_HIGH
// ... feed audio ...
session.complete()Content copied to clipboard
Functions
Link copied to clipboard
Add audio samples for processing.
Link copied to clipboard
Manually advance to the next phase. Captures the current stable note for the current phase.
Link copied to clipboard
Lock the current best note and advance to next phase.
Link copied to clipboard
Start a specific phase (manual mode). Use when autoFlow = false for custom flows.