adafruit_midi
A CircuitPython helper for encoding/decoding MIDI packets over a MIDI or UART connection.
Author(s): Limor Fried, Kevin J. Walters
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
MIDI helper class. midi_in
or midi_out
must be set or both together.
midi_in – an object which implements read(length)
, set to usb_midi.ports[0]
for USB MIDI, default None.
midi_out – an object which implements write(buffer, length)
, set to usb_midi.ports[1]
for USB MIDI, default None.
in_channel – The input channel(s). This is used by receive
to filter data. This can either be an int
for the wire protocol channel number (0-15) a tuple of int
to listen for multiple channels. Defaults to all channels.
out_channel (int) – The wire protocol output channel number (0-15) used by send
if no channel is specified, defaults to 0 (MIDI Channel 1).
in_buf_size (int) – Maximum size of input buffer in bytes, default 30.
debug (bool) – Debug mode, default False.
The incoming MIDI channel. Must be 0-15. Correlates to MIDI channels 1-16, e.g. in_channel = 3
will listen on MIDI channel 4. Can also listen on multiple channels, e.g. in_channel = (0,1,2)
will listen on MIDI channels 1-3. Default is all channels.
The outgoing MIDI channel. Must be 0-15. Correlates to MIDI channels 1-16, e.g. out_channel = 3
will send to MIDI channel 4. Default is 0 (MIDI channel 1).
Read messages from MIDI port, store them in internal read buffer, then parse that data and return the first MIDI message (event). This maintains the blocking characteristics of the midi_in port.
Returns object or None for nothing.
Sends a MIDI message.
msg – Either a MIDIMessage object or a sequence (list) of MIDIMessage objects. The channel property will be updated as a side-effect of sending message(s).
channel (int) – Channel number, if not set the out_channel
will be used.
adafruit_midi.active_sensing
Active Sensing MIDI message.
Author(s): Matthew Badeau
Active Sensing MIDI message.
Active Sensing message is a keepalive message sent every 300 milliseconds to tell the bus that the session is still good and alive.
adafruit_midi.channel_pressure
Channel Pressure MIDI message.
Author(s): Kevin J. Walters
Channel Pressure MIDI message.
pressure (int) – The pressure, 0-127.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
adafruit_midi.control_change
Control Change MIDI message.
Author(s): Kevin J. Walters
Control Change MIDI message.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
adafruit_midi.control_change_values
Definition for standard MIDI control change values.
Author(s): Mark Komus
adafruit_midi.midi_continue
Continue MIDI message.
Author(s): Mark Komus
Continue MIDI message.
adafruit_midi.midi_message
An abstract class for objects which represent MIDI messages (events). When individual messages are imported they register themselves with :func:register_message_type which makes them recognised by the parser, :func:from_message_bytes.
Large messages like :class:SystemExclusive can only be parsed if they fit within the input buffer in :class:MIDI.
Author(s): Kevin J. Walters
A bad MIDI message, one that could not be parsed/constructed.
This could be due to status bytes appearing where data bytes are expected. The channel property will not be set.
The parent class for MIDI messages.
Class variables:
_STATUS
- extracted from status byte with channel replaced by 0s (high bit is always set by convention).
_STATUSMASK
- mask used to compared a status byte with_STATUS
value.
LENGTH
- length for a fixed size message including status or -1 for variable length.
CHANNELMASK
- mask used to apply a (wire protocol) channel number.
ENDSTATUS
- the end of message status byte, only set for variable length.
This is an abstract class.
The channel number of the MIDI message where appropriate. This is updated by MIDI.send() method.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
Create an appropriate object of the correct class for the first message found in some MIDI bytes filtered by channel_in.
Returns (messageobject, endplusone, skipped) or for no messages, partial messages or messages for other channels (None, endplusone, skipped).
Register a new message by its status value and mask. This is called automagically at import
time for each message.
An unknown MIDI message.
status (int) – The MIDI status number.
This can either occur because there is no class representing the message or because it is not imported.
Utility function to return True iff the given channel matches channel_spec.
If note is a string then it will be parsed and converted to a MIDI note (key) number, e.g. “C4” will return 60, “C#4” will return 61. If note is not a string it will simply be returned.
note – Either 0-127 int or a str representing the note, e.g. “C#4”
adafruit_midi.mtc_quarter_frame
MIDI Time Code (MTC) Quarter Frame message.
Author(s): Raphaël Doursenaud
Based upon the official MMA0001 / RP004 / RP008 v4.2.1 MIDI Time Code Specification
MIDI Time Code (MTC) Quarter Frame message.
msgtype –
The quarter frame message type:
Frame count LS nibble
Frame count MS nibble
Seconds count LS nibble
Seconds count MS nibble
Minutes count LS nibble
Minutes count MS nibble
Hours count LS nibble
Hours count MS nibble and SMPTE Type
value – The quarter frame value for the specified type.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
adafruit_midi.note_off
Note Off Change MIDI message.
Author(s): Kevin J. Walters
Note Off Change MIDI message.
note – The note (key) number either as an int
(0-127) or a str
which is parsed, e.g. “C4” (middle C) is 60, “A4” is 69.
velocity (int) – The release velocity, 0-127, defaults to 0.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
Key, either int (0-127) or string that will be turned off
Release velocity, int (0-127)
adafruit_midi.note_on
Note On Change MIDI message.
Author(s): Kevin J. Walters
Note On Change MIDI message.
note – The note (key) number either as an int
(0-127) or a str
which is parsed, e.g. “C4” (middle C) is 60, “A4” is 69.
velocity (int) – The strike velocity, 0-127, 0 is equivalent to a Note Off, defaults to 127.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
Key, either int (0-127) or string that will be turned on
Strike velocity, int (0-127); 0 is equivalent to Note Off
adafruit_midi.pitch_bend
Pitch Bend Change MIDI message.
Author(s): Kevin J. Walters
Pitch Bend Change MIDI message.
pitch_bend (int) – A 14bit unsigned int representing the degree of bend from 0 through 8192 (midpoint, no bend) to 16383.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
adafruit_midi.polyphonic_key_pressure
Polyphonic Key Pressure MIDI message.
Author(s): Kevin J. Walters
Polyphonic Key Pressure MIDI message.
note – The note (key) number either as an int
(0-127) or a str
which is parsed, e.g. “C4” (middle C) is 60, “A4” is 69.
pressure (int) – The pressure, 0-127.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
adafruit_midi.program_change
Program Change MIDI message.
Author(s): Kevin J. Walters
Program Change MIDI message.
patch (int) – The new program/patch number to use, 0-127.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
adafruit_midi.start
Start MIDI message.
Author(s): Kevin J. Walters
Start MIDI message.
adafruit_midi.stop
Stop MIDI message.
Author(s): Kevin J. Walters
Stop MIDI message.
adafruit_midi.system_exclusive
System Exclusive MIDI message.
Author(s): Kevin J. Walters
System Exclusive MIDI message.
This message can only be parsed if it fits within the input buffer in :class:MIDI.
Creates an object from the byte stream of the wire protocol representation of the MIDI message.
adafruit_midi.timing_clock
Timing Clock MIDI message.
Author(s): Kevin J. Walters
Timing Clock MIDI message.
This occurs 24 times per quarter note when synchronization is in use. If this is not needed it’s best to avoid this sending this high frequency message to a CircuitPython device to reduce the amount of message processing.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4