libretro.drivers.audio.array

An audio driver that accumulates all received samples in an array.

See also

libretro.api.audio

Defines the audio callback types and sample formats this driver handles.

Classes

ArrayAudioDriver

A basic AudioDriver that stores all audio samples in an in-memory array.

class ArrayAudioDriver[source]

Bases: AudioDriver

A basic AudioDriver that stores all audio samples in an in-memory array.

Suitable for tests that need to inspect audio output after the fact.

__init__()[source]

Initialize with an empty array and no AV info.

sample(left, right)[source]

Receives a single stereo audio sample from the core.

Parameters:
  • left (int) – The left-channel sample as a signed 16-bit integer.

  • right (int) – The right-channel sample as a signed 16-bit integer.

See also

retro_audio_sample_t

The C function pointer type whose signature this method implements.

sample_batch(frames)[source]

Receives a batch of interleaved stereo audio frames from the core.

Parameters:

frames (memoryview) – A read-only memoryview of interleaved signed 16-bit stereo frames.

Return type:

int

Returns:

The number of frames consumed.

See also

retro_audio_sample_batch_t

The C function pointer type whose signature this method implements.

property callbacks

Audio callbacks are not supported by this driver.

Returns:

None, always.

Raises:

UnsupportedEnvCall – If setting this property.

property buffer_status

Buffer-status callbacks are not supported by this driver.

Returns:

None, always.

Raises:

UnsupportedEnvCall – If setting this property.

property minimum_latency

Setting a minimum latency is not supported by this driver.

Returns:

None, always.

Raises:

UnsupportedEnvCall – If setting this property.

classmethod __new__(*args, **kwargs)
callback()

Invoke the registered asynchronous audio callback, if any.

Calls retro_audio_callback.callback if a callback is registered.

Return type:

None

report_buffer_status(active, occupancy, underrun_likely)

Invoke the registered buffer-status callback, if any.

Parameters:
  • active (bool) – Whether the audio buffer is actively being filled.

  • occupancy (int) – The percentage of the buffer that is currently filled (0–100).

  • underrun_likely (bool) – Whether a buffer underrun is likely on the next frame.

Return type:

None

set_state(enabled)

Enable or disables the registered asynchronous audio callback.

Calls retro_audio_callback.set_state if a callback is registered.

Parameters:

enabled (bool) – Whether to enable the audio callback.

Return type:

None

property system_av_info

The AV info most recently set by the core.

Used by the driver to configure audio parameters such as sample rate.

property buffer

The accumulated audio data as an array of signed 16-bit interleaved stereo samples.