-2

I'm just trying to figure out the whole process of connecting a MIDI keyboard to the web. I have found things out there, but they're 3 years old or so and I think a fair amount has changed since then.

To have a place to start, I want to create a web app that simply displays what note I am hitting on my MIDI keyboard when I press it.

I found this thread and got it to work and all: How to discover midi keyboard in web midi api?

I guess I am stuck on how to register notes. I am semi-new to things like this and any answer I can find doesn't make a whole lot of sense to me. Thanks.

Community
  • 1
  • 1
Dan Hogan
  • 468
  • 4
  • 16

2 Answers2

0

I found this to be very helpful: http://webaudiodemos.appspot.com/monosynth/

I slightly added to it to display what note is being played: https://github.com/danhogan/monosynth

Dan Hogan
  • 468
  • 4
  • 16
0

The thread you linked to shows how to get MIDI access, but doesn't show you how to handle MIDI messages once you get access. What's missing from that example is something like this:

midiAccess.inputs()[0].onmidimessage = function(event){
    console.log(event.receivedTime, event.data)
    // do cool stuff with midi data here
}

I wrote a library, Wad.js, which I think would be perfect for you in this case. https://github.com/rserota/wad#midi-input

Basically, when Wad.js initializes, it will automatically detect all connected MIDI devices, and then log to the console all MIDI messages that they send. Once you're familiar with what your device's data look like, you can write MIDI event handler functions to handle those messages, e.g.

Wad.midiInputs[0].onmidimessage = function(event){
    console.log(event.receivedTime, event.data);
};
Wad.midiInputs[1].onmidimessage = anotherMidiHandlerFunction // If you have multiple MIDI devices that you would like to use simultaneously, you will need multiple MIDI handler functions.

As of writing this, I think that MIDI is only available in Chrome as an 'experimental feature', so you'll have to enable it manually. Also, you'll need to install the jazz-plugin ( http://jazz-soft.net/doc/Jazz-Plugin/ ) to give your browser low-level MIDI access. If you still have trouble detecting MIDI

Raphael Serota
  • 2,157
  • 10
  • 17