Department of Music

The new pages for Faculty of Humanities are available at from 3.1.2017

Midi Toolbox

The MIDI Toolbox is a compilation of functions for analyzing and visualizing MIDI files in the Matlab computing environment. Besides simple manipulation and filtering functions, the toolbox contains cognitively inspired analytic techniques that are suitable for context-dependent musical analysis that deal with such topics as melodic contour, similarity, key-finding, meter-finding and segmentation.

The Toolbox is available free of charge under the GNU General Public License. The toolbox runs under Matlab 6 and 7.4 (For Windows and Mac OS X (also Intel processors), also Matlab 5.3 to 7.4 for Windows works fine.). The current version of the Toolbox is 1.0.1 (released 24th Jan 2006).

» Authors

Petri Toiviainen (Professor) and Tuomas Eerola (Senior assistant) are employed at the Department of Music of the University of Jyväskylä, Finland. Both are members of the Music Cognition Team, which investigates various issues relating to music cognition. If you have any comments or problems to report, please contact the authors (firstname.lastname at


» Download

The avoid platform dependent problems when extracting the files within the distribution package, the Toolbox is available either as a zipped archive (for Windows and Linux) or as a Disc Image for Macintosh. When extracting the archive, make sure that the directory structure within the archive is retained. There should be private subdirectory under the MIDI Toolbox root.

12 years after the first release of MIDI toolbox 1.0, we surprised ourselves by correcting the read and write problems related to MIDI in the toolbox and updated some other functions as well. Version 1.1 now handles tempo changes, and should work on any Matlab and operating system without problems. The code, history, examples, and manual are available at:


» Documentation

The documentation provides a description of the Toolbox (Chapter 1), installation and system requirements (Chapter 2). Basic issues are explained in Chapter 3. Chapter 4 demonstrates the Toolbox functions using various examples and Chapter 5 constitutes the function reference section.


To cite the MIDI Toolbox, use the following reference to the User's Manual (downloadable from this page, see below):

  • APA entry:
    Eerola, T. & Toiviainen, P. (2004). MIDI Toolbox: MATLAB Tools for Music Research. University of Jyväskylä: Kopijyvä, Jyväskylä, Finland. Available at
  • Bibtex entry:
       Address = {Jyv{\"a}skyl{\"a}, Finland},
       Author = {Eerola, Tuomas and Toiviainen, Petri},
       Publisher = {University of Jyv{\"a}skyl{\"a}},
       Title = {MIDI Toolbox: MATLAB Tools for Music Research},
       Url = {},
       Year = {2004}}

» Installation

Unpack the MIDI Toolbox file package you have downloaded. This will create a directory called miditoolbox_<operating_system>. Secondly, a version of the Matlab program needs to be installed (see Thirdly, the Toolbox needs to be defined in the Matlab path variable. Under the File menu, select Set Path. Under the Path menu, select Add to Path. Write here the name of the directory where this toolbox has been installed. Then click OK. Finally, under the File menu, select Save Path, and then Exit.

» Compatibility

  • Windows (98, 2000, XP): The MIDI Toolbox version 1.0.1 is compatible with Matlab 5.3. to Matlab 7.3. There seems to be mex incompatibility with PC Matlab 7.4 version. For that, see the No mex extension below.
  • Macintosh (OS X): The MIDI Toolbox version 1.0.1 is compatible with Matlab 6.5 and 7.4 for Macintosh. Intel version available.
  • Linux: Currently not tested but should be compatible.

» Extensions

Matching Performance to Notation

Author: Ed Large, Associate Professor of Complex Systems and Brain Sciences, Florida Atlantic University

Sometimes an analysis of music performance requires matching a performance to its corresponding notation, or score. This extension provides a function, dynamicMatch.m to perform this task. The matcher utilizes dynamic programming techniques, runs in polynomial time and is fully described in (Large, 1993). The algorithm for this task was developed in the context of a study of music production errors (Palmer & van de Sande, 1993). The dynamic programming algorithm finds an optimal match between the two sequences, given a scoring function that is hard coded into the program. Examples and full documentation is also provided.

Download (includes documentation and examples):

No mex extension

Author: Tuomas Eerola

Recent PC version of the Matlab (7.4) seems to be imcompatible with the C-function/mex file (read and write midi files) so versions of the nmat2midi and midi2nmat that do not rely on mex-files is released here. These files are simple and primitive and are partly based on code developed by Ken Schutte (see Further improvements are welcome.

Download: nmat2midi.m and midi2nmat.m


» FAQ - Frequently Asked Questions

Is toolbox available for Octave?

Not as such, although many of the functions are compatible with Octave. The main problems relate to mex files (compiled gateways for handling C program files), which will not function in Octave. One workaround is to use matlab routines for MIDI file reading so the use of compiled files is not necessary. We haven not developed this as the quite often result in slow performance for large files. Technically these are straightforward. For example, Giovanni De Poli and his students created an installer for Octave / Cygwin ( and Nicola Orio has provided C source for reading midi files into matlab (

If you need to compile the mex files, you can download the mf2t and t2mf

C source and mex files. If you are developing a version for Octave, please let us know.

laksin.mid can’t be found!

Have you defined the path of the MIDI toolbox and are you sure you are currently within a folder that contains laksin.mid?

Reading/Writing MIDI file errors

The only routines that are operating system specific are the reading and writing midi files. These use the C source (author) and mex files, which need to be compiled for each operating system separately. There are also differences between different versions of the Matlab. The files in question are mf2t and t2mf and the function that calls them is readmidi and writemidi. Currently the compiled versions exists for the following operating systems and Matlab versions: Windows and Matlab 5.3 to Matlab 7.1 (higher version of the Matlab should also work). Mac OS X pre intel and Intel processors (different distributions) and Linux (less support, but it is known to work).

A 1.2 (beta) exists where the mex files are replaced with m-files. See No Mex extension.

How to analyze the X musical feature…

We have not though of all possibilities in the analysis procedures that could be carried out and we have very limited possibilities for developing new routines for inquiries.

How is tempo represented in toolbox?

At this point, we do not have tempo curve representation in MIDI toolbox and hence all events are represented as durations (in seconds and beats, see Manual for more details).

The readmidi command in the MIDI toolbox does not take into account tempo commands. An extension written by Christine Smit that handles tempo changes correctly can be downloaded here:

Can I change the instrument definition of the MIDI files that I create

Reading/Writing functions do not support Control Change, Program Change or System Exclusive commands.