From 6939254e2c75c39d80c9f1413305123871425396 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 12 Aug 2016 22:51:59 +0200 Subject: Implement midi commands for MIDIUSB on arduino --- arduino/Laserharfe/Laserharfe.ino | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'arduino/Laserharfe') diff --git a/arduino/Laserharfe/Laserharfe.ino b/arduino/Laserharfe/Laserharfe.ino index 8ad5f56..9f0d025 100644 --- a/arduino/Laserharfe/Laserharfe.ino +++ b/arduino/Laserharfe/Laserharfe.ino @@ -200,6 +200,25 @@ void handle_midi(char *command) { // MidiUSB.flush(); } +void midi_playnote(int channel, int note, int octave_offset ) { + midi_pitchbend(channel, 0); + midiEventPacket_t p = { 0x9, 0x90 | channel, note + 12 * octave_offset, 0x7f }; + MidiUSB.sendMIDI(p); +} + +void midi_silencenote( int channel, int note, int octave_offset ) { + midiEventPacket_t p = { 0x8, 0x80 | channel, note + 12 * octave_offset, 0x7f }; + MidiUSB.sendMIDI(p); +} + +void midi_pitchbend( int channel, int pitch ) { + pitch += 8192; + if (pitch < 0) pitch = 0; + if (pitch > 16383) pitch = 16383, + midiEventPacket_t p = { 0xe, 0xe0 | channel, 0x7f & pitch, 0x7f & (pitch>>7) }; + MidiUSB.sendMIDI(p); +} + void handle_configure(char *command) { } -- cgit v1.2.3