Commit c7ee829d authored by Joseph Larralde's avatar Joseph Larralde
Browse files

renamed waves-audio to wavesjs + added node-osc basic example

parent 423025ae
**/.DS_Store
**/Thumbs.db
node_modules/
\ No newline at end of file
{
"name": "node-osc",
"version": "1.0.0",
"description": "a simple ws osc bridge using osc.js",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD-3-Clause",
"dependencies": {
"express": "^4.15.3"
}
}
#N canvas 370 138 655 437 10;
#X text 129 140 Send messages to "foo" on remote machine;
#X msg 31 59 disconnect;
#X floatatom 93 140 0 0 0 0 - - -;
#X obj 78 259 netsend -u -b;
#X msg 31 37 connect localhost 57121;
#X obj 93 185 list prepend send;
#X obj 93 210 list trim;
#X obj 93 163 oscformat foo;
#X obj 454 90 oscparse;
#X obj 454 198 print;
#X obj 454 120 list trim;
#X obj 454 62 netreceive -b -u 8081;
#X connect 1 0 3 0;
#X connect 2 0 7 0;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 6 0 3 0;
#X connect 7 0 5 0;
#X connect 8 0 10 0;
#X connect 10 0 9 0;
#X connect 11 0 8 0;
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script src="js/osc-browser.min.js"></script>
</head>
<body>
<div>
<button id="butt" value="A"> A </button>
<br>
<input id="slider" type="range" min="0" max="1" step="0.01" value="0">
</div>
<script type="text/javascript">
window.onload = function() {
//>>>>>>>>>>>>>>>>>>>>>>>>>>
var oscPort = new osc.WebSocketPort({
url: "ws://localhost:8081"
});
oscPort.on('open', function() {
console.log('socket open');
});
oscPort.on('message', function (msg) {
console.log(msg['address'] + ' ' + msg['args']);
});
oscPort.on('close', function() {
console.log('socket closed');
});
oscPort.open();
oscPort.socket.onmessage = function (e) {
console.log("message", e);
};
var b = document.querySelector('#butt');
b.addEventListener('click', function(e) {
oscPort.send({
address: '/button',
args: [ e.target.value ],
});
});
var r = document.querySelector('#slider');
r.addEventListener('input', function(e) {
oscPort.send({
address: '/slider',
args: [ e.target.value ],
});
});
//<<<<<<<<<<<<<<<<<<<<<<<<<<
}
</script>
</body>
</html>
\ No newline at end of file
(function() {
window.onload = function() {
//>>>>>>>>>>>>>>>>>>>>>>>>>>
this.oscPort = new osc.WebSocketPort({
url: "ws://localhost:8081"
});
this.listen();
this.oscPort.open();
this.oscPort.socket.onmessage = function (e) {
console.log("message", e);
};
//<<<<<<<<<<<<<<<<<<<<<<<<<<
}
})();
\ No newline at end of file
This diff is collapsed.
var osc = require("osc"),
express = require("express"),
WebSocket = require("ws");
var cwd = process.cwd();
var getIPAddresses = function () {
var os = require("os"),
interfaces = os.networkInterfaces(),
ipAddresses = [];
for (var deviceName in interfaces) {
var addresses = interfaces[deviceName];
for (var i = 0; i < addresses.length; i++) {
var addressInfo = addresses[i];
if (addressInfo.family === "IPv4" && !addressInfo.internal) {
ipAddresses.push(addressInfo.address);
}
}
}
return ipAddresses;
};
// Bind to a UDP socket to listen for incoming OSC events.
var udpPort = new osc.UDPPort({
localAddress: "0.0.0.0",
localPort: 57121
});
udpPort.on("ready", function () {
var ipAddresses = getIPAddresses();
console.log("Listening for OSC over UDP.");
ipAddresses.forEach(function (address) {
console.log(" Host:", address + ", Port:", udpPort.options.localPort);
});
console.log("To start the demo, go to http://localhost:8081 in your web browser.");
});
udpPort.open();
// Create an Express-based Web Socket server to which OSC messages will be relayed.
// var appResources = __dirname + "/web",
var appResources = cwd + "/public",
app = express(),
server = app.listen(8081),
wss = new WebSocket.Server({
server: server
});
app.use("/", express.static(appResources));
wss.on("connection", function (socket) {
console.log("A Web Socket connection has been established!");
var socketPort = new osc.WebSocketPort({
socket: socket
});
var relay = new osc.Relay(udpPort, socketPort, {
raw: true
});
});
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<body>
<canvas width="100%" height="100%"></canvas>
<script type="text/javascript">
(function() {
var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
var modOsc = audioContext.createOscillator();
var modFreq = audioContext.createConstantSource();
var modGain = audioContext.createGain();
var addOffset = audioContext.createChannelMerger();
var carOsc = audioContext.createOscillator();
var carGain = audioContext.createGain();
modOsc.frequency.value = 100;
modGain.gain.value = 1000;
carGain.gain.value = 0.5;
carOsc.frequency.value = 100;
modOsc.connect(modGain);
modGain.connect(carOsc.frequency);
carOsc.connect(carGain);
carGain.connect(audioContext.destination);
modOsc.start();
carOsc.start();
setInterval(function() {
carOsc.frequency.value = Math.random() * 100 + 1000;
modOsc.frequency.value = Math.random() * 20 + 1000;
// modOsc.frequency.value = carOsc.frequency.value * 2.321;
}, 120);
})();
</script>
</body>
This diff is collapsed.
This diff is collapsed.
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
div { div {
margin: 10px; margin: 10px;
padding: 10px; padding: 10px;
background-color: #000; background-color: #ddd;
color: #fff; color: #333;
} }
a { a {
text-decoration: none; text-decoration: none;
color: #aaa; color: #555;
} }
</style> </style>
</head> </head>
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
<body> <body>
<div> <div>
<h1> waves audio basic examples </h1> <!-- <img src="assets/rapidmix-logo-720-2.png"> -->
<h1> <img src="assets/rmx.png" width="100" height="100"> waves audio basic examples </h1>
<p> <p>
To get the following examples working, To get the following examples working,
once you have Node.js installed : once you have Node.js installed :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment