Code Monkey home page Code Monkey logo

jzz's Introduction

JZZ: MIDI library for Node.js and web-browsers

nodejs firefox chrome opera safari msie edge windows macos linux raspberry pi ios android
npm npm jsDelivr Build Status Coverage

JZZ.js allows sending, receiving and playing MIDI messages in Node.js and all major browsers in Linux, MacOS and Windows. Some features are available on iOS and Android devices.

JZZ.js enables Web MIDI API in Node.js and those browsers that don't support it, and provides additional functionality to make developer's life easier.

For the best user experience, it's highly RECOMMENDED (though not required) to install the latest version of Jazz-Plugin and browser extensions from Chrome Web Store or Mozilla Add-ons or Apple App Store.

Features

  • MIDI In/Out
  • User-defined MIDI nodes
  • MIDI files
  • MPE
  • SMPTE
  • Additional modules

Install

npm install jzz --save
or bower install jzz
or yarn add jzz
or get the full development version and minified scripts from Github

Note: in the (unlikely) case you get into trouble installing the midi-test module, that requires special system configuration, you can safely remove it from the devDependencies by running npm remove midi-test --save-dev.

Usage

Plain HTML
<script src="JZZ.js"></script>
//...
CDN
<script src="https://cdn.jsdelivr.net/npm/jzz"></script>       // the latest version, or
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> // any particular version
//...
CommonJS (Browserify and Node.js command line applications)
var JZZ = require('jzz');
//...
AMD
require(['JZZ'], function(JZZ) {
  //...
});
TypeScript
import * as JZZ from 'jzz';
//...

Web MIDI API

(Node.js example)
var navigator = require('jzz');
navigator.requestMIDIAccess().then(onSuccess, onFail);
// ...
navigator.close(); // This will close MIDI inputs,
                   // otherwise Node.js will wait for MIDI input forever.
// In browsers the funcion is neither defined nor required.

JZZ API

MIDI Output/Input
JZZ().or('Cannot start MIDI engine!')
     .openMidiOut().or('Cannot open MIDI Out port!')
     .wait(500).send([0x90,60,127]) // note on
     .wait(500).send([0x80,60,0]);  // note off
JZZ().openMidiIn().or('Cannot open MIDI In port!')
     .and(function() { console.log('MIDI-In: ', this.name()); })
     .connect(function(msg) { console.log(msg.toString()); })
     .wait(10000).close();
Connecting MIDI nodes
var input = JZZ().openMidiIn();
var output = JZZ().openMidiOut();
var delay = JZZ.Widget({ _receive: function(msg) { this.wait(500).emit(msg); }});
input.connect(delay);
delay.connect(output);
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
port.ch(0).noteOn('C#5').wait(500).noteOff('C#5');          // using channels
port.ch(0).note('C#5', 127, 500);                           // using channels
Asynchronous calls
// in the environments that support async/await:
async function playNote() {
  var midi = await JZZ();
  var port = await midi.openMidiOut();
  await port.noteOn(0, 'C5', 127);
  await port.wait(500);
  await port.noteOff(0, 'C5');
  await port.close();
  console.log('done!');
}
// or:
async function playAnotherNote() {
  var port = await JZZ().openMidiOut();
  await port.noteOn(0, 'C5', 127).wait(500).noteOff(0, 'C5').close();
  console.log('done!');
}

Additional modules

  • JZZ-midi-SMF - Standard MIDI files: read / write / play
  • JZZ-midi-GM - General MIDI instrument names: MIDI to string / string to MIDI
  • JZZ-midi-Gear - Retrieve your MIDI device model and manufacturer
  • JZZ-input-Kbd - Virtual piano controls for your MIDI projects
  • JZZ-synth-OSC - A simple Web Audio synth to use when MIDI is not available
  • JZZ-synth-Tiny - A tiny General MIDI synth implemented with the Web Audio API
  • etc... - Import third-party solutions into the JZZ framework

Check the Getting Started page and the API reference for more information.
Your questions and comments are welcome here.

We would really appreciate your support!

jzz's People

Contributors

jazz-soft avatar pearcemerritt avatar justcfx2u avatar michaellavoie avatar abudaan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.