http://www.arduino.cc/playground/Main/MIDILibrary

MIDI Library v2.5

This library enables MIDI I/O communications on the Arduino serial ports. You can send and receive messages of (almost) all kind (including System Exclusive). The purpose of this library is not to make a big synthetizer out of an Arduino board, the application remains yours.

v2.5 Features:

Improved handling of System messages (Exclusive, but also RealTime, Clock...). Now the library can read every message ! (but you will have to sort them in your sketch).

v2 Features:

The version 2 of the MIDI library greatly simplifies its use, by removing advanced options such as opto pin powering, fast mode ect..

v1 Features:

  • Sending every kind of MIDI messages (no Clock or Sync messages)
  • Reading (almost) every kind (no Clock or Sync messages)
  • OMNI input reading
  • Thru-like input mirroring
  • Fast transmission mode automatic handling (see below) on input & output
  • Input message saving
  • Optocoupler power pin handling (enable/disable hardware MIDI input)

Download the library here (with documentation)
Download the library here (without documentation)
- Update (14/12/2009): Version 2.5 released.
- Update (28/07/2009): Version 2 released.
- Update (28/03/2009): Simplified version of MIDI.begin, Fast mode is now on by default.
- Update (08/03/2009): Thru method operationnal. Added some features to enable thru.

Warning: this library requires Arduino 13 or more recent versions.

What do I need to do?

After downloading the library, unzip it to the libraries folder (arduino-00xx/hardware/libraries), then reboot the Arduino IDE or compile your sketch, it will compile the library.

Include the library using the menu in the IDE, or type #include <MIDI.h>

You are now ready to use the library. look at the reference page to learn how to use it, or the examples given. Don't forget to enable the I/O communications with MIDI.begin...

if you have any comment or notification to make, feel free to contact me at francoisbest (at) gmail (dot) com.

Reference

See the extended reference here, or download it as PDF.

A few things...

Using MIDI.begin

In the setup() function of the Arduino, you must call the MIDI.begin method. If you don't give any argument to this method, the input channel for MIDI in will be set to 1 (channels are going from 1 to 16).

This method will:

  • Start the serial port at the MIDI baudrate (31250)
  • Set the input channel at the argument given (if any, 1 else)
  • Enable the Thru, with no filtering (everything caught is sent back)

MIDI Thru

The MIDI Thru allows you to mirror your incoming messages to the MIDI output. It replaces the need of a MIDI Thru connector, as it copies every valid incoming message from the input. For good performance, you might want to call read() in a fast loop, for low latency.

Incoming unread bytes/messages are kept in the Arduino serial buffer, in order not to flood it, check regularily with MIDI.read. See the reference for Thru explanations.

Thru is default enabled, you can turn it off using appropriate methods.

Hardware

Take a look at the MIDI.org schematic


Reply via email to