AudioCapture

Microphone capture for Kotlin Multiplatform on Android and iOS.

Start with AudioCapture:

  • record asks for permission and records a file in one call.

  • stream gives a cold Flow of raw PCM AudioChunks. The microphone is open only while the flow is collected.

  • start returns a CaptureSession that can stream, record to an AAC or WAV file, or both, with levels, pause/resume and interruption handling.

CaptureConfig holds every option. Its defaults, 16 kHz mono PCM16 in 100 ms chunks, suit speech-to-text.

Quick start

val capture = AudioCapture()

val session = capture.record("memo.m4a") // asks for the microphone the first time
launch { session.normalizedLevel.collect { meter = it } }
// ...
val recording = session.stop()

Microphone capture for Kotlin Multiplatform on Android and iOS.

Start with AudioCapture:

  • record asks for permission and records a file in one call.

  • stream gives a cold Flow of raw PCM AudioChunks. The microphone is open only while the flow is collected.

  • start returns a CaptureSession that can stream, record to an AAC or WAV file, or both, with levels, pause/resume and interruption handling.

CaptureConfig holds every option. Its defaults, 16 kHz mono PCM16 in 100 ms chunks, suit speech-to-text.

Quick start

val capture = AudioCapture()

val session = capture.record("memo.m4a") // asks for the microphone the first time
launch { session.normalizedLevel.collect { meter = it } }
// ...
val recording = session.stop()

Microphone capture for Kotlin Multiplatform on Android and iOS.

Start with AudioCapture:

  • record asks for permission and records a file in one call.

  • stream gives a cold Flow of raw PCM AudioChunks. The microphone is open only while the flow is collected.

  • start returns a CaptureSession that can stream, record to an AAC or WAV file, or both, with levels, pause/resume and interruption handling.

CaptureConfig holds every option. Its defaults, 16 kHz mono PCM16 in 100 ms chunks, suit speech-to-text.

Quick start

val capture = AudioCapture()

val session = capture.record("memo.m4a") // asks for the microphone the first time
launch { session.normalizedLevel.collect { meter = it } }
// ...
val recording = session.stop()

Packages

Link copied to clipboard
common
ios

The public API: the capture entry point, sessions, configuration and audio types.