Audio Toolkit - midimsg


: msg = midimsg (0)
: msg = midimsg (type ....)
: msg = midimsg ("note", channel, note, velocity, duration, timestamp)
: msg = midimsg ("noteon", channel, note, velocity, timestamp)
: msg = midimsg ("noteoff", channel, note, velocity, timestamp)
: msg = midimsg ("programchange", channel, prog, timestamp)
: msg = midimsg ("controlchange", channel, ccnum, ccval, timestamp)
: msg = midimsg ("polykeypressure", channel, note, keypressure, timestamp)
: msg = midimsg ("channelpressure", channel, chanpressure, timestamp)
: msg = midimsg ("localcontrol", channel, localcontrol, timestamp)
: msg = midimsg ("pitchbend", channel, pitchchange, timestamp)
: msg = midimsg ("polyon", channel, timestamp)
: msg = midimsg ("monoon", channel, monochannels, timestamp)
: msg = midimsg ("omnion", channel, timestamp)
: msg = midimsg ("omnioff", channel, timestamp)
: msg = midimsg ("allsoundoff", channel, timestamp)
: msg = midimsg ("allnotesoff", channel, timestamp)
: msg = midimsg ("resetallcontrollers", channel, timestamp)
: msg = midimsg ("start", timestamp)
: msg = midimsg ("stop", timestamp)
: msg = midimsg ("continue", timestamp)
: msg = midimsg ("systemreset", timestamp)
: msg = midimsg ("activesensing", timestamp)
: msg = midimsg ("timingclock", timestamp)
: msg = midimsg ("systemexclusive", timestamp)
: msg = midimsg ("systemexclusive", bytes, timestamp)
: msg = midimsg ("eox", timestamp)
: msg = midimsg ("data", bytes, timestamp)
: msg = midimsg ("songselect", song, timestamp)
: msg = midimsg ("songpositionpointer", songposition, timestamp)
: msg = midimsg ("tunerequest", timestamp)
: msg = midimsg ("miditimecodequarterframe", timeseq, timevalue, timestamp)

Create a midimsg object

If the input parameter is 0, create an empty midi message object Otherwise the first variable is the type of message to create, followed by the additional parameters for the message.

For each message type, the timestamp value is optional.

Inputs

type - string message type or a midimsgtype.
timestamp - optional seconds time stamp for the event
channel - the channel to use for the message (1..16)
note - the value of the note to play/stop
velocity - the velocity value for a note on/off, with 0 stopping a note from sounding.
duration - seconds between starting and stopping a note when created a ’note’ message.
prog - program number when doing a program change message.
ccnum - control change control number.
ccval - control change control value.
keypressure - key pressure value when creating a key pressure message.
chanpressure - channel pressure value when creating a channelpressure message.
pitchchange - pitch change value when creating a pitch bend message.
localcontrol - boolean value when creating a localcontrol message.
monochannels - channels specified for a mono on message.
bytes - array of data in range of 0 to 127 specified as part of a data message or system exclusive message.
song - song selection number for a song selection message.
songposition - song position value for a song position message.
timeseq - timecode sequence number for a miditimecodequarterframe message.
timevalue - timecode value number for a miditimecodequarterframe message.

Outputs

msg - a midimsg object containing the midi data of the message

Properties

timestamp - timestamp of the message, or an array or timestamps if the the message is a compound message.
msgbytes - the raw message bytes that make up the MIDI message.
nummsgbytes - the number of message bytes that make up the MIDI message.
type - string or midimsgtype that represents the message type.
channel - the channel number for message.
note - the note value for message (Only valid for noteon/off and polykeypressure).
velocity - the velocity value for message (Only valid for noteon/off).
keypressure - the keypressure value for message (Only valid for polykeypressure).
channelpressure - the chanpressure value for message (Only valid for channelpressure).
localcontrol - the localcontrol value for message (Only valid for localcontrol messages).
monochannels - channels specified for a mono on message.
program - program number specified for a program change message.
ccnumber - control change number specified for a control change message.
ccvalue - control change value specified for a control change message.
song - song number for a song selection message.
songposition - song position value for a song position message.
pitchchange - pitch change value for a pitch bend message.
timecodesequence - timecode sequence number for a miditimecodequarterframe message.
timecodevalue - timecode value number for a miditimecodequarterframe message.

Examples

Create a note on/off pair with a duration of 1.5 seconds

 msg = midimsg('note', 1, 60, 100, 1.5)
 

Create a separate note on/off pair with a time between them of 1.5 seconds

 msg = [midimsg('noteon', 1, 60, 100, 0), midimsg('noteoff', 1, 60, 0, 1.5)]
 

Create a system reset message

 msg = midimsg('systemreset')
 

See also: midifileread, midisend, midireceive, midimsgtype.