VorbisStream

Decodes an Ogg Vorbis file held in memory a block at a time, for music that is too long to decode up front. Open one with VorbisStream.open, pull interleaved float frames with read, start over with rewind, and close it to free the decoder.

The stream keeps its own copy of the file in native memory, so the caller's array may be reused once open returns.

Threading: open and close run on the thread that owns the stream. Between them, read and rewind may be called from one other thread at a time, such as the audio thread, and must not be called from two threads at once. Call close only after that thread has stopped using the stream.

Has no sample because it needs an Ogg Vorbis file.

Types

Link copied to clipboard
object Companion

Holds the factory that opens an Ogg Vorbis file for streaming.

Properties

Link copied to clipboard

Returns the number of interleaved channels in each frame, 1 or 2.

Link copied to clipboard

Returns the number of frames in the whole file, or 0 when the file does not record it.

Link copied to clipboard

Returns the number of frames per second the file was encoded at.

Functions

Link copied to clipboard
open override fun close()

Frees the decoder and the copy of the file. Calling it again does nothing.

Link copied to clipboard
fun read(output: FloatArray, frames: Int): Int

Decodes up to frames frames into the start of output, interleaved by channel, and returns how many frames were written. Returns fewer than frames only at the end of the file, and 0 once the end has been reached.

Link copied to clipboard
fun rewind()

Moves back to the first frame, so the next read starts the file over.

Link copied to clipboard
open override fun toString(): String

Returns the format as VorbisStream(<channels> ch, <rate> Hz, <frames> frames).