Чтобы использовать MIDI-выходы для воспроизведения звука, вам понадобится аппаратный или программный MIDI-синтезатор с работающими виртуальными MIDI-портами. Вы, вероятно, хотите использовать AudioContext вместо:
// patch up prefixes
window.AudioContext=window.AudioContext||window.webkitAudioContext;
context = new AudioContext();
if (navigator.requestMIDIAccess)
navigator.requestMIDIAccess().then( onMIDIInit, onMIDIReject );
else
alert("No MIDI support present in your browser. You're gonna have a bad time.")
// set up the basic oscillator chain, muted to begin with.
oscillator = context.createOscillator();
oscillator.frequency.setValueAtTime(110, 0);
envelope = context.createGain();
oscillator.connect(envelope);
envelope.connect(context.destination);
envelope.gain.value = 0.0; // Mute the sound
oscillator.start(0); // Go ahead and start up the oscillator
Для создания более изощренных звуков посмотрите SoundJS или другую звуковую библиотеку.