Jazz-Soft.net

We make it sound!

Home » Documentation » JZZ.js » MIDI-In

MIDI-In

Opening MIDI-In port

engine.openMidiIn(arg) - tries to open MIDI-In port.

Example

port = JZZ().openMidiIn(0);
port = JZZ().openMidiIn('Roland RD');
port = JZZ().openMidiIn(function(){ return [2, 1, 0]; });
port = JZZ().openMidiIn(/Yamaha/);
port = JZZ().openMidiIn();

close()

port.close() - closes the port.

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

This call is optional in HTML, but in Node.js all open MIDI-In ports must be closed before the application can exit.

info()

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

name()

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

connect()

port.connect(obj) - adds MIDI event handler or connects to MIDI-Out port.

obj is either a MIDI-Out port object, or a function that will execute in the context of the current MIDI-In port object and receive a JZZ.MIDI object as an argument.

Both MIDI-In and MIDI-Out ports can have multiple connections.

disconnect()

port.disconnect(obj) - removes MIDI event handler or disconnects MIDI-Out port.

obj - same as above.

Example

JZZ().or('Cannot start MIDI engine!')
     .openMidiIn().or('MIDI-In: Cannot open!')
     .and(function(){ console.log('MIDI-In:', this.name()); })
     .connect(JZZ().openMidiOut())                            // redirect to the default MIDI-Out port
     .connect(function(msg){ console.log(msg.toString()); })  // and log to the console
     .wait(10000).close().and('Thank you!');

Other calls

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

See also