l@271: # This listens for osc messages and rebroadcasts them l@271: # with all the floats converted to ints. l@271: l@271: osc = require 'osc-min' l@271: udp = require "dgram" l@271: l@271: if process.argv[2]? l@271: inport = parseInt process.argv[2] l@271: else l@271: inport = 41234 l@271: l@271: if process.argv[3]? l@271: outport = parseInt process.argv[3] l@271: else l@271: outport = 41235 l@271: l@271: float_to_int = (message) -> l@271: for arg in message.args l@271: if arg.type is "float" l@271: arg.type = "integer" l@271: message l@271: l@271: sock = udp.createSocket "udp4", (msg, rinfo) -> l@271: try l@271: edited = osc.applyMessageTransform msg, (message) -> float_to_int message l@271: sock.send( l@271: edited, l@271: 0, l@271: edited.length, l@271: outport, l@271: "localhost" l@271: ) l@271: catch error l@271: console.log "error redirecting: " + error l@271: sock.bind inport l@271: l@271: console.log "OSC redirecter running at http://localhost:" + inport l@271: console.log "translating messages to http://localhost:" + outport