libretro.drivers.microphone.driver

Protocol definitions for microphone capture drivers.

See also

libretro.api.microphone

The matching ctypes types and callback definitions.

Classes

Microphone

Protocol for an open microphone capture stream returned by a MicrophoneDriver.

MicrophoneDriver

Protocol for drivers that expose the libretro microphone capture interface.

class Microphone[source]

Bases: Protocol

Protocol for an open microphone capture stream returned by a MicrophoneDriver.

abstractmethod close()[source]

Close this microphone and release any underlying resources.

Subsequent calls to read() should return None.

Return type:

None

abstract property params

The capture parameters (sample rate, channel layout) negotiated for this microphone.

None if the microphone is closed or no parameters have been negotiated.

See also

retro_microphone_params

The C struct describing the negotiated capture format.

abstractmethod read(frames)[source]

Read up to frames audio frames from this microphone.

Parameters:

frames (int) – Maximum number of mono signed 16-bit frames to read.

Return type:

array[int] | None

Returns:

An array.array of signed 16-bit samples holding the frames actually read, or None if the microphone is closed or no samples are available.

abstract property state

Whether this microphone is currently capturing.

Parameters:

stateTrue to start capturing, False to pause it.

poll()[source]

Advance any per-frame internal state (e.g. refilling the capture buffer).

Default implementation is a no-op; drivers that need per-frame work override this.

Return type:

None

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
class MicrophoneDriver[source]

Bases: Protocol

Protocol for drivers that expose the libretro microphone capture interface.

See also

libretro.api.microphone

The matching ctypes types and callback definitions.

abstract property version

The version of the microphone interface this driver implements.

abstractmethod open_mic(params)[source]

Open a new microphone capture stream.

Parameters:

params (retro_microphone_params | None) – Requested capture parameters, or None to let the driver pick its defaults.

Return type:

retro_microphone | None

Returns:

A handle to the opened microphone, or None if no microphone could be opened.

abstractmethod close_mic(mic)[source]

Close a microphone previously returned by open_mic().

Parameters:

mic (retro_microphone) – The microphone handle to close.

Return type:

None

abstractmethod get_mic_params(mic)[source]

Return the negotiated capture parameters for mic.

Parameters:

mic (retro_microphone) – The microphone handle to query.

Return type:

retro_microphone_params | None

Returns:

The negotiated parameters, or None if the microphone has none.

abstractmethod get_mic_state(mic)[source]

Return whether mic is currently capturing.

Parameters:

mic (retro_microphone) – The microphone handle to query.

Return type:

bool

Returns:

True if the microphone is capturing.

abstractmethod set_mic_state(mic, state)[source]

Start or pause capture on mic.

Parameters:
Return type:

None

abstractmethod read_mic(mic, frames)[source]

Read up to frames audio frames from mic.

Parameters:
  • mic (retro_microphone) – The microphone handle to read from.

  • frames (int) – Maximum number of mono signed 16-bit frames to read.

Return type:

array[int] | None

Returns:

An array.array of signed 16-bit samples holding the frames actually read, or None if the microphone is closed or no samples are available.

abstract property microphones

All microphones currently open through this driver.

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