Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for strange MIDI delays using RP2040 and the MIDI library on the hardware serial ports #43

Open
ichingxs4all opened this issue Sep 24, 2024 · 1 comment

Comments

@ichingxs4all
Copy link

I recently found a workaround for strange irregular delays in outputting MIDI clock through the hardware serial port on a RP2040 based boards like the Pico or the Waveshare RP2040 Zero.
I can pinpoint it to every read operation that is executed in the main loop lik : void loop(){ MIDI.read()} . Or a direct serial port read without the MIDI library.
USB MIDI does not have this problem when it is used solo, but both together with an hardware serial device it also this strange behaviour. The result is a BPM that is very irregular and way below the BPM you set with setTempo.

So the workaround I found after al lot of experimentation is using the dual core mode of the RP2040. This solves the problem.

// Running on core1
void setup1() {
// Initialize UART midi stack
MIDI.begin(MIDI_CHANNEL_OMNI);
setHWMidiHandlers();
MIDI_USB.begin(MIDI_CHANNEL_OMNI);
setMIDI_USBHandlers();
}

void loop1() {
MIDI.read();
MIDI_USB.read();
}

@doctea
Copy link
Contributor

doctea commented Oct 16, 2024

Do you have a simple example that demonstrates this, or can you post your full code? I output serial MIDI clock in my RP2040+uClock project, and I don't think I've noticed anything strange like this so far...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants