websockets-streaming-audio
Version:
Click a browser button to launch a node.js process on the server side which streams audio using web sockets back to the browser which is then rendered using web audio API My plan is to make this modular enough to get added to your process as simple API
27 lines (15 loc) • 487 B
JavaScript
const WebSocket = require('ws');
// const ws_port = 8888
const ws_port = 8080
var ws_url = 'ws://localhost:' + ws_port
console.log("\nhere is ws_url ", ws_url, "\n\n");
// const ws = new WebSocket('ws://www.host.com/path');
// const ws = new WebSocket('ws://localhost:8080');
const ws = new WebSocket( ws_url );
ws.on('open', function open() {
const array = new Float32Array(5);
for (var i = 0; i < array.length; ++i) {
array[i] = i / 2;
}
ws.send(array);
});