libretro.drivers.audio.wave

An audio driver that writes received samples to a WAV file.

See also

wave

The Python standard library module used to write WAV files in this driver.

libretro.api.audio

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

Classes

WaveWriterAudioDriver

An AudioDriver that writes all audio output to a WAV file.

class WaveWriterAudioDriver[source]

Bases: AudioDriver

An AudioDriver that writes all audio output to a WAV file.

The output file is always stereo, 16-bit PCM at 44,100 Hz.

__init__(file)[source]

Open the given file for writing WAV audio.

Parameters:

file (str | bytes | PathLike[str] | PathLike[bytes] | IO[bytes]) – The output destination. Can be a file path (str, bytes, or PathLike) or a writable binary I/O object.

Raises:
  • ValueError – If file is an IO object that is not writable.

  • TypeError – If file is not one of the supported types.

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.

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 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.

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.

close()[source]

Close the underlying WAV file.