We make it sound!

Home » Documentation » JZZ.js » MIDI-Out


Opening MIDI-Out port

engine.openMidiOut(arg) - tries to open MIDI-Out port.


port = JZZ().openMidiOut(0);
port = JZZ().openMidiOut('Microsoft GS Wavetable Synth');
port = JZZ().openMidiOut(['Microsoft GS Wavetable Synth', 'Apple DLS Synth', 0]);
port = JZZ().openMidiOut(function(){ return [2, 1, 0]; });
port = JZZ().openMidiOut(/Yamaha/);
port = JZZ().openMidiOut();


port.close() - closes the port.

No other calls except the common calls can be chained to the closed port.

This call is optional, since all ports automatically close on exit.


port.info() - returns an info object with the following keys:


port.name() - a shortcut for the port.info().name.


JZZ().or('Cannot start MIDI engine!')
     .openMidiOut().or('MIDI-Out: Cannot open!')
     .and(function(){ console.log('MIDI-Out:', this.name()); });


port.send(msg) - sends msg to the port.

msg can be an array, a comma-separated list, or an object of type JZZ.MIDI.

It is subject of the same rules applied to the JZZ.MIDI constructor.


MIDI-Out port has a complete set of helpers corresponding to the ones defined for JZZ.MIDI.

For each helper name, port.helper(...) is equivalent to port.send(JZZ.MIDI.helper(...)).

Additional helpers can send multiple messages:

port.note(c, n, v, t) is equivalent to port.noteOn(c, n, v).wait(t).noteOff(c, n) if t, and to port.noteOn(c, n, v) otherwise.


All statements below do the same job:

port.send([0x90, 61, 127]).wait(500).send([0x80, 61, 0]);   // arrays
port.send(0x90, 61, 127).wait(500).send(0x80, 61, 0);       // comma-separated
port.send(0x90, 'C#5' ,127).wait(500).send(0x80, 'Db5' ,0); // note names
port.noteOn(0, 'C#5', 127).wait(500).noteOff(0, 'B##4');    // helpers
port.note(0, 'C#5', 127, 500);                              // another helper

Other calls

port.or(), port.and(), port.wait()

See also