KRecorder
A Kotlin Multiplatform audio recording library for Android and iOS.
Features
- KMP-first — single API for Android and iOS
- Configurable — sample rate, channels, encoding (AAC/PCM/AMR/Opus), output format
- Reactive —
StateFlow<RecorderState> with amplitude, duration, status
- Waveform-ready — amplitude normalized to 0.0–1.0 at ~20fps for visualization
- Optional UI — ready-made
RecorderView + standalone WaveformView, or bring your own
- Lifecycle-safe — pause/resume/stop/release
Modules
KRecorder/
├── krecorder-core/ ← Recording engine. No UI dependency.
├── krecorder-ui/ ← Optional Compose Multiplatform UI.
└── sample/ ← Demo app showcasing all features.
Demo App
The sample module demonstrates all library features:
- Config pickers — tap chips to change sample rate, channels, encoding, and format live
- Live recording — waveform visualization, timer with red recording indicator
- Pause/Resume/Stop — full lifecycle control
- Dark theme — Material3 dark color scheme
Run the demo
./gradlew :sample:installDebug
open iosApp/iosApp.xcodeproj
Quick Start
Core only (bring your own UI)
val recorder = KRecorder.create(
config = RecorderConfig(
sampleRate = SampleRate.RATE_44100,
channels = Channels.MONO,
encoding = AudioEncoding.AAC,
format = OutputFormat.MP4,
)
)
recorder.state.collect { state ->
println("${state.formattedDuration} | Amplitude: ${state.amplitude}")
}
recorder.start()
recorder.pause()
recorder.resume()
recorder.stop()
recorder.release()
With built-in UI
val recorder = remember { KRecorder.create() }
RecorderView(
recorder = recorder,
onRecordingSaved = { filePath -> },
)
Standalone waveform
WaveformView(
amplitudes = amplitudes,
barColor = Color.White,
barWidth = 3.dp,
barSpacing = 2.dp,
height = 200.dp,
)
Configuration
State
StateFlow<RecorderState> fields:
Platform Setup
Android
<uses-permission android:name="android.permission.RECORD_AUDIO" />
iOS
<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access to record audio.</string>
Architecture
┌─────────────────────────────────────────┐
│ Your App │
│ ┌────────────┐ ┌───────────────────┐ │
│ │krecorder-ui│ │ Your custom UI │ │
│ │RecorderView│ │ WaveformView │ │
│ └─────┬──────┘ └────────┬──────────┘ │
│ └────────┬─────────┘ │
│ ┌────────┴─────────┐ │
│ │ krecorder-core │ │
│ │ KRecorder + Flow │ │
│ ├────────┬─────────┤ │
│ │Android │ iOS │ │
│ │MediaRec│AVAudioRec │
│ └────────┴─────────┘ │
└─────────────────────────────────────────┘
Tech Stack
- Kotlin 2.3.20 / Compose Multiplatform 1.10.3
- Kotlinx Coroutines 1.10.2 / Gradle 8.14.3
- Android: MediaRecorder / iOS: AVAudioRecorder
License
Apache 2.0