Next: MIDI Controller Interface, Up: Function Reference [Contents][Index]
Return whether there is data available to read
dev - a octave midi device opened using mididevice.
tf - true if device has data available to read
See also: mididevice.
Create a midi device using the input parameters.
When a single device name or id is provided, attempt to create the midi device using the same name for both input and output.
Otherwise, use the name or device id for the given input or output direction.
mididev - name or id of device to load.
mididir - midi direction of "input" or "output"
midiindev - midi input name or id
midioutdev - midi output name or id
dev - octave_midi class for opened device
Input - Input device name (read only).
Output - Output device name (read only).
InputID - Input device id (read only).
OutputID - Output device id (read only).
Open midi device with ID of 0.
>
dev = mididevice(0);
mididevice connected to
input: "SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0" (1)
output: "SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0" (0)
Open a named midi device:
>
dev = mididevice("SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0");
mididevice connected to
input: "SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0" (1)
output: "SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0" (0)
See also: mididevinfo.
Retrieve the midi devices detected within the system.
The list will be stored with variable devlist as either a input or output device. If no output variable is provided, the devices will be displayed.
None
devlist - a structure containing the midi device information
Display the known devices of the system.
>
mididevinfo
MIDI devices available
ID Direction Interface Name
0 output Alsa Midi Through:Midi Through Port-0 14:0
1 output Alsa Ensoniq AudioPCI:ES1371 16:0
2 output Alsa SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0
3 input Alsa Midi Through:Midi Through Port-0 14:0
4 input Alsa Ensoniq AudioPCI:ES1371 16:0
5 input Alsa SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0
Assign variable mididevices with the values from the known devices
>
mididevices = mididevinfo
mididevices =
scalar structure containing the fields:
input =
{
[1,1] =
scalar structure containing the fields:
Name = SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0
Interface = Alsa
ID = 0
}
output =
{
[1,1] =
scalar structure containing the fields:
Name = SparkFun Pro Micro:SparkFun Pro Micro MIDI 1 20:0
Interface = Alsa
ID = 1
}
See also: mididevice.
Flush the receive buffers on a midi device
dev - midi device opened using mididevice
None
Flush a midi device
midiflush(dev);
See also: mididevice, midireceive.
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.
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.
msg - a midimsg object containing the midi data of the message
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.
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.
Attempt to receive midi messages from a midi device.
dev - a octave midi device opened using mididevice.
maxmsg - Maximum number of messages to retrieve. If not specified, the function will attempt to get all pending.
midimsg - a midimsg containing the messages retrieved from the device.
If no messages are available, midimsg will be empty.
Open device 0, and poll and display read messages
dev = mididevice(0); while true mx = midireceive(dev); if !isempty(mx) % display message mx endif endwhile
See also: mididevice, midisend.
Send a midimsg to a midi device
dev - midi device opened using mididevice
msg - a midi message class with messages to send to the midi device
If the msg isn’t a midimsg class, the input data is expected to be in same format as the inputs to a midimsg object.
None
Send a note on/off command to a opened midi device dev
midisend(dev, midimsg("note", 1, 60, 100, 2.0));
See also: midimsg, mididevice, midireceive.
Next: MIDI Controller Interface, Up: Function Reference [Contents][Index]