Marius Petrut / MIDI_5Pin
Committer:
mpetrut
Date:
Thu Oct 22 17:15:51 2015 +0000
Revision:
0:a6b78fdc6619
Initial commit;

Who changed what in which revision?

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