Interfacing a midi keyboard or other real-time midi input with javascript?

Viewed 11343

I want to create a simple visualization tool that would allow to represent my playing a midi keyboard on the screen. I play a relatively novel instrument type, called the harmonic table:

http://en.wikipedia.org/wiki/Harmonic_table_note_layout

http://www.soundonsound.com/newspix/image/axis49.jpg

And want to build tools to ease their use and to teach others how to use them.

However, I can't find a good way to get get midi into javascript environment (or, for that matter, Flash, or Java without a large helping of jiggery-pokery slightly beyond my reach, and the use of code from what look to be rather stale and abandoned open source projects. Neither language I am too enthused to work in for this project in any case).

Is there a suitable library or application that I have missed, that will enable me to do this?

8 Answers

I have made a NPAPI browser plugin that lets you communicate in Javascript with MIDI devices.

Currently it works on OSX in Chrome and Safari, and on Windows in Chrome.

I am working on support for other browsers (Firefox, Internet Explorer) and other operating systems (Linux, Android, iOs)

See: http://abumarkub.net/abublog/?p=754

Nowadays browsers supports MIDI listening. All you need is

navigator.requestMIDIAccess().then(requestMIDIAccessSuccess, requestMIDIAccessFailure);

and listen keys

function requestMIDIAccessSuccess(midi) {
            var inputs = midi.inputs.values();
            for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
                console.log('midi input', input);
                input.value.onmidimessage = midiOnMIDImessage;
            }
            midi.onstatechange = midiOnStateChange;
        }

See working example here

Related