Sonix Recorder Config
data class SonixRecorderConfig(val format: AudioFormat = AudioFormat.M4A, val sampleRate: Int = 16000, val channels: Int = 1, val bitrate: Int = 64000, val playbackSyncProvider: PlaybackInfoProvider? = null, val enableSegmentRecording: Boolean = false, val segmentOutputDirectory: String? = null, val bufferPoolSize: Int = 4, val bufferSampleSize: Int = 2048, val recordingBufferSizeBytes: Int = 10 * 1024 * 1024, val audioBufferSizeMs: Int = 40, val echoCancellation: Boolean = false, val onRecordingStarted: () -> Unit? = null, val onRecordingStopped: (outputPath: String) -> Unit? = null, val onError: (message: String) -> Unit? = null, val onLevelUpdate: (level: Float) -> Unit? = null, val onStateChange: (RecordingState) -> Unit? = null)
Configuration for SonixRecorder.
Usage Tiers
Tier 1: Presets (80% of users)
Kotlin
val recorder = SonixRecorder.create("/path/to/output.m4a", SonixRecorderConfig.VOICE)Content copied to clipboard
Swift
let recorder = SonixRecorder.create(outputPath: "/path/to/output.m4a", config: .voice)Content copied to clipboard
Tier 2: Builder (15% of users)
Kotlin
val config = SonixRecorderConfig.Builder()
.preset(SonixRecorderConfig.HIGH)
.format(AudioFormat.MP3)
.echoCancellation(true)
.build()
val recorder = SonixRecorder.create("/path/to/output.mp3", config)Content copied to clipboard
Swift
let config = SonixRecorderConfig.Builder()
.preset(.high)
.format(.mp3)
.echoCancellation(true)
.build()
let recorder = SonixRecorder.create(outputPath: "/path/to/output.mp3", config: config)Content copied to clipboard
Tier 3: .copy() (5% of users)
Kotlin
val config = SonixRecorderConfig.VOICE.copy(bitrate = 128000)Content copied to clipboard
See also
Factory method to create recorders
For playing recorded audio
Constructors
Link copied to clipboard
constructor(format: AudioFormat = AudioFormat.M4A, sampleRate: Int = 16000, channels: Int = 1, bitrate: Int = 64000, playbackSyncProvider: PlaybackInfoProvider? = null, enableSegmentRecording: Boolean = false, segmentOutputDirectory: String? = null, bufferPoolSize: Int = 4, bufferSampleSize: Int = 2048, recordingBufferSizeBytes: Int = 10 * 1024 * 1024, audioBufferSizeMs: Int = 40, echoCancellation: Boolean = false, onRecordingStarted: () -> Unit? = null, onRecordingStopped: (outputPath: String) -> Unit? = null, onError: (message: String) -> Unit? = null, onLevelUpdate: (level: Float) -> Unit? = null, onStateChange: (RecordingState) -> Unit? = null)
Types
Properties
Link copied to clipboard
Audio capture buffer size in milliseconds
Link copied to clipboard
Number of pre-allocated buffers for zero-allocation DSP
Link copied to clipboard
Size of each buffer in samples
Link copied to clipboard
Enable acoustic echo cancellation
Link copied to clipboard
Enable segment recording for practice apps
Link copied to clipboard
Audio format (M4A, MP3, WAV)
Link copied to clipboard
Called when audio level updates
Link copied to clipboard
Called when recording starts
Link copied to clipboard
Called when recording stops with output path
Link copied to clipboard
Called when recording state changes
Link copied to clipboard
Provider for playback timeline synchronization
Link copied to clipboard
Maximum bytes for encoding buffer ring
Link copied to clipboard
Sample rate in Hz
Link copied to clipboard
Directory for segment output files