0.0.6 • Published 3 months ago

jzz-midi-ws v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

JZZ-midi-WS

MIDI via WebSockets for browser and Node.js

and, YES, it's visible from the Web MIDI API!

npm npm build Coverage Status

Usage

Plain HTML
<script src="JZZ.js"></script>
<script src="JZZ.midi.WS.js"></script>
//...
CDN (jsdelivr)
<script src="https://cdn.jsdelivr.net/npm/jzz"></script>
<script src="https://cdn.jsdelivr.net/npm/jzz-midi-ws"></script>
//...
CDN (unpkg)
<script src="https://unpkg.com/jzz"></script>
<script src="https://unpkg.com/jzz-midi-ws"></script>
//...
CommonJS
var JZZ = require('jzz');
require('jzz-midi-ws')(JZZ);
//...

Client

(Browser or Node.js)
JZZ.WS.connect('ws://localhost:8888'); // not necessarily local :)
// ... 
var port = JZZ().openMidiOut('ws://localhost:8888 - Microsoft GS Wavetable Synth');
// ... 
port.noteOn(0, 'C5', 127);

See another example at https://github.com/jazz-soft/JZZ-midi-WS/blob/main/test.html ...

Server

(Node.js only)
const ws = require('ws');
const JZZ = require('jzz');
require('jzz-midi-ws')(JZZ);

// start a WebSocket server (see more ways of doing that at https://github.com/websockets/ws)
const wss = new ws.Server({ port: 8888 });

// start a MIDI via WebSockets server
const server = new JZZ.WS.Server(wss);

// add actual MIDI ports
JZZ().and(function() {
    var info = JZZ().info();
    for (var p of info.inputs) server.addMidiIn(p.id, JZZ().openMidiIn(p.id));
    for (var p of info.outputs) server.addMidiOut(p.id, JZZ().openMidiOut(p.id));
});

// and/or virtual ports
server.addMidiIn('Dummy', JZZ.Widget());
server.addMidiOut('Debug', JZZ.Widget({ _receive: function(msg) { console.log(msg.toString()); }}));

A more advanced example is available at https://github.com/jazz-soft/WS-MIDI-Server ...

0.0.6

3 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago

0.0.0

4 months ago