示例#1
32
oscServer.on("message", function (msg, rinfo) {
    console.log("TUIO message:");
    console.log(msg);
    var body = null;
    if(msg[1]){
        body = JSON.parse(msg[1]);
    }

    if(msg[0] == "/fired"){
        Performance.findOne(body['performanceId']).exec(function (err, performance) {
            Performance.publishFiredFragmentForInstrument(
                performance,body["index"],body["trackName"]
            );
        });
        client.send('/messageReceived', body["messageId"]);
    }
    if(msg[0] == "/played"){
        Performance.findOne(body['performanceId']).exec(function (err, performance) {
            Performance.publishPlayedFragmentForInstrument(
                performance,body["index"],body["trackName"]
            );
        });
        client.send('/messageReceived', body["messageId"]);
    }

    if(msg[0] == "/getPerformances"){
        Performance.find({}).done(function (err, performances) {
            console.log(performances);
            client.send('/performances', JSON.stringify(performances));
        });
    }
});
示例#2
31
    socket.on("oscServer", function (obj) {
        console.log("Creating OSC-Server and -Client on Port 8081:");
    //    console.log(obj);
        oscServer = new osc.Server(obj.server.port, obj.server.host);
        console.log("Bridge listening as Server:: Host: " + obj.server.host + ", Port: " + obj.server.port);
        oscClient = new osc.Client(obj.client.host, obj.client.port);
        console.log("Bridge listening as Client:: Host: " + obj.client.host + ", Port: " + obj.client.port);
//        // send configConfirmation to webClient
//        socket.emit('oscServerConf',{
//            'outgoing':{'ip':obj.client.host,'port':obj.client.port},
//            'incoming':{'ip':obj.server.host,'port':obj.server.port}});
        
//        socket.join("session1"); //define session for each bunch of clients

        // send status==connected to "real" application
        oscClient.send('/status', 'connected to nodejs-bridge: \n\t\tlistening to ' + obj.client.port + "\n\t\tsending to " + obj.server.port);
        
        // awaits data from "real" application, forwards to webclient
        oscServer.on('message', function(msg, rinfo) {
            console.log(msg + " from RT-Application", rinfo);
            socket.emit("bydOsc", msg); //.broadcast to send to all webclients
        });
        
        // send oscData to "real" application
        socket.on("oscOut", function (obj, values) {
            var oscMessage = function(){
                var msg =  new osc.Message(obj); //'/address'
                switch(typeof values){
                    case 'object':
                        if(values instanceof Array){
                            for(var i = 0;i < values.length; i++){
                                console.log("value" + i + ":" + values[i]);
                                msg.append(values[i]);
                            }                            
                        }
                        else{
                            msg.append(values.toString());
                        }
                        break;
                    case 'string':
                        break;
                    default:
                        throw new Error("Error: not an object/ not a string/ not a well-formatted message.");
                }
                return msg;
            };
            
            console.log("sendToApplication::" + obj + " " + values.toString());
            oscClient.send(oscMessage());
//            oscClient.send(obj, parseFloat(val));
        });

  });
示例#3
16
  socket.on('config', function (obj) {
    console.log('config', obj);
    oscServer = new osc.Server(obj.server.port, obj.server.host);
    oscClient = new osc.Client(obj.client.host, obj.client.port);

    oscClient.send('/status', socket.id + ' connected');

    oscServer.on('message', function(msg, rinfo) {
      socket.emit('message', msg);
      console.log('sent OSC message to WS', msg, rinfo);
    });
  });
示例#4
10
文件: app_pre.js 项目: ogaksk/clm-osc
 setInterval( function () {
   if(emotionDatas.length > count) {
     oscClient1.send('/data', faceDatas[count]);
     oscClient2.send('/data', emotionDatas[count]);
     count += 1;
   } else {
     process.exit();
   }
 }, 1000 / fps);
示例#5
4
 User.findOne({uid: args[0]}, function(err, user){
   if(user){
     oscSender.send('/user/info', user.uid, "user.username", user.first_name, user.last_name, user.image, user.link, user.suzuri.size, user.suzuri.color);
   }else{
     oscSender.send('/user/info', -1);
   }
 });
示例#6
4
socket.on('from client', function(data) {
	console.log(data);
	
	if (data.board !== undefined && data.user !== undefined && data.yPos !== undefined) {
		client.send('/board', data.board);
		client.send('/user', data.user);
		client.send('/yPos', data.yPos);
		client.send('/toggle', data.toggle);
	}

	//Use to send data back
	// socket.emit('my other event', { my: 'data' });
});
示例#7
3
	socket.on("config", function (obj) {
		isConnected = true;
    	oscServer = new osc.Server(obj.server.port, obj.server.host);
	    oscClient = new osc.Client(obj.client.host, obj.client.port);
	    oscClient.send('/status', socket.sessionId + ' connected');
		oscServer.on('message', function(msg, rinfo) {
			socket.emit("message", msg);
		});
		socket.emit("connected", 1);
	});
示例#8
0
        socket.on("oscOut", function (obj, values) {
            var oscMessage = function(){
                var msg =  new osc.Message(obj); //'/address'
                switch(typeof values){
                    case 'object':
                        if(values instanceof Array){
                            for(var i = 0;i < values.length; i++){
                                console.log("value" + i + ":" + values[i]);
                                msg.append(values[i]);
                            }                            
                        }
                        else{
                            msg.append(values.toString());
                        }
                        break;
                    case 'string':
                        break;
                    default:
                        throw new Error("Error: not an object/ not a string/ not a well-formatted message.");
                }
                return msg;
            };
            
            console.log("sendToApplication::" + obj + " " + values.toString());
            oscClient.send(oscMessage());
//            oscClient.send(obj, parseFloat(val));
        });
示例#9
0
module.exports = function(user, dataType) {
  var client = new osc.Client('0.0.0.0', user.port);
  console.log('Stub for ' + user.username + ' started on port ' + user.port);

  Repeat(function() {
    switch (dataType) {
      case 'sine':
        client.send('/muse/elements/experimental/concentration', sine[index]);
        client.send('/muse/elements/experimental/mellow', 1 - sine[index]);
        if (index < sine.length - 1) {
          index++;
        } else {
          index = 0;
        }
        break;
      case 'portLSD':
        client.send('/muse/elements/experimental/concentration', (user.port - 5000) / 10);
        client.send('/muse/elements/experimental/mellow', (10 - (user.port - 5000)) / 10);
        break;
      case 'sine-portmod':
        var sinemodded = (sine[index] - ((user.port - 5000) / 20)) || 0;
        client.send('/muse/elements/experimental/concentration', sinemodded);
        client.send('/muse/elements/experimental/mellow', 1 - sinemodded);
        if (index < sine.length - 1) {
          index++;
        } else {
          index = 0;
        }
        break;
      default:

    }
  }).every(100, 'ms').start.now();
};
示例#10
0
	socket.on('clientMsg', function (data) {
		console.log(data.txt);
		//pass the msg on to the oscClient
 		var msg =  new osc.Message('/clientMsg')
 		msg.append(data.txt)
 		oscClient.send(msg)
	});
示例#11
0
 socket.on('ripplingColors', function(data) {
     console.log(data);
     //determine which slider
     for(var k in data) var key=k;
     k_lite = parseInt(k)+1;
     client.send("/1/fader"+k_lite, data[k]);
 });
示例#12
0
    function sendOSCMove() {

            if ( accellMove.x >  10 || accellMove.x < -10 ) {

                    accellMove.x = accellMove.x;

            } else {

                    accellMove.x = 0;
            }


            if ( accellMove.y <  -10  ) {

                    accellMove.y = -1;

            } else if ( accellMove.y >  10  ) {

                    accellMove.y = 1;
                    
            } else {

                accellMove.y = 0;
            }



            

            client.send('/move', accellMove.y , accellMove.x );

            console.log('Move',  " Y :" + accellMove.y + " X :" + accellMove.x );

    }
示例#13
0
	sendSection = function (sect) {
		var title = getSection(sect);
		io.sockets.emit('setSection', {sect: sect, title: title});
		// oscClient.send('/setSection', sect, title);
		oscClient.send('/causeway/currentSection', sect);

	};
示例#14
0
  socket.on('send message', function(data){
    var oscNum = Math.random();
    var oscMap = '/composition/video/effect3/opacity/values ' + oscNum;

    client.send('/composition/video/effect3/opacity/values', oscNum);
    console.log(oscMap);
  });
示例#15
0
/**
 * Process the text after updated in the client
 * @param  {String} text    The new text
 * @param  {Array} regExes An array of regular expressions for processing
 */
function processText(text, regExes) {
	var globalCount = 0,
		charsCount = text.length,
		wordsCount = text.split(/\s+/).length;

	// send global counts
	processChars(text, regExes);
	processWords(text, regExes);

	// parse for note messages
	parseNotes(text, regExes);

	// evaluate individual regexes
	regExes.forEach(function(re, i) {
		var matches = text.match(re),
			count;

		if(matches) {
			count = matches.length;
			globalCount += count;

		 	console.log('test re for exp '+i, matches, count);

		 	// send matches count for this regex
		 	sendToAll(getChannel('count', i), count, {count: count, rule: i, regExp: re.toString()});
		 	// oscClient.send(getChannel('count', i), count);
		}
	});


	console.log('send global matches count: ', globalCount);
	// send global matches count
	oscClient.send(getChannel('count'), globalCount);

}
示例#16
0
 myPort.on('data', function(data){
   var msg = data.split(',');
   var type = msg[0];
   var value = msg[1];
   if(type==='v'){
     currentVolume = value;
     oscClient.send('/someShit',currentMode,currentVolume);
   }
   else if(type==='m'){
     currentMode = value;
     oscClient.send('/someShit',currentMode,currentVolume);
   }
   else if(type==='calibrated'){
     myPort.options.setup = true;
     console.log('calibration complete...');
   }
   else console.log('FROM ARDUINO: '+ data);
 });
示例#17
0
    function sendOSCLook() {

            client.send('/look', accellLook.d, accellLook.x, accellLook.y );

            console.log('look', "  Z:" + accellLook.d + " X :" + accellLook.x  + " Y :" + accellLook.y);

            

    }
示例#18
0
    function sendOSCLook() {

            var thisLookD = ( accellLook.d/4 ),
                thisLookX = accellLook.x,
                thisLookY = accellLook.y;


            if ( thisLookD > 0 && thisLookD < 45 ){

                thisLookD = 0 -(thisLookD);

            } else if ( thisLookD >= 45 && thisLookD <=90){

                thisLookD = 90 - thisLookD;
            }

            thisLookD = ((thisLookD/45)*2);

            if ( thisLookD >= 1) {

                thisLookD = 1;

            } else if ( thisLookD <= -1) {

                    thisLookD = -1;

            }

            if ( thisLookX > 45 ){

                thisLookX = 45;

            } else if ( thisLookX < - 45 ) {

                thisLookX = -45;
            }

            if ( thisLookY > 45 ){

                thisLookY = 45;

            } else if ( thisLookY < - 45 ) {

                thisLookY = -45;
            }



            client.send('/look', thisLookD, thisLookX, thisLookY );

            console.log('look', "  Z:" + thisLookD + " X :" + thisLookX  + " Y :" + thisLookY);


            

    }
示例#19
0
  return new Promise((resolve, reject) => {
    osc.send('/dwdevices', colorArr, err => {
      if (err) {
        reject(err);
        return;
      }

      resolve();
    })
  })
  return new Promise((resolve, reject) => {
    osc.send(addr, msg, err => {
      if (err) {
        reject(err);
        return;
      }

      resolve();
    })
  })
示例#21
0
  _send(address, data) {
    if (!utils.addressExist(address)) {
      utils.logError(`OFBridge._send() : ${address} doesn't exist.`);
      return;
    }

    const d = data || '';
    utils.logInfo(`${d} sended at ${address}`);
    this._client.send(address, d);
  }
示例#22
0
	socket.on('item' , function(data) {
		console.log(socket.id + " tapped item: " + data);
		// TODO: Take out all the socket.broadcast.emits.
		// socket.broadcast.emit('chat', socket.id + " : " + data, 1);

	    if(io.sockets.connected[theaterID]!== null) {
	        io.sockets.connected[theaterID].emit('itemback', {phrase: data, color: socket.userColor}, 1);
	    }
		// socket.broadcast.emit('itemback', {phrase: data, color: socket.userColor}, 1);
		oscClient.send('/causeway/phrase/number', socket.id, data);
	});
示例#23
0
    socket.on('nx', function(data) {
        oscClient.send(data.oscName, data.value);
       
        // work out which widget param is being set
        var splitOscName = data.oscName.split('/');
        
        // update our cache with that info
        widgets[splitOscName[1]].properties[splitOscName[2]] = data.value;

        // tell other clients about change
        socket.broadcast.emit('update', splitOscName[1], splitOscName[2], data.value);
    });
示例#24
0
文件: osc.js 项目: 3000d/nevtelen
var OSC = function() {
  var self = this;
  var client = new osc.Client('127.0.0.1', 3333);

  this.sendEOD = function() {
    client.send('/EOD', 'true')
  };

  this.sendSOD = function() {
    client.send('/SOD', 'true')
  };
};
示例#25
0
  Repeat(function() {
    switch (dataType) {
      case 'sine':
        client.send('/muse/elements/experimental/concentration', sine[index]);
        client.send('/muse/elements/experimental/mellow', 1 - sine[index]);
        if (index < sine.length - 1) {
          index++;
        } else {
          index = 0;
        }
        break;
      case 'portLSD':
        client.send('/muse/elements/experimental/concentration', (user.port - 5000) / 10);
        client.send('/muse/elements/experimental/mellow', (10 - (user.port - 5000)) / 10);
        break;
      case 'sine-portmod':
        var sinemodded = (sine[index] - ((user.port - 5000) / 20)) || 0;
        client.send('/muse/elements/experimental/concentration', sinemodded);
        client.send('/muse/elements/experimental/mellow', 1 - sinemodded);
        if (index < sine.length - 1) {
          index++;
        } else {
          index = 0;
        }
        break;
      default:

    }
  }).every(100, 'ms').start.now();
示例#26
0
	regExes.forEach(function(re, i) {
		var matches = text.match(re)
			, notes;

		if(matches) {
			notes = _.uniq(matches.join().match(notesRegEx));

			if(notes && notes.length) {
				oscClient.send(createNotesMessage(getChannel('notes', i), notes));
			}
		}	

	});
示例#27
0
 socket.on('client-step-update', function (data) {
   // first, we store new state
   for( var track = 0; track < pattern.tracks.length; track++) {
     if(pattern.tracks[track].name == data.trackName) {
       // put the state update into the right place
       pattern.tracks[track].steps[data.step] = data.state;
       updateClient.send('/song_update',"(id: " + track + ", type: \"track\", data: " + JSON.stringify(pattern.tracks[track].steps) + ")");
     }
   }
   // and push it on to other peers
   readOnlySockets.emit("group-step-update", data);
   // people are still using the machine, so we extend the deadline
   lastChangeOccurred = new Date().getTime();
 });
示例#28
0
    function sendOSCMove() {

            if ( accellMove.y >  10 || accellMove.y < -10 ) {

                    accellMove.y = accellMove.y;

            } else {

                    accellMove.y = 0;
            }

            client.send('/move', accellMove.x, accellMove.y);

            console.log('Move',  " X :" + accellMove.x + " Y :" + accellMove.y );

    }
示例#29
0
文件: app_pre.js 项目: ogaksk/clm-osc
 socket.on("senddata", function(facedata, emotiondata) {
   if(fpsFlag == true) {
     oscClient2.send('/data', [emotiondata[0].value, emotiondata[1].value, emotiondata[2].value, emotiondata[3].value]);
     // if(facedata){
     //   oscClient2.send('/formant', [
     //   // 44 60 50 57
     //   degreeA(facedata[44][0], facedata[44][1], 
     //     facedata[60][0], facedata[60][1], 
     //     facedata[50][0], facedata[50][1], 
     //     facedata[57][0], facedata[57][1]
     //     ),
     //   degreeI(facedata[44][0], facedata[50][0], facedata[2][0], facedata[12][0]),
     //   degreeO(facedata[60][1], facedata[57][1], facedata[33][1], facedata[7][1]),
     //   ]);
     // }
   }
   fpsFlag = false;
 });
示例#30
0
	socket.on('addme', function(data) {
		username = data.name;
		var userColor = data.color;
		var userNote = data.note;
		var userLocation = data.location;

		if(username == "theater"){
			theaterID = socket.id;
			console.log("Hello Theater: " + theaterID);
		}

		if(username == "controller"){
			controllerID = socket.id;
			console.log("Hello Controller: " + controllerID);
		}

		if(username == "a_user") {
			ioClients.push(socket.id);
		}

		socket.username = username;  // allows the username to be retrieved anytime the socket is used
		// Can add any other pertinent details to the socket to be retrieved later
		socket.userLocation = userLocation;
		socket.userColor = userColor;
		socket.userNote = userNote;
		// .emit to send message back to caller.
		socket.emit('chat', 'SERVER: You have connected. Hello: ' + username + " " + socket.id + 'Color: ' + socket.userColor);
		// .broadcast to send message to all sockets.
		//socket.broadcast.emit('chat', 'SERVER: A new user has connected: ' + username + " " + socket.id + 'Color: ' + socket.userColor);
		// socket.emit('bump', socket.username, "::dude::");
		var title = getSection(currentSection);
		
		if(username == "a_user") {
			console.log("Hello:", socket.username, "currentSection:", currentSection, "id:", socket.id, "userColor:", socket.userColor, "userLocation:", socket.userLocation, "userNote:", socket.userNote);
		}

		socket.emit('setSection', {sect: currentSection, title: title});
		// io.sockets.emit('setSection', {sect: sect, title: title});
		if(username == "a_user") {
			oscClient.send('/causeway/registerUser', socket.id, socket.userColor, socket.userLocation[0],socket.userLocation[1], socket.userNote);
		}
	});