CaptureSession

One run of the microphone, from AudioCapture.start to stop or cancel.

Properties

Link copied to clipboard
abstract val chunks: Flow<AudioChunk>

Raw PCM, one chunk per CaptureConfig.chunkDuration.

Link copied to clipboard
abstract val config: CaptureConfig

What this session was started with.

Link copied to clipboard
abstract val format: PcmFormat

The format chunks are delivered in.

Link copied to clipboard
abstract val inputDevice: InputDevice?

The microphone the system is actually recording from, or null when it does not say. It can differ from CaptureConfig.device: the system has the final word on routing.

Link copied to clipboard
abstract val level: StateFlow<AudioLevel>

Loudness of the most recent chunk; updated once per CaptureConfig.chunkDuration.

Link copied to clipboard
abstract val normalizedLevel: StateFlow<Float>

level as 0..1, ready for a meter or an animation: run through a LevelNormalizer so ordinary speech moves it well on every device. 0 while paused or stopped.

Link copied to clipboard
abstract val state: StateFlow<CaptureState>
Link copied to clipboard

The voice processing that actually took effect, which can be less than was asked for: an Android device may lack an effect, and iOS cannot switch its effects separately. null when none is active.

Functions

Link copied to clipboard
abstract suspend fun cancel()

Stops capturing and deletes the file, if there was one.

Link copied to clipboard
abstract fun pause()

Stops delivering audio and releases the microphone, keeping the session and its file open. Works while CaptureState.Recording or paused by an interruption; no-op otherwise.

Link copied to clipboard
abstract fun resume()

Picks up after pause or an interruption. No-op unless state is CaptureState.Paused.

Link copied to clipboard
abstract suspend fun stop(): Recording?

Stops capturing, finishes the file and completes chunks.