readAllSuspend

suspend fun AudioFileReader.readAllSuspend(dispatcher: CoroutineDispatcher = defaultIoDispatcher): FloatArray

Reads and decodes all remaining audio frames on the IO dispatcher.

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

The entire decoded audio is loaded into memory at once. For large files, consider using asFlow instead to process audio in chunks.

Cancellation

This function is cancellable at the dispatcher boundary. However, once the native readAll() call begins, it runs to completion.

Return

A FloatArray of interleaved PCM samples normalized to [-1.0, 1.0].

Parameters

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.