Simple mbed 5-pin DIN to USB MIDI Converter library

Dependents:   5-PinMIDIDemo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Midi5Pin.h Source File

Midi5Pin.h

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