jzz-synth-osc

Fallback MIDI-Out implementation


Keywords
midi, midi-synth, webaudio, webaudioapi, web-audio, web-audio-api, synth, audio, web-midi, web-midi-api, webmidi, webmidiapi
License
MIT
Install
bower install jzz-synth-osc

Documentation

JZZ-synth-OSC

A simple MIDI-Out implementation for the systems with no better option available.
Mainly, for use as a template for your own JZZ-compatible synths.
For real world applications, please consider using JZZ-synth-Tiny instead.

npm npm jsDelivr build Coverage Status

Install

npm install jzz-synth-osc
or yarn add jzz-synth-osc
or get the full development version and minified scripts from GitHub

Usage

Plain HTML
<script src="JZZ.js"></script>
<script src="JZZ.synth.OSC.js"></script>
//...
CDN (jsdelivr)
<script src="https://cdn.jsdelivr.net/npm/jzz"></script>
<script src="https://cdn.jsdelivr.net/npm/jzz-synth-osc"></script>
//...
CDN (unpkg)
<script src="https://unpkg.com/jzz"></script>
<script src="https://unpkg.com/jzz-synth-osc"></script>
//...
CommonJS
var JZZ = require('jzz');
require('jzz-synth-osc')(JZZ);
//...
TypeScript / ES6
import { JZZ } from 'jzz';
import { OSC } from 'jzz-synth-osc';
OSC(JZZ);
//...
AMD
require(['JZZ', 'JZZ.synth.OSC'], function(JZZ, dummy) {
  // ...
});
//...
JZZ.synth.OSC().noteOn(0, 'C5', 127)
     .wait(500).noteOn(0, 'E5', 127)
     .wait(500).noteOn(0, 'G5', 127);
     .wait(500).noteOff(0, 'C5').noteOff(0, 'E5').noteOff(0, 'G5');

Using in Node.js with headless Web Audio

const WAAPI = require('node-web-audio-api');
const JZZ = require('jzz');
require('jzz-synth-osc')(JZZ);

global.window = { AudioContext: WAAPI.AudioContext };

JZZ.synth.OSC()
  .or(function() { console.log('Cannot open MIDI-Out!\n'/* + this.err() */); })
  .note(0, 'C5', 127, 500).wait(500)
  .note(0, 'E5', 127, 500).wait(500)
  .note(0, 'G5', 127, 500).wait(500)
  .note(9, 'C6', 127, 500).wait(500)
  .and(function() { JZZ.lib.closeAudioContext(); });

More information

Please visit https://jazz-soft.net for more information.
Your questions and comments are welcome here.