libretro.api.av

Types to describe the parameters of a core’s rendered audio and video.

Classes

AvEnableFlags

Bit flags that denote whether the loaded core should render audio and/or video frames.

Region

TV region.

retro_game_geometry

The expected (and possible) dimensions of the framebuffer.

retro_system_av_info

Description of the emulated platform's audio and video characteristics.

retro_system_timing

Description of the emulated system's video and audio output timings.

class Region[source]

Bases: IntEnum

TV region.

NTSC = 0

Corresponds to RETRO_REGION_NTSC.

Tip

Cores may also return this if the NTSC/PAL region isn’t applicable, e.g. for handhelds or arcade machines.

PAL = 1

Corresponds to RETRO_REGION_PAL.

__new__(value)
classmethod value in self

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)

classmethod self[name]

Return the member matching name.

__init__()
classmethod iter(self)

Return members in definition order.

classmethod len(self)

Return the number of members (no aliases)

class AvEnableFlags[source]

Bases: IntFlag

Bit flags that denote whether the loaded core should render audio and/or video frames.

Tip

These flags can be set even if libretro.py isn’t literally showing audio or video output to the user.

VIDEO = 1

If not set, the core can safely skip rendering the next video frame.

Corresponds to RETRO_AV_ENABLE_VIDEO.

AUDIO = 2

If not set, the core can safely skip rendering the next audio frame.

Corresponds to RETRO_AV_ENABLE_AUDIO.

FAST_SAVESTATES = 4

Indicates that savestates will only be used by this process and will not be saved to disk.

Corresponds to RETRO_AV_ENABLE_FAST_SAVESTATES.

HARD_DISABLE_AUDIO = 8

If set, the core can safely skip rendering audio frames for the entire duration of its execution.

Corresponds to RETRO_AV_ENABLE_HARD_DISABLE_AUDIO.

ALL = 15

All other flags are set.

Caution

If additional flags are added in the future, this value will be updated to include them. Try not to rely on the exact value of this constant.

__new__(value)
other in self

Returns True if self has at least the same flags set as other.

iter(self)

Returns flags in definition order.

len(self)

Return the number of members (no aliases)

classmethod self[name]

Return the member matching name.

__init__()
class retro_game_geometry[source]

Bases: Structure

The expected (and possible) dimensions of the framebuffer.

Corresponds to retro_game_geometry.

Warning

This object is mutable, therefore VideoDriver s should not expose or store references to it; all access should be done through copies, otherwise you run the risk of encountering hard-to-debug issues!

base_width

Nominal video width in pixels.

Assigned values will be bitwise-masked to fit into an unsigned int.

base_height

Nominal video height in pixels.

Assigned values will be bitwise-masked to fit into an unsigned int.

max_width

Maximum possible video width in pixels.

Assigned values will be bitwise-masked to fit into an unsigned int.

max_height

Maximum possible video height in pixels.

Assigned values will be bitwise-masked to fit into an unsigned int.

aspect_ratio

Nominal aspect ratio. 0.0 indicates that it should be calculated from base_width and base_height.

Assigned values will be converted to a C float.

__deepcopy__(_)[source]

Return a deep copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_game_geometry
>>> geom = retro_game_geometry(base_width=320, base_height=240, max_width=640, max_height=480, aspect_ratio=0.0)
>>> geom2 = copy.deepcopy(geom)
>>> geom == geom2
True
>>> geom is geom2
False
property base_size

The base (nominal) resolution as (width, height).

>>> from libretro.api import retro_game_geometry
>>> geom = retro_game_geometry(base_width=256, base_height=224, max_width=256, max_height=224)
>>> geom.base_size
(256, 224)
>>> (geom.base_width, geom.base_height) == geom.base_size
True
__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
property max_size

The maximum possible resolution as (width, height).

>>> from libretro.api import retro_game_geometry
>>> geom = retro_game_geometry(base_width=256, base_height=224, max_width=512, max_height=448)
>>> geom.max_size
(512, 448)
>>> (geom.max_width, geom.max_height) == geom.max_size
True
class retro_system_timing[source]

Bases: Structure

Description of the emulated system’s video and audio output timings.

Corresponds to retro_system_timing in libretro.h.

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

The core’s video refresh rate in frames per second.

Assigned values will be converted to a C double.

sample_rate

The core’s audio output rate in Hz.

Assigned values will be converted to a C double.

__deepcopy__(_)[source]

Return a deep copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_system_timing
>>> timing = retro_system_timing(fps=60.0, sample_rate=44100.0)
>>> copy.deepcopy(timing).sample_rate
44100.0
class retro_system_av_info[source]

Bases: Structure

Description of the emulated platform’s audio and video characteristics.

Corresponds to retro_system_av_info in libretro.h.

Warning

This object is mutable, therefore VideoDriver s and AudioDriver s should not expose or store references to it; all access should be done through copies, otherwise you run the risk of encountering hard-to-debug issues!

>>> from libretro.api import retro_system_av_info, retro_game_geometry, retro_system_timing
>>> geom = retro_game_geometry(base_width=320, base_height=240, max_width=320, max_height=240)
>>> timing = retro_system_timing(fps=60.0, sample_rate=32000.0)
>>> av = retro_system_av_info(geom, timing)
>>> av.geometry.base_width
320
>>> av.timing.fps
60.0
__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
geometry

Video output geometry.

timing

Audio/video timing information.

__deepcopy__(_)[source]

Return a deep copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_system_av_info, retro_game_geometry, retro_system_timing
>>> geom = retro_game_geometry(base_width=320, base_height=240, max_width=320, max_height=240)
>>> timing = retro_system_timing(fps=60.0, sample_rate=32000.0)
>>> av = retro_system_av_info(geom, timing)
>>> av2 = copy.deepcopy(av)
>>> av2.timing.sample_rate
32000.0
retro_av_enable_flags

alias of c_uint