libretro.api.microphone¶
Microphone audio capture interface types.
Corresponds to retro_microphone_interface in libretro.h.
Allows cores to capture audio input from the host device.
See also
Module Attributes
The current version of the microphone interface. |
|
Alias for |
|
Open a new microphone for capture. |
|
Close an open microphone and release its resources. |
|
Retrieve the configured parameters of an open microphone. |
|
Enable or disable an open microphone. |
|
Return whether an open microphone is currently enabled. |
|
Read captured audio samples from an open microphone. |
Classes
Opaque handle for an open microphone. |
|
Corresponds to |
|
Parameters for opening a microphone. |
- RETRO_MICROPHONE_INTERFACE_VERSION = 1¶
The current version of the microphone interface.
- INTERFACE_VERSION = 1¶
Alias for
RETRO_MICROPHONE_INTERFACE_VERSION.
- class retro_microphone[source]¶
Bases:
StructureOpaque handle for an open microphone.
Corresponds to
retro_microphoneinlibretro.h.Note
Unlike most other
ctypes-wrappedstructs in libretro.py, the fields in this class are not part of libretro.h. They are provided as a convenience forMicrophoneDriverimplementations.Cores should treat instances of this class as opaque handles and _not_ access or modify its fields directly.- id¶
Opaque identifier for this microphone handle.
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- class retro_microphone_params[source]¶
Bases:
StructureParameters for opening a microphone.
Corresponds to
retro_microphone_paramsinlibretro.h.>>> from libretro.api.microphone import retro_microphone_params >>> p = retro_microphone_params() >>> p.rate 0
- rate¶
Requested sample rate in Hz.
- __deepcopy__(_)[source]¶
Return a shallow copy.
>>> import copy >>> from libretro.api.microphone import retro_microphone_params >>> copy.deepcopy(retro_microphone_params()).rate 0
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- retro_open_mic_t¶
Open a new microphone for capture.
Registered by the frontend and called by the core.
- Parameters:
params – Pointer to a
retro_microphone_paramsdescribing the desired configuration, orNoneto use the frontend’s defaults.- Returns:
A
c_void_ptrto aretro_microphonehandle on success, orNoneif a microphone could not be opened.
Note
Microphones are inactive by default; a returned handle must be enabled with
retro_set_mic_state_tbefore it will yield samples.Corresponds to
retro_open_mic_tinlibretro.h.
- retro_close_mic_t¶
Close an open microphone and release its resources.
Registered by the frontend and called by the core. After this returns, the handle must not be used again.
- Parameters:
microphone – Pointer to the
retro_microphonehandle to close. IfNone, this function does nothing.
Corresponds to
retro_close_mic_tinlibretro.h.
- retro_get_mic_params_t¶
Retrieve the configured parameters of an open microphone.
Registered by the frontend and called by the core. The returned parameters may differ from those originally requested depending on driver and device support.
- Parameters:
microphone – Pointer to the
retro_microphonewhose parameters will be queried.params – Pointer to a
retro_microphone_paramsthat will be filled in.
- Returns:
Corresponds to
retro_get_mic_params_tinlibretro.h.
- retro_set_mic_state_t¶
Enable or disable an open microphone.
Registered by the frontend and called by the core. A disabled microphone will not produce samples and has minimal performance impact.
- Parameters:
microphone – Pointer to the
retro_microphonewhose state will change.
- Returns:
Trueif the state was successfully set,Falseifmicrophoneis invalid or there was an error.
Corresponds to
retro_set_mic_state_tinlibretro.h.
- retro_get_mic_state_t¶
Return whether an open microphone is currently enabled.
Registered by the frontend and called by the core.
- Parameters:
microphone – Pointer to the
retro_microphoneto query.- Returns:
Corresponds to
retro_get_mic_state_tinlibretro.h.
- retro_read_mic_t¶
Read captured audio samples from an open microphone.
Registered by the frontend and called by the core, which must do so every frame while the microphone is enabled.
- Parameters:
microphone – Pointer to the
retro_microphoneto read from.samples – Pointer to a buffer of signed 16-bit mono samples that will be filled.
num_samples – Capacity of
samples, in samples (not bytes).
- Returns:
The number of samples actually written to
samples, or-1if the microphone is disabled, the audio driver is paused, or there was an error.
Corresponds to
retro_read_mic_tinlibretro.h.
- class retro_microphone_interface[source]¶
Bases:
StructureCorresponds to
retro_microphone_interfaceinlibretro.h.Provides functions for managing microphone input.
>>> from libretro.api.microphone import retro_microphone_interface, INTERFACE_VERSION >>> mic = retro_microphone_interface(INTERFACE_VERSION) >>> mic.open_mic is None True
- classmethod __new__(*args, **kwargs)¶
- __init__(interface_version, open_mic=None, close_mic=None, get_params=None, set_mic_state=None, get_mic_state=None, read_mic=None)[source]¶
Initialize the interface with a required version number.
- Parameters:
interface_version (
int) – Must matchINTERFACE_VERSION.
- interface_version¶
Version of the microphone interface.
- open_mic¶
Opens a microphone with the given parameters.
- close_mic¶
Closes an open microphone.
- get_params¶
Retrieves the effective parameters of an open microphone.
- set_mic_state¶
Enables or disables an open microphone.
- get_mic_state¶
Returns whether an open microphone is currently enabled.
- read_mic¶
Reads audio samples from an open microphone.