MIDI Communication

class pico_synth_sandbox.midi.Midi(board)[source]

Bases: Task

Send and receive both hardware UART and USB MIDI messages using adafruit_midi.MIDI. UART can be enabled with the MIDI_UART variable and USB can be enabled with the MIDI_USB variable in settings.toml. The midi channel is limited to a single value for both input and output and is determined by the MIDI_CHANNEL variable in settings.toml with a range of 0-15. However, the channel can be changed once a pico_synth_sandbox.midi.Midi object is created by calling the set_channel function. By default, the onboard led will be used to indicate incoming midi messages. At the moment, this feature cannot be disabled.

send_control_change(control, value, channel=None)[source]

Send an adafruit_midi.control_change.ControlChange message through the enabled midi outputs.

Parameters:
  • control (int) – The number of the midi control to send.

  • value (float) – The value to set of the desired control from 0.0 through 1.0.

  • channel (int) – The midi channel to transmit the message on.

send_message(msg)[source]

Send an adafruit_midi.midi_message.MIDIMessage message through the enabled midi outputs.

Parameters:

msg (adafruit_midi.midi_message.MIDIMessage) – The message you would like to trasmit

send_note_off(notenum, channel=None)[source]

Send an adafruit_midi.note_off.NoteOff message through the enabled midi outputs.

Parameters:
  • notenum (int) – The value of the midi note to send.

  • channel (int) – The midi channel to transmit the message on.

send_note_on(notenum, velocity=1.0, channel=None)[source]

Send an adafruit_midi.note_on.NoteOn message through the enabled midi outputs.

Parameters:
  • notenum (int) – The value of the midi note to send.

  • velocity (float) – The velocity of the note from 0.0 through 1.0.

  • channel (int) – The midi channel to transmit the message on.

send_program_change(patch, channel=None)[source]

Send an adafruit_midi.program_change.ProgramChange message through the enabled midi outputs.

Parameters:
  • patch (int) – The program/patch you would like to change to from 0 through 127.

  • channel (int) – The midi channel to transmit the message on.

set_channel(value)[source]

Set the midi channel for messages to be received and sent from.

Parameters:

value (int) – The desired channel from 0 to 16. 0 will accept all midi messages.

set_control_change(callback)[source]

Set the callback method you would like to be called when a adafruit_midi.control_change.ControlChange message is received.

Parameters:

callback (function) – The callback method. Must have 2 parameters for control number and control value (0.0-1.0). Ie: def control_change(control, value):.

set_note_off(callback)[source]

Set the callback method you would like to be called when a adafruit_midi.note_off.NoteOff message is received.

Parameters:

callback (function) – The callback method. Must have 1 parameter for the note value. Ie: def note_off(notenum):.

set_note_on(callback)[source]

Set the callback method you would like to be called when a adafruit_midi.note_on.NoteOn message is received.

Parameters:

callback (function) – The callback method. Must have 2 parameters for note value and velocity (0.0-1.0). Ie: def note_on(notenum, velocity):.

set_pitch_bend(callback)[source]

Set the callback method you would like to be called when a adafruit_midi.pitch_bend.PitchBend message is received.

Parameters:

callback (function) – The callback method. Must have 1 parameter for the pitch bend value (-1.0-1.0). Ie: def pitch_bend(value):.

set_program_change(callback)[source]

Set the callback method you would like to be called when a adafruit_midi.program_change.ProgramChange message is received.

Parameters:

callback (function) – The callback method. Must have 1 parameter for the patch number requested. Ie: def program_change(patch):.

set_thru(value)[source]

Set whether you would like to forward incoming midi messages through the enabled outputs automatically.

Parameters:

value (bool) – Whether or not you would like to enable midi thru.

async update()[source]

Process any incoming midi messages from the enabled midi devices. Will trigger any pre-defined callbacks if the appropriate messages are received.