Send MIDI message to MIDI device



midisend(device,msg) sends the MIDI message, msg, to a MIDI device using the MIDI device interface, device.


midisend(device,varargin) creates MIDI messages using varargin and then sends the MIDI messages. The varargin syntax is for convenience and includes a call to midimsg with the call to midisend.


collapse all

Query your system for available MIDI device output ports. Use the availableDevices struct to specify a valid MIDI device and create a mididevice object.

availableDevices = mididevinfo;
device = mididevice(availableDevices.output(2).ID);

Create a pair of NoteOn messages (to indicate Note On and Note Off) and send them to your selected MIDI device.

msgs = midimsg('Note',1,48,64,0.25);

midisend enables you to combine the definition and sending of a midimsg into a single function call. Send middle C on channel 3 with velocity 64.

  MIDI devices available:
  ID  Direction  Interface   Name
   0   output    MMSystem   'Microsoft MIDI Mapper'
   1    input    MMSystem   'nanoKONTROL2'
   2    input    MMSystem   'USB Uno MIDI Interface'
   3   output    MMSystem   'Microsoft GS Wavetable Synth'
   4   output    MMSystem   'nanoKONTROL2'
   5   output    MMSystem   'USB Uno MIDI Interface'
device = mididevice('USB Uno MIDI Interface')
device = 
  mididevice connected to
     Input: 'USB Uno MIDI Interface' (2)
    Output: 'USB Uno MIDI Interface' (5)

Input Arguments

collapse all

Specify device as an object created by mididevice.

Specify msg as an object created by midimsg.

Specify varargin as a valid combination of arguments that can construct a MIDI message. See midimsg for a description of valid arguments.

Introduced in R2018a