Sonix Lesson Synthesizer
Synthesizes audio lessons from svara (note) sequences.
What is Lesson Synthesis?
In Indian classical music education, lessons are built from svaras (notes like Sa, Re, Ga, Ma, Pa, Dha, Ni). This synthesizer:
Combines individual svara recordings into a complete lesson
Applies proper timing based on beat length
Handles crossfades and loop smoothing
Adds configurable silence at start/end
When to Use
| Scenario | Use This? | Why |
|---|---|---|
| Generate lesson audio | Yes | Core use case |
| Create practice tracks | Yes | From svara sequence |
| Synthesize from MIDI | No | Use SonixMidiSynthesizer |
| Play existing audio | No | Use SonixPlayer |
Quick Start
Kotlin
val svaras = listOf(
LessonSvara(
svaraName = "Sa",
svaraLabel = "S",
svaraAudioFilePath = "/path/to/sa.wav",
numBeats = 2,
numSamplesConsonant = 100
),
LessonSvara(
svaraName = "Re",
svaraLabel = "R",
svaraAudioFilePath = "/path/to/re.wav",
numBeats = 2,
numSamplesConsonant = 100
)
)
val synth = SonixLessonSynthesizer.create(
svaras = svaras,
beatLengthMs = 500
)
if (synth.loadAudioSync()) {
val audioData = synth.synthesize()
// audioData is ready to play or save
}
synth.release()Swift
let svaras = [
LessonSvara(
svaraName: "Sa",
svaraLabel: "S",
svaraAudioFilePath: "/path/to/sa.wav",
numBeats: 2,
numSamplesConsonant: 100
),
LessonSvara(
svaraName: "Re",
svaraLabel: "R",
svaraAudioFilePath: "/path/to/re.wav",
numBeats: 2,
numSamplesConsonant: 100
)
]
let synth = SonixLessonSynthesizer.create(
svaras: svaras,
beatLengthMs: 500
)
// Load audio (async)
if await synth.loadAudio() {
if let audioData = synth.synthesize() {
// audioData is ready to play or save
}
}
synth.release()Builder Pattern (Advanced)
Kotlin
val synth = SonixLessonSynthesizer.Builder()
.svaras(svaraList)
.beatLengthMs(500)
.silenceBeats(start = 2, end = 2)
.sampleRate(44100)
.onError { error -> println("Error: $error") }
.build()StateFlows
| StateFlow | Type | Description |
|---|---|---|
isLoading | Boolean | True while loading audio files |
isLoaded | Boolean | True when ready to synthesize |
error | SonixError? | Error state |
Platform Notes
iOS/Android
Audio files must be accessible at specified paths
Loading happens asynchronously (use
loadAudio()suspend function)Synthesis runs synchronously after loading
Common Pitfalls
Call loadAudio first: Must load before synthesize
Audio file paths: Must be absolute paths to valid audio files
Memory usage: All svara files loaded into memory
Sample rate: Output defaults to 16kHz (for Calibra compatibility)
See also
For svara specification format
For MIDI-based synthesis
For output format