File Exchange

image thumbnail

MIDI Interface for MATLAB

version 1.2.0.1 (16.9 KB) by Tucker McClure
Supports bringing incoming MIDI data into MATLAB on Windows.

1 Download

Updated 01 Sep 2016

View License

This simple interface allows MATLAB to read incoming MIDI data from a MIDI device or another MIDI program. For instance, if a MIDI keyboard is connected to the computer running MATLAB, this interface could be used to see what keys the user is playing, what knobs he's twisting, what pedals he has down, etc.
% Open an interface; the tool will prompt to select a device.
midi_interface('open');

% Play some notes on a connected keyboard or wiggle some knobs on a MIDI controller.

% Read all the new MIDI messages.
messages = midi_interface();

% Close the device.
midi_interface('close');

This currently only works on Windows (32/64-bit) and only supports one MIDI device at a time. If this tool proves useful for people, we could take it further, so just let me know!

Early beta.

Comments and Ratings (5)

Hi Sima H,

The messages this tool outputs use a standard MIDI format consisting of several integers per "message". You can read about their meanings online; a simple search for "MIDI messages" ought to do it. Also, a few of the most basic messages (note on/off and velocity) are covered as part of the MidiDemo.m in the Real-Time Audio Processor, available here:

http://www.mathworks.com/matlabcentral/fileexchange/37770-real-time-audio-processor/all_files

- Tucker

Sima H

Hi. I wonder if you give me a brief explanation about the massages.
Thanks

Dace

Sorry, had a problem with the cable. Now working. Great code, very helpful. Thanks!

Dace

I wonder, why do I always get an empty messages matrix?

I open the interface, select the device, play some notes on the keyboard and execute messages = midi_interface() which always returns an empty matrix.

very helpful! thank you!

Updates

1.2.0.1

Updated license

1.2.0.0

The output timestamps of the MIDI data were wrong and aren't any more. (Thanks Janne.)

1.1.0.0

Updated copyright information.

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux