AudioRecording
Represents a recorded audio clip with its format metadata.
This is a higher-level abstraction over AudioFlow that provides convenient methods for common operations like saving to file and playback.
AudioRecording is immutable and thread-safe. All factory methods create defensive copies of input data to prevent external mutation.
Example Usage
val recording = Kodio.record(duration = 5.seconds)
// Save to file
recording.saveAs(Path("voice_note.wav"))
// Play it back
recording.play()
// Access raw data
val bytes = recording.toByteArray()Properties
The calculated duration based on frame count and sample rate. Falls back to the provided duration if available.
The audio format of this recording
The number of audio frames in this recording. A frame contains one sample per channel.
The total size of the audio data in bytes.
Functions
Returns the audio data as an AudioFlow for compatibility with existing APIs.
Saves the recording to a file in the specified format.
Collects all chunks into a single byte array. Note: This loads all audio data into memory. Returns a new array (not a reference to internal data).