multi-midi: Introducing a new multi-port hardware + USB MIDI library for RP2 boards (and a question for the community) #17979
Replies: 3 comments 3 replies
-
asyncio acts as a cooperative and not a preemptive scheduler. I presume that timing is of critical importance when dealing with MIDI messages. While it might be possible to achieve something acceptable, all pieces have to fit perfectly and yield as fast as possible. And timing still wouldn't always be reproducible. |
Beta Was this translation helpful? Give feedback.
-
Maybe you want to see this: https://youtu.be/02CLD-42VdI?si=XRl9gpXMgzuOIG1l&t=4507 |
Beta Was this translation helpful? Give feedback.
-
As a very general comment my approach would be to start with Multi-core work is difficult and can harbour subtle, hard to find, bugs. While powerful, it's something of a last resort (IMHO). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m happy to announce a new MicroPython library for RP2 boards, providing an interface for UART and PIO based hardware MIDI and USB MIDI 1.0: https://github.com/HLammers/multi-midi/
This is a follow up to #17640
Features
Question For the Community
As I describe in much detail in the PROCESS_MAP.md file (with all the pros and cons), I’m still considering whether I’ve followed the right approach, or I should try a different one:
Is it really necessary and worth the considerable effort to refactor the current
asyncio
based approach into an approach based on dedicating the second core to a viper code and direct register access based low-level approach?To answer that question I probably first need to get a better understanding of how well the
asyncio
based implementation performs: try it out with real MIDI hardware (putting my collection of drum computers to work) and find a way to actually measure its current performance.On the one hand I’m feeling drawn to taking the challenge of building a near-low-level version of multi-midi, but on the other hand I’m afraid it’s going to consume too much time – this project already took a little bit more time and effort than I expected…
Perhaps it’s also possible to look for hybrids of the current
asyncio
based approach and a complete low-level refactoring:Only replacing the current IRQ + event based approach to I/O with a polling approach based on direct register access.
Disadvantage: This goes against the
asyncio
philosophy and it can be tricky to maintain the flow of the event loop, but it can be done…Only move the lowest level MIDI processing (merging data streams and I/O) to the second core.
Disadvantage: In such case the second core could not be used anymore for off-loading heavy tasks, introducing a risk of more jitter because some MIDI processes depend on the main core.
I’d love to read the expert opinion of others who have more experience writing (semi-)low-level code than I have (and who can perhaps help me here and there if I decide to go that route…): what do you recommend? To do or not to do?
Beta Was this translation helpful? Give feedback.
All reactions