I have built a sequencer, but I have trouble making the all notes off message work as intended when it stops. What happens is that i get hanging notes after the sequencer stops. Not sure where I fail.
The gist of my code is that whenever I stop my sequencer, the allChannelsAllNotesOff() function is called. I've triple checked the midi command value for the all notes off message... All the other messages are working as expected. Happy if someone could look at my code!
The gist of my code is that whenever I stop my sequencer, the allChannelsAllNotesOff() function is called. I've triple checked the midi command value for the all notes off message... All the other messages are working as expected. Happy if someone could look at my code!
Code:
[B]MIDI.cpp[/B]
void MIDI::noteOff(const uint8_t voiceNumber) {
using namespace constants;
Serial1.write(MIDInoteOff + voiceNumber);
Serial1.write(m_previousMIDINote[voiceNumber]);
Serial1.write(0);
}
void MIDI::allNotesOff(const uint8_t voiceNumber) {
using namespace constants;
Serial1.write(MIDIchannel + voiceNumber); // Channel CC message
Serial1.write(MIDIallNotesOff);
Serial1.write(0);
}
void MIDI::allChannelsAllNotesOff() {
using namespace constants;
for (uint8_t voiceNumber = voice1; voiceNumber <= voice4; ++voiceNumber) {
allNotesOff(voiceNumber);
}
}
[B]Constants.h[/B]
constexpr uint8_t MIDIstart = 0xFA; // 250
constexpr uint8_t MIDIstop = 0xFC; // 252
constexpr uint8_t MIDInoteOn = 0x90; // 144
constexpr uint8_t MIDInoteOff = 0x80; // 128
constexpr uint8_t MIDIchannel = 0xB0; // 176
constexpr uint8_t MIDIallNotesOff = 0x7B; // 123
enum voiceNumbers {
voice1,
voice2,
voice3,
voice4,
allVoices
};