
Here we’ll be concerned with only two different status values: So we need to call midi_input.read only if this returns True.Įach number, except timestamp is a byte, and the value of status tells us what the other ( data*) numbers mean.
.jpg)
midi_input.poll() : This will basically tell us if there's any event to be read by returning a bool.midi_input.read : This will return the MIDI events (such as pressing a key) that occured and were stored in a buffer as a list of events, each event in the list has the form of, timestamp], all the named values here are numbers.There are two main functions here that we'll be using: Now using midi_input we can get MIDI messages from our controller. Also, a MIDI controller can have multiple devices on it, midi.get_count() should give you the number of devices, you can switch the one being used by selecting a different id.Make sure that default_id isn't -1, this happens if your MIDI controller isn't connected properly or if one isn’t plugged in to ensure that its being detected you can run midi.get_device_info(default_id) to make user that the name you see is the same your device.This sets up the midi.Input object which will allow us to receive data from our controller.

Using it is pretty simple, you first initialize and then set it up: midi.init() default_id = midi.get_default_input_id() midi_input = midi.Input(device_id=default_id) To deal with MIDI input we’ll use pygame.midi. MIDI stands for Music Instrument Digital Interface and refers the the set of things (protocols, connectors, etc) that allow digital instruments and controllers communicate with each other.įor our purpose, MIDI defines the type of controller we’ll be using and the type of values we can expect from the controller when we use it.
