Correct me if I'm wrong, but wouldn't WebMidi[1] be a solution to your problem? Here is a piano example [2]
1. https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_AP... 2. https://abbernie.github.io/tune/
1. https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_AP... 2. https://abbernie.github.io/tune/