read

actual fun read(data: FloatArray, numFrames: Int, timeoutNanos: Long): Int

Read audio data from an input stream.

This method is used in blocking I/O mode (when no AudioStreamCallback was provided). The samples in data are written interleaved by channel: for stereo, the layout is [L0, R0, L1, R1, ...].

Return

The number of frames actually read. On Android a negative value is an Oboe error code.

Parameters

data

Float array to fill with interleaved audio samples. The array must have capacity for at least numFrames * channelCount elements.

numFrames

Number of frames to read. One frame contains one sample per channel.

timeoutNanos

Maximum time to wait in nanoseconds for data to become available. Use 0 for non-blocking behavior; Long.MAX_VALUE to block indefinitely. Ignored on JS (cannot block the main thread).

Throws

if push-mode I/O is not supported (Apple, JVM, Linux/Windows native) or if this stream's direction is StreamDirection.OUTPUT.

if the stream is closed.

actual fun read(data: FloatArray, numFrames: Int, timeoutNanos: Long): Int

Push-model read is not supported on Apple platforms.

Apple's AVAudioEngine uses a pull-model via render callbacks (AVAudioSinkNode / installTap). Use AudioStreamCallback.onAudioReady instead.

Throws

expect fun read(data: FloatArray, numFrames: Int, timeoutNanos: Long = 0): Int

Read audio data from an input stream.

This method is used in blocking I/O mode (when no AudioStreamCallback was provided). The samples in data are written interleaved by channel: for stereo, the layout is [L0, R0, L1, R1, ...].

Return

The number of frames actually read. On Android a negative value is an Oboe error code.

Parameters

data

Float array to fill with interleaved audio samples. The array must have capacity for at least numFrames * channelCount elements.

numFrames

Number of frames to read. One frame contains one sample per channel.

timeoutNanos

Maximum time to wait in nanoseconds for data to become available. Use 0 for non-blocking behavior; Long.MAX_VALUE to block indefinitely. Ignored on JS (cannot block the main thread).

Throws

if push-mode I/O is not supported (Apple, JVM, Linux/Windows native) or if this stream's direction is StreamDirection.OUTPUT.

if the stream is closed.

actual fun read(data: FloatArray, numFrames: Int, timeoutNanos: Long): Int

Read audio data from an input stream.

This method is used in blocking I/O mode (when no AudioStreamCallback was provided). The samples in data are written interleaved by channel: for stereo, the layout is [L0, R0, L1, R1, ...].

Return

The number of frames actually read. On Android a negative value is an Oboe error code.

Parameters

data

Float array to fill with interleaved audio samples. The array must have capacity for at least numFrames * channelCount elements.

numFrames

Number of frames to read. One frame contains one sample per channel.

timeoutNanos

Maximum time to wait in nanoseconds for data to become available. Use 0 for non-blocking behavior; Long.MAX_VALUE to block indefinitely. Ignored on JS (cannot block the main thread).

Throws

if push-mode I/O is not supported (Apple, JVM, Linux/Windows native) or if this stream's direction is StreamDirection.OUTPUT.

if the stream is closed.

actual fun read(data: FloatArray, numFrames: Int, timeoutNanos: Long): Int

Read audio data from an input stream.

This method is used in blocking I/O mode (when no AudioStreamCallback was provided). The samples in data are written interleaved by channel: for stereo, the layout is [L0, R0, L1, R1, ...].

Return

The number of frames actually read. On Android a negative value is an Oboe error code.

Parameters

data

Float array to fill with interleaved audio samples. The array must have capacity for at least numFrames * channelCount elements.

numFrames

Number of frames to read. One frame contains one sample per channel.

timeoutNanos

Maximum time to wait in nanoseconds for data to become available. Use 0 for non-blocking behavior; Long.MAX_VALUE to block indefinitely. Ignored on JS (cannot block the main thread).

Throws

if push-mode I/O is not supported (Apple, JVM, Linux/Windows native) or if this stream's direction is StreamDirection.OUTPUT.

if the stream is closed.

actual fun read(data: FloatArray, numFrames: Int, timeoutNanos: Long): Int

Read audio data from an input stream.

This method is used in blocking I/O mode (when no AudioStreamCallback was provided). The samples in data are written interleaved by channel: for stereo, the layout is [L0, R0, L1, R1, ...].

Return

The number of frames actually read. On Android a negative value is an Oboe error code.

Parameters

data

Float array to fill with interleaved audio samples. The array must have capacity for at least numFrames * channelCount elements.

numFrames

Number of frames to read. One frame contains one sample per channel.

timeoutNanos

Maximum time to wait in nanoseconds for data to become available. Use 0 for non-blocking behavior; Long.MAX_VALUE to block indefinitely. Ignored on JS (cannot block the main thread).

Throws

if push-mode I/O is not supported (Apple, JVM, Linux/Windows native) or if this stream's direction is StreamDirection.OUTPUT.

if the stream is closed.