libretro.api.midi

MIDI input/output interface types. Allows cores to send and receive MIDI messages.

Corresponds to retro_midi_interface in libretro.h.

See also

MidiDriver

The Protocol that uses these types to implement MIDI support in libretro.py.

libretro.drivers.midi

libretro.py’s included MidiDriver implementations.

Module Attributes

retro_midi_input_enabled_t

Return whether MIDI input is currently enabled.

retro_midi_output_enabled_t

Return whether MIDI output is currently enabled.

retro_midi_read_t

Read a single byte from the MIDI input stream.

retro_midi_write_t

Write a single byte to the MIDI output stream.

retro_midi_flush_t

Flush previously-written MIDI output.

Classes

retro_midi_interface

Provides functions for MIDI input/output.

retro_midi_input_enabled_t

Return whether MIDI input is currently enabled.

Registered by the frontend and called by the core.

Returns:

True if MIDI input is enabled.

Corresponds to retro_midi_input_enabled_t in libretro.h.

retro_midi_output_enabled_t

Return whether MIDI output is currently enabled.

Registered by the frontend and called by the core.

Returns:

True if MIDI output is enabled.

Corresponds to retro_midi_output_enabled_t in libretro.h.

retro_midi_read_t

Read a single byte from the MIDI input stream.

Registered by the frontend and called by the core.

Parameters:

byte – Pointer to a c_uint8 that receives the input byte.

Returns:

True if a byte was successfully read, False if MIDI input is disabled or byte is None.

Corresponds to retro_midi_read_t in libretro.h.

retro_midi_write_t

Write a single byte to the MIDI output stream.

Registered by the frontend and called by the core.

Parameters:
  • byte – The byte to write.

  • delta_time – Time elapsed since the previous write, in microseconds.

Returns:

True if byte was written, False otherwise.

Corresponds to retro_midi_write_t in libretro.h.

retro_midi_flush_t

Flush previously-written MIDI output.

Registered by the frontend and called by the core.

Returns:

True if the output was successfully flushed.

Corresponds to retro_midi_flush_t in libretro.h.

class retro_midi_interface[source]

Bases: Structure

Provides functions for MIDI input/output.

Corresponds to retro_midi_interface in libretro.h.

>>> from libretro.api import retro_midi_interface
>>> midi = retro_midi_interface()
>>> midi.read is None
True
input_enabled

Returns whether MIDI input is enabled.

output_enabled

Returns whether MIDI output is enabled.

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

Reads a byte from the MIDI input stream.

write

Writes a byte to the MIDI output stream with a delta time.

flush

Flushes previously-written MIDI data.

__deepcopy__(_)[source]

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

>>> import copy
>>> from libretro.api import retro_midi_interface
>>> copy.deepcopy(retro_midi_interface()).read is None
True