node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org ยป

jzz

JZZ: Asynchronous MIDI Library

nodejs firefox chrome opera safari msie windows mocos linux raspberry pi ios android

JZZ.js allows sending, receiving and playing MIDI messages in Node.js and all major browsers in Linux, MacOS and Windows.

It requires jazz-midi or Jazz-Plugin, and uses Chrome Web MIDI API and/or Web Audio as a fallback.

Limited support is available on iOS and Android devices.

Node.js module: npm install jzz.

Development version and minified scripts are available at Github.

Your questions and comments are welcome here.

You can also support this project.

Usage

Node.js
var JZZ = require('jzz');
JZZ().or('Cannot start MIDI engine!')
     .openMidiOut().or('Cannot open MIDI Out port!')
     .wait(500).send([0x90,60,127])
     .wait(500).send([0x90,64,127])
     .wait(500).send([0x90,67,127])
     .wait(1000).send([0x90,60,0]).send([0x90,64,0]).send([0x90,67,0])
     .and('thank you!');
HTML
<script src="scripts/JZZ.js"></script>
...
<script><!--
JZZ().or('Cannot start MIDI engine!')
     .openMidiOut().or('Cannot open MIDI Out port!')
     .wait(500).send([0x90,60,127])
     .wait(500).send([0x90,64,127])
     .wait(500).send([0x90,67,127])
     .wait(1000).send([0x90,60,0]).send([0x90,64,0]).send([0x90,67,0])
     .and('thank you!');
--></script>
Helpers and shortcuts

All calls below will 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');   // helper functions
port.note(0,'C#5',127,500);                             // another shortcut
MIDI input
JZZ().openMidiIn().or('MIDI-In:  Cannot open!')
     .and(function(){ console.log('MIDI-In: ', this.name()); })
     .connect(function(msg){console.log(msg.toString());})
     .wait(10000).close();

Check the Getting Started page and the API reference for more information ...