Basic example for send MIDI messages

Dependencies:   mbed

main.cpp

Committer:
jose_23991
Date:
2014-09-29
Revision:
0:2f27565123e1

File content as of revision 0:2f27565123e1:

#include "mbed.h"
#include "midii.h"

#define MIDI_SERIAL_TX PA_2
#define MIDI_SERIAL_RX PA_3

MIDII midi(MIDI_SERIAL_TX, MIDI_SERIAL_RX);

int main()
{
    while(1)
    {
        //Note 'D' in fifth octave on channel 1 at middle velocity (0x45)
        midi.noteOn(CH_1, D, OCTAVE_5, 0x45);
        wait(0.75);
        midi.noteOff(CH_1, D, OCTAVE_5, 0x45);
        wait(0.25);
        
        //Note 'E' in fifth octave on channel 1 at middle velocity (0x45)
        midi.noteOn(CH_1, E, OCTAVE_5, 0x45);
        wait(0.75);
        midi.noteOff(CH_1, E, OCTAVE_5, 0x45);
        wait(0.25);
        
        //Note 'G#' in fifth octave on channel 1 at middle velocity (0x45)
        midi.noteOn(CH_1, G_, OCTAVE_5, 0x45);
        wait(0.75);
        midi.noteOff(CH_1, G, OCTAVE_5, 0x45);
        wait(0.25);
        
        wait(3);
    }
}