How to use the osc.UDPPort function in osc

To help you get started, we’ve selected a few osc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github collective-soundworks / soundworks / server / server.es6.js View on Github external
console.log('Server listening on port', app.get('port'));
  });

  // Engine IO defaults
  // this.pingTimeout = opts.pingTimeout || 3000;
  // this.pingInterval = opts.pingInterval || 1000;
  // this.upgradeTimeout = opts.upgradeTimeout || 10000;
  // this.maxHttpBufferSize = opts.maxHttpBufferSize || 10E7;

  if (httpServer) {
    server.io = new IO(httpServer, socketConfig);
  }

  // OSC
  if (options.osc) {
    server.osc = new osc.UDPPort({
      // This is the port we're listening on.
      localAddress: options.osc.localAddress || '127.0.0.1',
      localPort: options.osc.localPort || 57121,

      // This is the port we use to send messages.
      remoteAddress: options.osc.remoteAddress || '127.0.0.1',
      remotePort: options.osc.remotePort || 57120,
    });

    server.osc.on('ready', () => {
      console.log('Listening for OSC over UDP on port ' + options.osc.localPort + '.');
    });

    server.osc.on('message', (oscMsg) => {
      const address = oscMsg.address;
github Streampunk / casparcl / scratch / mixer_clunker.js View on Github external
let start = process.hrtime();

	let frameList1 = await fs.readdir('../media/EBU_test_sets/filexchange.ebu.ch/EBU test sets - Creative Commons (BY-NC-ND)/HDTV test sequences/1080i25/Graphics_1080i_/Graphics_1080i_')
	frameList1 = frameList1.filter(f => f.endsWith('v210'))
	let frameList2 = await fs.readdir('../media/EBU_test_sets/filexchange.ebu.ch/EBU test sets - Creative Commons (BY-NC-ND)/HDTV test sequences/1080i25/girlflower1_1080i_/girlflower1_1080i_')
	frameList2 = frameList2.filter(f => f.endsWith('v210'))
	console.log(frameList2)

	let counter = 0
	let data1 = Buffer.alloc(5529600)
	let data2 = Buffer.alloc(5529600)

	let fl = 0.5

	const oscUdp = new osc.UDPPort({
    localAddress: "0.0.0.0",
    localPort: 9876
	});
	oscUdp.on("message", function (oscMessage) {
		// console.log(oscMessage.address)
    if (oscMessage.address === '/1/fader1') {
			fl = oscMessage.args[0]
			// console.log(fl)
		}
	});
	oscUdp.open()

	while (true) {
		let fh1 = await fs.open('../media/EBU_test_sets/filexchange.ebu.ch/EBU test sets - Creative Commons (BY-NC-ND)/HDTV test sequences/1080i25/Graphics_1080i_/Graphics_1080i_/' + frameList1[counter % frameList1.length], 'r')
		let fh2 = await fs.open('../media/EBU_test_sets/filexchange.ebu.ch/EBU test sets - Creative Commons (BY-NC-ND)/HDTV test sequences/1080i25/girlflower1_1080i_/girlflower1_1080i_/' + frameList2[counter % frameList2.length], 'r')
		await Promise.all([fh1.read(data1, 0, data1.length, 0), fh2.read(data2, 0, data2.length, 0)])
github mimic-sussex / sema / SemaOSCRelay / index.js View on Github external
var addresses = interfaces[deviceName];

		for (var i = 0; i < addresses.length; i++) {
			var addressInfo = addresses[i];

			if (addressInfo.family === "IPv4") {
				// if (addressInfo.family === "IPv4" && !addressInfo.internal) {
				ipAddresses.push(addressInfo.address);
			}
		}
	}

	return ipAddresses;
};

var udp = new osc.UDPPort({
	localAddress: "0.0.0.0",
	localPort: 7400,
	remoteAddress: "127.0.0.1",
	remotePort: 7500
});

udp.on("ready", function() {
	var ipAddresses = getIPAddresses();
	console.log("Sema OSC Relay.");
	console.log("Listening for OSC.");
	ipAddresses.forEach(function(address) {
		console.log(" Host:", address + ", Port:", udp.options.localPort);
	});
	console.log(
		"Broadcasting OSC over UDP to",
		udp.options.remoteAddress + ", Port:",
github ShaPOC / node-muse / src / server / osc.class.js View on Github external
};

    // If an options object is set, check if it's valid
    if(typeof options !== "object") {
        throw new Error("init(): First arg must be an object containing a host and / or port key.");
    }

    // Make sure all options required are set
    options.host = options.host || "127.0.0.1";
    options.port = options.port || 5002;
    options.port = parseInt(options.port);
    
    var self = this;

    // Create an osc.js UDP connection to receive incoming OSC data
    this.udpPort = new osc.UDPPort({
        localAddress: options.host,
        localPort: options.port
    });

    // Listen for incoming OSC bundles.
    this.udpPort.on("data", function (data, info) {

        // Prepare an error for when the try catch fails, inside the try this variable will get overridden
        var receivedData = {
            address : "error",
            args : ["The header of an OSC packet didn't contain an OSC address or a #bundle string"]
        };
        try {
            receivedData = osc.readMessage(data);
        } catch(e) {
            if(self.debug) {
github kylemcdonald / Highsight / Control / app.js View on Github external
var transitions = {
  'shutdown': {end: 'bottom'},
  'top': {end: 'top'},
  'bottom': {end: 'bottom'},
  'scene1': {start: 'top', end: 'boxtop'},
  'scene2': {start: 'boxtop', end: 'boxbottom', s: boxs, ac: boxac, dc: boxdc},
  'scene3': {start: 'boxbottom', end: 'openair'},
  'scene4': {start: 'openair', end: 'end', s: fasts, ac: fastac, dc: fastdc}, // should be fast
  'scene5': {start: 'end', end: 'openair'}, // should be slow
};

app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/bower_components'));

var udpPort = new osc.UDPPort({
    localAddress: 'localhost'
});
udpPort.open();

var server = app.listen(process.env.PORT || 3000, function () {
  var host = server.address().address;
  var port = server.address().port;
  logger.info('Listening at http://%s:%s', host, port);
});

// could pass encoder resolution here?
roboteq.connect({
  // these are limited internally as an error-check
  top: metersToEncoderUnits(11.40),
  bottom: metersToEncoderUnits(0.1),
  speedLimit: 1400,
github GamesDoneQuick / agdq18-layouts / extension / caspar.js View on Github external
files
	},
	osc: new EventEmitter()
};

function resetState() {
	foregroundFileName = '';
	currentFrame = 0;
	durationFrames = 0;
	fileMayHaveRestarted = false;
	ignoreForegroundUntilNextPlay = true;
}

nodecg.listenFor('caspar:play', module.exports.play);

const udpPort = new osc.UDPPort({
	localAddress: '0.0.0.0',
	localPort: nodecg.bundleConfig.casparcg.localOscPort,
	metadata: true
});

const emitForegroundChanged = debounce(() => {
	log.info('Media began playing: %s, %s, %s', new Date().toISOString(), foregroundFileName, currentRun.value.name);
	module.exports.osc.emit('foregroundChanged', foregroundFileName);
}, 250);

udpPort.on('message', message => {
	if (message.address === '/channel/1/stage/layer/0/file/frame') {
		const newCurrentFrame = message.args[0].value.low;
		const newDurationFrames = message.args[1].value.low;
		if (currentFrame !== newCurrentFrame || durationFrames !== newDurationFrames) {
			if (newCurrentFrame < currentFrame) {
github GamesDoneQuick / sgdq18-layouts / src / extension / caspar.ts View on Github external
foregroundFileName = '';
	currentFrame = 0;
	durationFrames = 0;
	fileMayHaveRestarted = false;
	ignoreForegroundUntilNextPlay = true;
}

export const replicants = {
	files
};

export const oscEvents = new EventEmitter();

nodecg.listenFor('caspar:play', module.exports.play);

const udpPort = new osc.UDPPort({
	localAddress: '0.0.0.0',
	localPort: nodecg.bundleConfig.casparcg.localOscPort,
	metadata: true
});

const emitForegroundChanged = debounce(() => {
	log.info('Media began playing: %s, %s, %s', new Date().toISOString(), foregroundFileName, currentRun.value.name);
	oscEvents.emit('foregroundChanged', foregroundFileName);
}, 250);

udpPort.on('message', (message: osc.OscMessage) => {
	const args = message.args as {[key: string]: any}[];

	if (message.address === '/channel/1/stage/layer/0/file/frame') {
		const newCurrentFrame = args[0].value.low;
		const newDurationFrames = args[1].value.low;
github colinbdclark / osc.js-examples / nodejs / index.js View on Github external
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;
};

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);
    });
});

udpPort.on("message", function (oscMessage) {
    console.log(oscMessage);
});
github TipoftheHats / toth5-overlay / extension / x32.js View on Github external
}

				talkbackIntent.value.techDirector[target] = false;
			}
		} else if (url === `/graphics/${nodecg.bundleName}/fm_talkback.html`) {
			for (const target in talkbackIntent.value.floorManager) {
				if (!{}.hasOwnProperty.call(talkbackIntent.value.floorManager, target)) {
					continue;
				}

				talkbackIntent.value.floorManager[target] = false;
			}
		}
	});

	const udpPort = new osc.UDPPort({
		localAddress: '0.0.0.0',
		localPort: 52361,
		remoteAddress: nodecg.bundleConfig.x32.address,
		remotePort: X32_UDP_PORT,
		metadata: true
	});

	udpPort.on('raw', buf => {
		const str = buf.toString('ascii');
		let valueBytes;

		for (const mixbus in MIXBUSES) {
			if (!{}.hasOwnProperty.call(MIXBUSES, mixbus)) {
				continue;
			}