PortMidi / portmidi

portmidi is a cross-platform MIDI input/output library
Other
130 stars 35 forks source link

Feature request: Support WebMIDI when targeting Emscripten/WebAssembly #68

Open fwcd opened 8 months ago

fwcd commented 8 months ago

Would be pretty cool to have, other libraries like libremidi have an Emscripten backend too.

rbdannenberg commented 8 months ago

Some comments: Yes, I think the PortMidi API could run in Emscripten with a WebMIDI backend, but it might be even better to rewrite the API in javascript. PortMidi is optimized for real time by avoiding dynamic memory allocation and using lock-free queues between OS callbacks or MIDI threads and the application thread. Javascript in a web environment is much less real-time oriented and the programming model is cooperative multi-threading, so a lot of the structure of PortMidi does not really apply. Also, for javascript, it might seem strange to be encoding midi messages into a single PmMessage, which is really just an int32. On the other hand, an Emscripten version would allow applications in C++ to use PortMidi and be compiled to run in browsers. I'd be happy to discuss further with anyone interested in making PortMidi run in browsers.

fwcd commented 8 months ago

On the other hand, an Emscripten version would allow applications in C++ to use PortMidi and be compiled to run in browsers

Yeah this is precisely our use case, I'm porting Mixxx, a large DJ app written in C++/Qt to the web.