l@271: // Generated by CoffeeScript 1.10.0 l@271: var float_to_int, inport, osc, outport, sock, udp; l@271: l@271: osc = require('osc-min'); l@271: l@271: udp = require("dgram"); l@271: l@271: if (process.argv[2] != null) { l@271: inport = parseInt(process.argv[2]); l@271: } else { l@271: inport = 41234; l@271: } l@271: l@271: if (process.argv[3] != null) { l@271: outport = parseInt(process.argv[3]); l@271: } else { l@271: outport = 41235; l@271: } l@271: l@271: float_to_int = function(message) { l@271: var arg, i, len, ref; l@271: ref = message.args; l@271: for (i = 0, len = ref.length; i < len; i++) { l@271: arg = ref[i]; l@271: if (arg.type === "float") { l@271: arg.type = "integer"; l@271: } l@271: } l@271: return message; l@271: }; l@271: l@271: sock = udp.createSocket("udp4", function(msg, rinfo) { l@271: var edited, error, error1; l@271: try { l@271: edited = osc.applyMessageTransform(msg, function(message) { l@271: return float_to_int(message); l@271: }); l@271: return sock.send(edited, 0, edited.length, outport, "localhost"); l@271: } catch (error1) { l@271: error = error1; l@271: return console.log("error redirecting: " + error); l@271: } l@271: }); l@271: l@271: sock.bind(inport); l@271: l@271: console.log("OSC redirecter running at http://localhost:" + inport); l@271: l@271: console.log("translating messages to http://localhost:" + outport);