Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork0
jazz-soft/JZZ-midi-WS
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This module allows you to set up a server that exposes MIDI ports via the network,
and multiple clients that can access these ports via WebSockets.
And YES, these ports are visible from the Web MIDI API!
If you need a symmetric peer-to-peer connection where both sides can access each other's MIDI ports,
you may want to checkhttps://github.com/jazz-soft/JZZ-midi-RTC
<scriptsrc="JZZ.js"></script><scriptsrc="JZZ.midi.WS.js"></script>//...
<scriptsrc="https://cdn.jsdelivr.net/npm/jzz"></script><scriptsrc="https://cdn.jsdelivr.net/npm/jzz-midi-ws"></script>//...
<scriptsrc="https://unpkg.com/jzz"></script><scriptsrc="https://unpkg.com/jzz-midi-ws"></script>//...
varJZZ=require('jzz');require('jzz-midi-ws')(JZZ);//...
JZZ.WS.connect('ws://localhost:8888');// not necessarily local :)// ...varport=JZZ().openMidiOut('ws://localhost:8888 - Microsoft GS Wavetable Synth');// ...port.noteOn(0,'C5',127);
See another example athttps://github.com/jazz-soft/JZZ-midi-WS/blob/main/test.html ...
varconnection=JZZ.WS.connect(url,timeout);
Constructor.url
- websocket address/port;timeout
(optional) - time inms
before fail if the connection cannot be established; default:5000
.
Upon successful connection, remote MIDI ports are added and tracked automatically.
If the connection is lost, client tries to reconnect.
connection.close();
Disconnect and close all related MIDI ports.
functiongood(){console.log('Connected!');}functionbad(){console.log('Cannot connect!');}varurl='ws://localhost:8888';varconnection;// method 1 (and/or):connection=JZZ.WS.connect(url).and(good).or(bad);// method 2 (then):connection=JZZ.WS.connect(url).then(good,bad);// method 3 (within an async function):connection=awaitJZZ.WS.connect(url);
constws=require('ws');constJZZ=require('jzz');require('jzz-midi-ws')(JZZ);// start a WebSocket server (see more ways of doing that at https://github.com/websockets/ws)constwss=newws.Server({port:8888});// start a MIDI via WebSockets serverconstserver=newJZZ.WS.Server(wss);// add actual MIDI portsJZZ().and(function(){varinfo=JZZ().info();for(varpofinfo.inputs)server.addMidiIn(p.id,JZZ().openMidiIn(p.id));for(varpofinfo.outputs)server.addMidiOut(p.id,JZZ().openMidiOut(p.id));});// and/or virtual portsserver.addMidiIn('Dummy',JZZ.Widget());server.addMidiOut('Debug',JZZ.Widget({_receive:function(msg){console.log(msg.toString());}}));
A more advanced example is available athttps://github.com/jazz-soft/WS-MIDI-Server ...
varserver=newJZZ.WS.Server(wss);
Constructor.wss
- websocket server.
server.addMidiIn(name,port);server.addMidiOut(name,port);
Add MIDI port.name
- name to bee seen by the client;port
- MIDI port (real or virtual).
server.removeMidiIn(name);server.removeMidiOut(name);
Remove MIDI port.
- WS Client - a live demo at github.io
- JZZ-midi-RTC - MIDI via WebRTC
- JZZ - MIDI library for Node.js and web-browsers
About
MIDI via WebSockets
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.