AudioBuffer

Decoded PCM, ready for the engine's filter chain.

Unlike a video frame, audio does cross into Kotlin memory. It has to: resampling, channel remixing, tempo change and the drift correction all happen in the engine, and audio is small. One second of 48 kHz stereo float is 384 KB, against 187 MB for a second of 1080p60 video.

Properties

Link copied to clipboard
abstract val format: AudioFormat

The rate, the channels and the sample format of this buffer.

Link copied to clipboard
abstract val frameCount: Int

Sample frames in this buffer. One frame is one sample for every channel.

Link copied to clipboard
abstract val generation: Generation

The epoch the packets were offered in. See VideoDecoder.flush.

Link copied to clipboard
abstract val pts: Pts

The media time of the first sample frame.

Functions

Link copied to clipboard
expect abstract fun close()
Link copied to clipboard
abstract fun copyChannel(channel: Int, into: FloatArray, offset: Int = 0)

Copies channel channel into into as floats in the range -1 to 1.

Link copied to clipboard
open fun copyInterleaved(into: FloatArray, offset: Int = 0)

Copies every channel into into interleaved, frame by frame, starting at offset: the frameCount times format.channels values the engine hands to its ring. The engine reads each buffer through this. The default builds it from copyChannel and allocates one channel of scratch per call; a backend whose samples decode straight into this layout overrides it.