Basic example for send MIDI messages

Dependencies:   mbed

Committer:
jose_23991
Date:
Mon Sep 29 15:45:18 2014 +0000
Revision:
0:2f27565123e1
Version 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jose_23991 0:2f27565123e1 1 #include "mbed.h"
jose_23991 0:2f27565123e1 2 #include "midii.h"
jose_23991 0:2f27565123e1 3
jose_23991 0:2f27565123e1 4 #define MIDI_SERIAL_TX PA_2
jose_23991 0:2f27565123e1 5 #define MIDI_SERIAL_RX PA_3
jose_23991 0:2f27565123e1 6
jose_23991 0:2f27565123e1 7 MIDII midi(MIDI_SERIAL_TX, MIDI_SERIAL_RX);
jose_23991 0:2f27565123e1 8
jose_23991 0:2f27565123e1 9 int main()
jose_23991 0:2f27565123e1 10 {
jose_23991 0:2f27565123e1 11 while(1)
jose_23991 0:2f27565123e1 12 {
jose_23991 0:2f27565123e1 13 //Note 'D' in fifth octave on channel 1 at middle velocity (0x45)
jose_23991 0:2f27565123e1 14 midi.noteOn(CH_1, D, OCTAVE_5, 0x45);
jose_23991 0:2f27565123e1 15 wait(0.75);
jose_23991 0:2f27565123e1 16 midi.noteOff(CH_1, D, OCTAVE_5, 0x45);
jose_23991 0:2f27565123e1 17 wait(0.25);
jose_23991 0:2f27565123e1 18
jose_23991 0:2f27565123e1 19 //Note 'E' in fifth octave on channel 1 at middle velocity (0x45)
jose_23991 0:2f27565123e1 20 midi.noteOn(CH_1, E, OCTAVE_5, 0x45);
jose_23991 0:2f27565123e1 21 wait(0.75);
jose_23991 0:2f27565123e1 22 midi.noteOff(CH_1, E, OCTAVE_5, 0x45);
jose_23991 0:2f27565123e1 23 wait(0.25);
jose_23991 0:2f27565123e1 24
jose_23991 0:2f27565123e1 25 //Note 'G#' in fifth octave on channel 1 at middle velocity (0x45)
jose_23991 0:2f27565123e1 26 midi.noteOn(CH_1, G_, OCTAVE_5, 0x45);
jose_23991 0:2f27565123e1 27 wait(0.75);
jose_23991 0:2f27565123e1 28 midi.noteOff(CH_1, G, OCTAVE_5, 0x45);
jose_23991 0:2f27565123e1 29 wait(0.25);
jose_23991 0:2f27565123e1 30
jose_23991 0:2f27565123e1 31 wait(3);
jose_23991 0:2f27565123e1 32 }
jose_23991 0:2f27565123e1 33 }
jose_23991 0:2f27565123e1 34