MIDI - JakeTurner616/pygame-lua-bindings GitHub Wiki

Pygame MIDI Utility Functions

midi_init()

Initialize the MIDI module.

Returns: None

midi_quit()

Uninitialize the MIDI module.

Returns: None

midi_get_init()

Check if the MIDI module is currently initialized.

Returns: Boolean indicating whether the MIDI module is initialized.

midi_Input(device_id, buffer_size=None)

Create a MIDI input object.

Parameters:

  • device_id: The ID of the MIDI device.
  • buffer_size: The size of the buffer (optional).

Returns: A MIDI input object.

midi_Input_close(midi_input)

Close a MIDI input object.

Parameters:

  • midi_input: The MIDI input object to close.

Returns: None

midi_Input_poll(midi_input)

Check if there's data available in the input buffer.

Parameters:

  • midi_input: The MIDI input object.

Returns: Boolean indicating whether data is available.

midi_Input_read(midi_input, num_events)

Read MIDI events from the input buffer.

Parameters:

  • midi_input: The MIDI input object.
  • num_events: The number of events to read.

Returns: A list of MIDI events.

midi_Output(device_id, latency=0, buffer_size=256)

Create a MIDI output object.

Parameters:

  • device_id: The ID of the MIDI device.
  • latency: The latency in milliseconds (optional, default is 0).
  • buffer_size: The size of the buffer (optional, default is 256).

Returns: A MIDI output object.

midi_Output_abort(midi_output)

Terminate outgoing messages immediately.

Parameters:

  • midi_output: The MIDI output object.

Returns: None

midi_Output_close(midi_output)

Close a MIDI output object.

Parameters:

  • midi_output: The MIDI output object to close.

Returns: None

midi_Output_note_off(midi_output, note, velocity=None, channel=0)

Turn a MIDI note off.

Parameters:

  • midi_output: The MIDI output object.
  • note: The note to turn off.
  • velocity: The velocity of the note (optional).
  • channel: The channel number (optional, default is 0).

Returns: None

midi_Output_note_on(midi_output, note, velocity=None, channel=0)

Turn a MIDI note on.

Parameters:

  • midi_output: The MIDI output object.
  • note: The note to turn on.
  • velocity: The velocity of the note (optional).
  • channel: The channel number (optional, default is 0).

Returns: None

midi_Output_set_instrument(midi_output, instrument_id, channel=0)

Select an instrument.

Parameters:

  • midi_output: The MIDI output object.
  • instrument_id: The ID of the instrument.
  • channel: The channel number (optional, default is 0).

Returns: None

midi_Output_pitch_bend(midi_output, value=0, channel=0)

Modify the pitch of a channel.

Parameters:

  • midi_output: The MIDI output object.
  • value: The pitch bend value (optional, default is 0).
  • channel: The channel number (optional, default is 0).

Returns: None

midi_Output_write(midi_output, data)

Write MIDI data to the output.

Parameters:

  • midi_output: The MIDI output object.
  • data: The MIDI data to write.

Returns: None

midi_Output_write_short(midi_output, status, data1=0, data2=0)

Write up to 3 bytes of MIDI data to the output.

Parameters:

  • midi_output: The MIDI output object.
  • status: The status byte.
  • data1: The first data byte (optional, default is 0).
  • data2: The second data byte (optional, default is 0).

Returns: None

midi_Output_write_sys_ex(midi_output, when, msg)

Write a timestamped system-exclusive MIDI message.

Parameters:

  • midi_output: The MIDI output object.
  • when: The timestamp.
  • msg: The system-exclusive message.

Returns: None

midi_get_count()

Get the number of MIDI devices.

Returns: The number of MIDI devices.

midi_get_default_input_id()

Get the default input device number.

Returns: The default input device number.

midi_get_default_output_id()

Get the default output device number.

Returns: The default output device number.

midi_get_device_info(device_id)

Get information about a MIDI device.

Parameters:

  • device_id: The ID of the MIDI device.

Returns: A tuple containing information about the device.

midi_midis2events(midi_events, device_id)

Convert MIDI events to Pygame events.

Parameters:

  • midi_events: A list of MIDI events.
  • device_id: The ID of the MIDI device.

Returns: A list of Pygame events.

midi_time()

Get the current time in milliseconds of the PortMidi timer.

Returns: The current time in milliseconds.

midi_frequency_to_midi(frequency)

Convert a frequency into a MIDI note.

Parameters:

  • frequency: The frequency to convert.

Returns: The MIDI note corresponding to the frequency.

midi_midi_to_frequency(midi_note)

Convert a MIDI note to a frequency.

Parameters:

  • midi_note: The MIDI note to convert.

Returns: The frequency corresponding to the MIDI note.

midi_midi_to_ansi_note(midi_note)

Get the Ansi Note name for a MIDI number.

Parameters:

  • midi_note: The MIDI note to convert.

Returns: The Ansi Note name.

MidiException

Exception raised by pygame.midi functions and classes.

init(errno)

Constructor method to initialize the MidiException.

Parameters:

  • errno: The error number.

Returns: None