Fix clock latency: process one USB packet per update() — no more batch-processing 0xF8 bursts
This commit is contained in:
@@ -50,7 +50,7 @@ void UsbMidiTransport::update() {
|
||||
TinyUSBDevice.mounted() ? "YES" : "NO");
|
||||
}
|
||||
|
||||
while (usb_midi.available()) {
|
||||
if (usb_midi.available()) {
|
||||
uint8_t packet[4];
|
||||
if (usb_midi.readPacket(packet)) {
|
||||
uint8_t cin = packet[0] & 0x0F;
|
||||
@@ -58,12 +58,10 @@ void UsbMidiTransport::update() {
|
||||
if (packet[1] == 0xF8) {
|
||||
midi_tick_count++;
|
||||
} else if (packet[1] == 0xFA) {
|
||||
midi_tick_count = 0;
|
||||
Serial.println("[CLK] START - reset tick to 0");
|
||||
midi_tick_count = 0xFFFFFFFF;
|
||||
Serial.println("[CLK] START - next F8 = tick 0");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
MidiEvent event;
|
||||
parse_midi_packet(packet, 4, event);
|
||||
|
||||
@@ -84,6 +82,7 @@ void UsbMidiTransport::update() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UsbMidiTransport::on_midi_receive(std::function<void(const MidiEvent&)> callback) {
|
||||
receive_callback = callback;
|
||||
|
||||
Reference in New Issue
Block a user