MIDI

Control MIDI equipment!

Library

Import Library:

http://mbed.org/projects/cookbook/svn/MIDI/trunk

Hardware

                     gnd
                      |
                      o
tx ----[ 220R ]----o     o----[ 220R ]---- +3.3v
                  o       o

          (view from back of socket)

source:MIDI/doc/MIDI.jpg

Hello World

Press middle C for 1 second

#include "mbed.h"
#include "MIDI.h"

MIDI midi(p13, p14);
int main() {
    midi.noteon(60);
    wait(1);
    midi.noteoff(60);
}
Source Code of MIDIHelloWorld.bin (LPC1768 LPC2368)

MIDI API

MIDIA MIDI port, used for sending MIDI commands to e.g.
Functions
MIDICreate a MIDI port connected to the specified serial pins
noteonSend a Note On Message
noteoffSend a Note Off Message
pitchSend a Pitchbend Message
controllerSend a Continuous Controller Message
patchSend a Patch Change Message
class MIDI
A MIDI port, used for sending MIDI commands to e.g.
MIDI(PinName tx,
PinName rx)
Create a MIDI port connected to the specified serial pins
void noteon(int key,  
int velocity =  127,
int channel =  1)
Send a Note On Message
void noteoff(int key,  
int velocity =  127,
int channel =  1)
Send a Note Off Message
void pitch(float pitchbend,  
int channel =  1)
Send a Pitchbend Message
void controller(int controller,  
int value,  
int channel =  1)
Send a Continuous Controller Message
void patch(int instrument,  
int channel =  1)
Send a Patch Change Message

See MIDI/trunk/MIDI.h for full details

Examples

See Also

Development Notes

Some notes/links that are useful for developement of the library itself...

MIDI Message Format

Command Name Code Parameter 1 Parameter 2
Note-off 0x8<c> Key Velocity
Note-on 0x9<c> Key Veolcity
Aftertouch 0xA<c> Key Touch
Continuous controller 0xB<c> Controller Value
Patch change 0xC<c> Instrument -
Channel Pressure 0xD<c> Pressure -
Pitch bend 0xE<c> LSB (0-127) MSB (0-127)