JvmAudioRecordingSession

class JvmAudioRecordingSession(device: AudioDevice.Input, format: AudioFormat = DefaultJvmRecordingAudioFormat, warmupMillis: Int = JvmRecordingWarmupMillis) : BaseAudioRecordingSession

JVM implementation for AudioRecordingSession.

Parameters

device

The input device to record from.

format

The format of the audio data.

warmupMillis

Number of milliseconds of audio to read-and-discard immediately after TargetDataLine.start() so the silent priming frames the JavaSound stack produces (GitHub issue #5) don't show up at the beginning of every recording. Set to 0 to disable.

Constructors

Link copied to clipboard
constructor(device: AudioDevice.Input, format: AudioFormat = DefaultJvmRecordingAudioFormat, warmupMillis: Int = JvmRecordingWarmupMillis)

Properties

Link copied to clipboard
open override val audioFlow: StateFlow<AudioFlow?>

A flow that emits audio data chunks as ByteArrays while recording.

Link copied to clipboard
open override val state: StateFlow<AudioRecordingSession.State>

A flow that emits the current state of the recording.

Functions

Link copied to clipboard
open suspend override fun pause()

Pauses recording while preserving the captured buffer, the live recording job, and the publicly exposed AudioFlow. Calling resume appends further chunks to the same hot flow, so consumers see one continuous stream.

Link copied to clipboard
open override fun reset()
Link copied to clipboard
open suspend override fun resume()

Resumes a recording previously paused. The buffered chunks from before the pause remain in the audio flow; new chunks are appended to the same hot flow.

Link copied to clipboard
open suspend override fun start()

Starts the recording. Sets the state to RECORDING.

Link copied to clipboard
open override fun stop()

Stops the current recording. Sets the state to STOPPED.