-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonNote.cpp
More file actions
28 lines (24 loc) · 919 Bytes
/
ButtonNote.cpp
File metadata and controls
28 lines (24 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "ButtonNote.h"
#include "Debug.h"
ButtonNote::ButtonNote(byte pin, byte channel, byte note, byte velocity)
: ButtonBase(pin), _channel(channel), _note(note), _velocity(velocity) {}
void ButtonNote::init() {
Debug::printNameValuePair("Note Button Startup", _pin);
// Send note-off on startup to ensure clean state
midiEventPacket_t msg = {0x08, uint8_t(0x80 | _channel), _note, 0};
sendMidiMsg(msg);
}
void ButtonNote::onPress() {
Debug::printNameValuePair("Note Button Pressed", _pin);
midiEventPacket_t msg = {0x09, uint8_t(0x90 | _channel), _note, _velocity};
sendMidiMsg(msg);
//MidiUSB.sendMIDI(msg);
//MidiUSB.flush();
}
void ButtonNote::onRelease() {
Debug::printNameValuePair("Note Button Released", _pin);
midiEventPacket_t msg = {0x08, uint8_t(0x80 | _channel), _note, 0};
sendMidiMsg(msg);
//MidiUSB.sendMIDI(msg);
//MidiUSB.flush();
}