Created
April 19, 2014 08:36
-
-
Save 2bbb/11078078 to your computer and use it in GitHub Desktop.
artnet_sender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install artnet-node | |
// npm install node-osc | |
var clientIP = "192.168.1.102"; // set correct IP | |
var port = 6454, | |
Artnet = require('artnet-node'), | |
ArtnetClient = Artnet.Client, | |
OSC = require('node-osc'); | |
var socket = ArtnetClient.createClient(clientIP, port); | |
var data = []; | |
for(var i = 0; i < 512; i++) { | |
data[i] = 0; | |
} | |
var oscServer = new OSC.Server(9005, '127.0.0.1') | |
.on("message", function (packet, rinfo) { | |
address = packet[0]; | |
if(address == "/dmx") { | |
if(packet.length == 3) { | |
data[packet[1] - 1] = packet[2]; | |
} else { | |
for(var i = 0; i < packet[2]; i++) data[packet[1] + i - 1] = packet[3 + i]; | |
} | |
} | |
if(address == "/print") { | |
var dataStr = ""; | |
for(var i = packet[1] - 1; i < packet[2] - 1; i++) { | |
dataStr += data[i] + ", "; | |
} | |
console.log("debug", dataStr); | |
} | |
}); | |
var t = setInterval(function() { | |
socket.send(data); | |
}, 16.6667); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment