A simple 5-pin MIDI helper library.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MIDI_5Pin.h Source File

MIDI_5Pin.h

00001 /** Simple mbed 5-pin DIN to USB MIDI Converter library
00002  *  Marius Petrut, 2015
00003  */
00004 
00005 #ifndef MBED_MIDI_5PIN_H
00006 #define MBED_MIDI_5PIN_H
00007  
00008 #include "mbed.h"
00009 
00010 /** The 5-pin MIDI helper class
00011  */ 
00012 class MIDI_5Pin {
00013 public:
00014     /** Create a Midi5Pin object with the specified
00015      * transmit and receive pins
00016      *
00017      * @param txPin Transmit pin
00018      * @param rxPin Receive pin
00019      */
00020     MIDI_5Pin(PinName txPin, PinName rxPin);
00021     
00022     /** Send a command to the 5-pin output port
00023      *
00024      * @param command The MIDI command byte
00025      * @param param1 First parameter (depends on command)
00026      * @param param2 Second parameter (depends on command)
00027      */
00028     void write(char command, char param1, char param2);
00029     
00030     /** Send a noteOn MIDI message to the 5-pin output
00031      *
00032      * @param note MIDI note number
00033      * @param velocity MIDI note velocity (loudness)
00034      */
00035     void noteOn(char note, char velocity);
00036     
00037     /** Send a noteOff MIDI message to the 5-pin output
00038      *
00039      * @param note MIDI note number
00040      */
00041     void noteOff(char note);
00042     
00043     /** Send a continuous control message to the 5-pin output
00044      *
00045      * @param ccNumber The continuous control message number
00046      * @param value Value of the continuous control message
00047      */
00048     void contCtrl(char ccNumber, char value);
00049     
00050     /** Read from the 5-pin input connection and send
00051      * it to the PC through the USB virtual com port
00052      *
00053      */
00054     void read();
00055   
00056 private:  
00057     Serial _pc;
00058     Serial _uart5pin;
00059 };
00060  
00061 #endif
00062