Possible bug in MIDIpal code

Hello,

I have noticed with my own build that the output of notenuke was not correct.
I asked an original MIDIpal user to test this for me and it appears that it suffers from the bug as well.

Some bytes are either lost or triggered twice.

I think the problem is in FlushOutputBuffer() function.
I think (kinda sure in fact) that the midi_out.Write() call conflicts with the TIMER2 ISR.

There are a few ways to solve this but I think this one is the best:.
Here is my updated function:

void App::FlushOutputBuffer(uint8_t requested_size) {
while (MidiHandler::OutputBuffer::writable() < requested_size) {
display.set_status(’!’);
//midi_out.Write(MidiHandler::OutputBuffer::Read());
}
}

I just remove the midi_out.Write() and let the ISR do its job.
The drawback may be the ISR speed, but @ 4kHz I don’t think we lower the bandwidth.

@pichenettes : what do you think? as long as the Timer2 ISR is working this should be fine

Cheers,
Samuel.

Should work, yes.

It definitely solves the notenuke bug.
I don’t think this affects other apps, all seems well, and there are no real reasons to stop the Timer2 ISR anyway…