Sonix Lesson Synthesizer
Synthesizes audio lessons from note sequences.
What is Lesson Synthesis?
A lesson is a sequence of notes (e.g. Sa, Re, Ga, Ma, Pa, Dha, Ni in Indian classical practice), each with its own audio recording. This synthesizer:
Combines individual note 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 note sequence |
| Synthesize from MIDI | No | Use SonixMidiSynthesizer |
| Play existing audio | No | Use SonixPlayer |
Quick Start
Kotlin
val notes = listOf(
LessonNote(
noteName = "Sa",
noteLabel = "S",
noteAudioFilePath = "/path/to/sa.wav",
numBeats = 2,
numSamplesConsonant = 100
),
LessonNote(
noteName = "Re",
noteLabel = "R",
noteAudioFilePath = "/path/to/re.wav",
numBeats = 2,
numSamplesConsonant = 100
)
)
val synth = SonixLessonSynthesizer.create(
notes = notes,
beatLengthMs = 500
)
if (synth.loadAudioSync()) {
val audioData = synth.synthesize()
// audioData is ready to play or save
}
synth.release()Swift
let notes = [
LessonNote(
noteName: "Sa",
noteLabel: "S",
noteAudioFilePath: "/path/to/sa.wav",
numBeats: 2,
numSamplesConsonant: 100
),
LessonNote(
noteName: "Re",
noteLabel: "R",
noteAudioFilePath: "/path/to/re.wav",
numBeats: 2,
numSamplesConsonant: 100
)
]
let synth = SonixLessonSynthesizer.create(
notes: notes,
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()
.notes(noteList)
.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 note files loaded into memory
Sample rate: Output defaults to 16kHz (for Calibra compatibility)
See also
For note specification format
For MIDI-based synthesis
For output format