readFramesSuspend

suspend fun AudioFileReader.readFramesSuspend(maxFrames: Int, dispatcher: CoroutineDispatcher = defaultIoDispatcher): FloatArray

Reads up to maxFrames audio frames on the IO dispatcher.

This is a suspending wrapper around AudioFileReader.readFrames that offloads the blocking I/O and decoding work to the specified dispatcher (defaulting to the platform IO dispatcher).

Return

A FloatArray of interleaved PCM samples. The array length is at most maxFrames * reader.info.channelCount.

Parameters

maxFrames

The maximum number of frames to read. The returned array may be shorter if the end of the file is reached.

dispatcher

Dispatcher for the blocking read. Defaults to the platform IO dispatcher (kotlinx.coroutines.Dispatchers.IO except JS, which uses Dispatchers.Default).

See also

Throws

AudioFileException

if a decoding error occurs.