javascriptgoogle-chromeweb-midi

Webmidi js does not play a sound on browser


Hey I am using the webmidi js library to play midi music on click on the browser. https://www.npmjs.com/package/webmidi

I am using a very basic example from the library. Even though it seems that the connection works I can not here anything.

WebMidi.enable(function (err) {
  if (err) {
    console.log("WebMidi could not be enabled.", err);
  } else {
    console.log("WebMidi enabled!");
    var output =WebMidi.outputs[0];
    console.log(output);
    output.playNote(["C3", "D#3", "G3"]);
  }      
});

I am running it on chrome and ubuntu 14.04.

The console.log(output) returns:

Output_midiOutput: MIDIOutput
connection:"open"
id:"6FF5590044F4859ED50C5167BCFE9700A1798E39AA55A628E86D39011FAECD5D"
manufacturer:""
name:"Midi Through Port-0"
onmidimessage:()
onstatechange:null
state:"connected"
type:"output"
version:"ALSA library version 1.0.25"

Solution

  • Midi Through Port-0 is a dummy sequencer that doesn't make any sound. I assume you are running on a Linux machine - try the command aconnect -o to see a list of available MIDI outputs, find the device you are trying to play the MIDI notes through and select that one as your output.