MIDI Input and Output¶
Contents
rcp.midi¶
Objects related to MIDI event processing.
-
class
rcp.midi.
MIDIEncoder
[source]¶ Abstract class for composing MIDI messages.
-
channel_pressure
(channel, value)[source]¶ Send a Channel Pressure (aftertouch) message.
- Parameters
channel – MIDI channel, integer on [1,16]
value – MIDI value, integer on [0,127]
-
control_change
(channel, controller, value)[source]¶ Send a Controller Change message.
- Parameters
channel – MIDI channel, integer on [1,16]
controller – MIDI controller index, integer on [0,127]
value – MIDI value, integer on [0,127]
-
message
(message)[source]¶ Overridable method to output a single MIDI message.
- Parameters
message – list of integers constituting a MIDI message
-
note_off
(channel, note, velocity=0)[source]¶ Send a Note On message.
- Parameters
channel – MIDI channel, integer on [1,16]
note – MIDI note, integer on [0,127]
velocity – optional MIDI velocity, integer on [0,127], normally zero, default zero
-
-
class
rcp.midi.
MIDIProcessor
[source]¶ Abstract class for processing MIDI events. Provides a callback for the specific MIDI events we use in our systems so this may be subclassed to implement a MIDI stream processor. This defines an informal protocol for MIDI input. This may be extended to more event times as needed.
-
channel_pressure
(channel, value)[source]¶ Function to receive messages starting with 0xD0 through 0xDF.
- Parameters
channel – integer from 1 to 16
value – integer from 0 to 127
-
control_change
(channel, control, value)[source]¶ Function to receive messages starting with 0xB0 through 0xBF.
- Parameters
channel – integer from 1 to 16
control – integer from 0 to 127; some have special meanings
value – integer from 0 to 127
-
decode_message
(message)[source]¶ Decode a MIDI message expressed as a list of integers and perform callbacks for recognized message types.
- Parameters
message – list of integers containing a single MIDI message
-
decode_mpd218_cc
(cc)[source]¶ Interpret a MPD218 knob control change event as a knob index and bank position. The MPD218 uses a non-contiguous set of channel indices so this normalizes the result. The knob index ranges from 1 to 6 matching the knob labels. Bank 0 is the A bank, bank 1 is the B bank, bank 2 is the C bank.
- Parameters
cc – an integer MIDI control channel identifier
- Returns
(knob, bank)
-
decode_mpd218_key
(key)[source]¶ Interpret a MPD218 pad event key value as a row, column, and bank position. Row 0 is the front/bottom row (Pads 1-4), row 3 is the back/top row (Pads 13-16). Column 0 is the left, column 3 is the right. Bank 0 is the A bank, bank 1 is the B bank, bank 2 is the C bank.
- Parameters
key – an integer MIDI note value
- Returns
(row, column, bank)
-
note_off
(channel, key, velocity)[source]¶ Function to receive messages starting with 0x80 through 0x8F.
- Parameters
channel – integer from 1 to 16
key – integer from 0 to 127
velocity – integer from 0 to 127
-
-
class
rcp.midi.
QtMIDIListener
[source]¶ Object to manage a MIDI input connection.
-
connect_midi_processor
(processor)[source]¶ Attach an object to receive MIDI input events, generally a subclass of MIDIProcessor.
-