Simple mbed 5-pin DIN to USB MIDI Converter library
Midi5Pin.h@6:08234a5a8598, 2015-10-22 (annotated)
- Committer:
- mpetrut
- Date:
- Thu Oct 22 16:58:11 2015 +0000
- Revision:
- 6:08234a5a8598
- Parent:
- 5:cd6f744d5def
No docs;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mpetrut | 3:b258cf76ee4f | 1 | /** Simple mbed 5-pin DIN to USB MIDI Converter library |
mpetrut | 5:cd6f744d5def | 2 | * Marius Petrut, 2015 |
mpetrut | 3:b258cf76ee4f | 3 | */ |
mpetrut | 0:722bbb69c79d | 4 | |
mpetrut | 0:722bbb69c79d | 5 | #ifndef MBED_MIDI5PIN_H |
mpetrut | 0:722bbb69c79d | 6 | #define MBED_MIDI5PIN_H |
mpetrut | 0:722bbb69c79d | 7 | |
mpetrut | 0:722bbb69c79d | 8 | #include "mbed.h" |
mpetrut | 6:08234a5a8598 | 9 | /** The 5-pin MIDI helper class |
mpetrut | 6:08234a5a8598 | 10 | */ |
mpetrut | 0:722bbb69c79d | 11 | class Midi5Pin { |
mpetrut | 0:722bbb69c79d | 12 | public: |
mpetrut | 2:b36bd99c6755 | 13 | /** Create a Midi5Pin object with the specified |
mpetrut | 2:b36bd99c6755 | 14 | * transmit and receive pins |
mpetrut | 2:b36bd99c6755 | 15 | * |
mpetrut | 2:b36bd99c6755 | 16 | * @param txPin Transmit pin |
mpetrut | 2:b36bd99c6755 | 17 | * @param rxPin Receive pin |
mpetrut | 2:b36bd99c6755 | 18 | */ |
mpetrut | 0:722bbb69c79d | 19 | Midi5Pin(PinName txPin, PinName rxPin); |
mpetrut | 0:722bbb69c79d | 20 | |
mpetrut | 2:b36bd99c6755 | 21 | /** Send a command to the 5-pin output port |
mpetrut | 2:b36bd99c6755 | 22 | * |
mpetrut | 2:b36bd99c6755 | 23 | * @param command The MIDI command byte |
mpetrut | 2:b36bd99c6755 | 24 | * @param param1 First parameter (depends on command) |
mpetrut | 2:b36bd99c6755 | 25 | * @param param2 Second parameter (depends on command) |
mpetrut | 2:b36bd99c6755 | 26 | */ |
mpetrut | 0:722bbb69c79d | 27 | void write(char command, char param1, char param2); |
mpetrut | 0:722bbb69c79d | 28 | |
mpetrut | 2:b36bd99c6755 | 29 | /** Send a noteOn MIDI message to the 5-pin output |
mpetrut | 2:b36bd99c6755 | 30 | * |
mpetrut | 2:b36bd99c6755 | 31 | * @param note MIDI note number |
mpetrut | 2:b36bd99c6755 | 32 | * @param velocity MIDI note velocity (loudness) |
mpetrut | 2:b36bd99c6755 | 33 | */ |
mpetrut | 0:722bbb69c79d | 34 | void noteOn(char note, char velocity); |
mpetrut | 0:722bbb69c79d | 35 | |
mpetrut | 2:b36bd99c6755 | 36 | /** Send a noteOff MIDI message to the 5-pin output |
mpetrut | 2:b36bd99c6755 | 37 | * |
mpetrut | 2:b36bd99c6755 | 38 | * @param note MIDI note number |
mpetrut | 2:b36bd99c6755 | 39 | */ |
mpetrut | 0:722bbb69c79d | 40 | void noteOff(char note); |
mpetrut | 0:722bbb69c79d | 41 | |
mpetrut | 2:b36bd99c6755 | 42 | /** Send a continuous control message to the 5-pin output |
mpetrut | 2:b36bd99c6755 | 43 | * |
mpetrut | 2:b36bd99c6755 | 44 | * @param ccNumber The continuous control message number |
mpetrut | 2:b36bd99c6755 | 45 | * @param value Value of the continuous control message |
mpetrut | 2:b36bd99c6755 | 46 | */ |
mpetrut | 0:722bbb69c79d | 47 | void contCtrl(char ccNumber, char value); |
mpetrut | 0:722bbb69c79d | 48 | |
mpetrut | 2:b36bd99c6755 | 49 | /** Read from the 5-pin input connection and send |
mpetrut | 2:b36bd99c6755 | 50 | * it to the PC through the USB virtual com port |
mpetrut | 2:b36bd99c6755 | 51 | * |
mpetrut | 2:b36bd99c6755 | 52 | */ |
mpetrut | 0:722bbb69c79d | 53 | void read(); |
mpetrut | 0:722bbb69c79d | 54 | |
mpetrut | 0:722bbb69c79d | 55 | private: |
mpetrut | 0:722bbb69c79d | 56 | Serial _pc; |
mpetrut | 0:722bbb69c79d | 57 | Serial _uart5pin; |
mpetrut | 0:722bbb69c79d | 58 | }; |
mpetrut | 0:722bbb69c79d | 59 | |
mpetrut | 0:722bbb69c79d | 60 | #endif |
mpetrut | 0:722bbb69c79d | 61 |