Example #1
0
    public void OSCCallback(OscMessage m)
    {
        if (verbose) {
            string command = (string) m.Values[0];
            string osc_report_string = "";
            //print("OSC command is " + command);
            for (int i = 0; i < m.Values.Count; i++) {
                osc_report_string = osc_report_string + "Values[" + i + "]: " + m.Values[i] + "***";
            }
            //print("osc_report_string: " + osc_report_string + "\n");
        }

        oscMessagesToSend.Add(m);

        //obsolete code, but we do need to figure out how to better handle MIDI notes,
        //or if we should even handle them at all (and instead only use CC)
        /*
        if(command == "midievent") {
            midiEventReceiver((string)m.Values[1], (int)m.Values[2], (int)m.Values[3]);
        }
        else if (command == "scenechange") {
            if (verbose) {
                Debug.Log("SCENE CHANGE!!!!!!!!!");
            }
            sceneChange = (int) m.Values[1];
        }
        else if (command == "cc") {

            //string messageName = "onCC";

        }
        */
    }
        void Update()
        {
            // If we are going to send 'as bundle', then we would like OSC io
            // to add the timetag to the messeges contained in the bundle.
            oscIn.addTimeTagsToBundledMessages = sendAsBundle;

            // Create a messege
            OscMessage message = new OscMessage( address );

            // Create a timetag. Default time is DateTime.Now.
            OscTimeTag timetag = new OscTimeTag();

            // Make it 1 milisecond into the future.
            timetag.time = timetag.time.AddMilliseconds( 1 );

            // Two possible methods for sending timetags ...
            if( sendAsBundle )
            {
                // Either create a bundle with the timetag, add the message and send.
                OscBundle bundle = new OscBundle( timetag );
                bundle.Add( message );
                oscOut.Send( bundle );
            } else {
                // Or add the timetag to message and send it.
                message.Add( timetag );
                oscOut.Send( message );
            }

            // Update label.
            sendLabel.text = timetag.time + ":" + timetag.time.Millisecond;
        }
Example #3
0
    protected override void ReceiveMessage(OscMessage message)
    {
        // Debug.Log(message);

        /*        // addresses must be listed in Inspector/Osc Addresses
        if (message.Address.Equals("/vicon/Position0"))
        {
            var v = new Vector3((float)(double)message[0], (float)(double)message[2] - 1, (float)(double)message[1]);
            playerController.transform.localPosition = v;
        }
        else if (message.Address.Equals("/vicon/Quaternion0"))
        {
            //var q = new Quaternion((float)(double)message[0], (float)(double)message[1], (float)(double)message[2], (float)(double)message[3]);
        }
        else*/ if (message.Address.Equals("/niw/client/aggregator/floorcontact"))
        {
            // Floor input
            int id = (int)message[1];
            float x = (((float)message[2]) / 6.0f);
            float z = (((float)message[3]) / 6.0f);
            var position = new Vector3(x, 0, z);
            Debug.Log(position);

            RacketObject.GetComponent<Racket>().SendMessage("SetPosition", new Vector3(0, 0, x));

        }
    }
Example #4
0
	public void AllMessageHandler(OscMessage oscMessage) {
		string msg = Osc.OscMessageToString (oscMessage).Substring (1);
		string[] _vals = msg.Split (' ');
		float[] vals = new float[_vals.Length];
		for (int i = 0; i < vals.Length; i++)
			vals[i] = float.Parse(_vals[i]);
	}
Example #5
0
        private static OscBundle CreateTestBundle()
        {
            IPEndPoint sourceEndPoint = new IPEndPoint(IPAddress.Loopback, Port);
            OscBundle bundle = new OscBundle(sourceEndPoint);

            OscBundle nestedBundle = new OscBundle(sourceEndPoint);
            OscMessage nestedMessage = new OscMessage(sourceEndPoint, TestMethod);
            nestedMessage.AppendNil();
            nestedMessage.Append("Some String");
            nestedMessage.Append(10);
            nestedMessage.Append(100000L);
            nestedMessage.Append(1234.567f);
            nestedMessage.Append(10.0012345);
            nestedMessage.Append(new byte[] { 1, 2, 3, 4 });
            nestedMessage.Append(new OscTimeTag());
            nestedMessage.Append('c');
            nestedMessage.Append(Color.DarkGoldenrod);
            nestedMessage.Append(true);
            nestedMessage.Append(false);
            nestedMessage.Append(float.PositiveInfinity);
            nestedBundle.Append(nestedMessage);
            bundle.Append(nestedBundle);

            OscMessage message = new OscMessage(sourceEndPoint, AliveMethod);
            message.Append(9876.543f);
            bundle.Append(message);

            return bundle;
        }
    public void AllMessageHandler(OscMessage message){
        
        Debug.Log(message);
        Debug.Log("stuff sent");
        string msgAddress = message.Address; //the message parameters
        string msgString =  Osc.OscMessageToString(message); //the message and value combined
        float myValue = (float)message.Values[0];
        
        int iValue = Mathf.RoundToInt(myValue);
        yRot = iValue;
        
        Debug.Log(msgAddress);
        
        //FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
	switch (msgAddress){
		case "/1/push1":
			xRot = iValue;
			break;
		case "/1/push2":
			yRot = iValue;
			break;
		case "/1/push3":
			zRot = iValue;
			break;
		case "/1/fader1":
			scaleVal = 1+iValue;
			break;
		
		default:
			//
			break;
	}

    }
Example #7
0
 private void BuildBeatMessage(int[][] score, OscMessage m)
 {
     for (var trackCount = 0; trackCount < numberOfTracks; trackCount++)
     {
         BuildTrackMessage(score, m, trackCount);
     }
 }
Example #8
0
    // called every time Unity receives a message
    public void MessageHandler(OscMessage message)
    {
        // string msgString = Osc.OscMessageToString(message);
        //MainDebug.WriteLine(msgString);     // writing out the message to see if everything works correctly
        //Debug.Log (msgString);

        // clean debug message

        string debugLine = "received for adress : ";
        debugLine += message.Address + " with values : ";
        int j = 0;
        foreach (object o in message.Values) {
            debugLine += o.ToString () + ", ";
            OSCvalues [j] = float.Parse (message.Values [j].ToString ());
            j++;
        }
        Debug.Log (debugLine);

        if (message.Address == "/gain"){
            float gain = float.Parse(message.Values[0].ToString());
            colorCorrect.gain = Mathf.Pow (10,(gain*2));
        }

        if (message.Address == "/gamma"){
            float gamma = float.Parse(message.Values[0].ToString());
            colorCorrect.gamma = 1/(gamma*2);
        }

        if (message.Address == "/black"){
            colorCorrect.black = float.Parse(message.Values[0].ToString());
        }
    }
Example #9
0
 private void Broadcast(OscMessage message)
 {
     foreach (var oscSender in this.oscSenders)
     {
         oscSender.Send(message);
     }
 }
    public void WiiMoteOscMsgHandler(OscMessage oscMeg)
    {
        //Debug.Log (oscMeg.Address);
        ArrayList values = oscMeg.Values;
        string[] strings;
        if (!initialFlag)
            initialFlag = true;
        for (int i = 0; i < values.Count; i++) {

            strings = values[i].ToString().Split(':');

            Debug.Log (i + ":  "+ values[i]);

            if(int.Parse(strings[1]) == 1)
                ir_state[i] = true;
            else
                ir_state[i] = false;

            string[] positionStrings = strings[2].Split(',');

            float positionX = float.Parse(positionStrings[0]);

            float positionY = float.Parse(positionStrings[1]);

            ir_position[i] = new Vector2(positionX,positionY);

            WiiVRUpdate();

        }
    }
Example #11
0
        private void SendMessage(Action<OscMessage> appendAction)
        {
            var message = new OscMessage(endPoint, "/");

            appendAction(message);

            message.Send(endPoint);
        }
Example #12
0
    public override void OSCMessageReceiver(OscMessage message)
    {
        if (emit) {
            emitter.Emit();
        }

        Debug.Log("Message...");
    }
Example #13
0
 public void Send(OscMessage msg)
 {
     if (m_SendController != null)
     {
         // Send the message
         m_SendController.Sender.Send(msg);
     }
 }
Example #14
0
 public void MetaHandler(OscMessage oscMessage)
 {
     library.step = (int)oscMessage.Values[0];
     library.numSteps = (int)oscMessage.Values[1];
     int numPatterns = (int)oscMessage.Values[2];
     library.SetNumPatterns(numPatterns);
     Debug.Log("Meta found");
 }
Example #15
0
 public override void OSCMessageReceiver(OscMessage message)
 {
     float x = System.Convert.ToInt32(message.Values[2]) / 127.0f;
     //print(x);
     renderer.material.color = new Color(System.Convert.ToInt32(message.Values[2]) / 127.0f,
                                         renderer.material.color.g,
                                         renderer.material.color.b,
                                         renderer.material.color.a);
 }
    void Ta_filler0(OscMessage oscMessage)
    {
        for( int i = 0; i <= 5; i++) {

        trackarray[i] = (float)oscMessage.Values[i];
        //Debug.Log("htrack : "+(float)oscMessage.Values[i]);

        }
    }
        void OnMessageReceived( OscMessage message )
        {
            // Get the time tag.
            OscTimeTag timeTag;
            if( !message.TryGet( 0, out timeTag ) ) return;

            // Update label.
            receiveLabel.text = timeTag.time + ":" + timeTag.time.Millisecond;
        }
        void OnMessageReceived( OscMessage message )
        {
            // Get the value
            float value;
            if( !message.TryGet( 0, out value ) ) return;

            // Update label
            receiveLabel.text = value.ToString();
        }
Example #19
0
        public void TestLong()
        {
            long num = 123456789012345;
            var msg = new OscMessage("/test/1", num);
            var bytes = msg.GetBytes();

            var msg2 = (OscMessage)OscPacket.GetPacket(bytes);

            Assert.AreEqual(num, msg2.Arguments[0]);
        }
Example #20
0
        public void TestDouble()
        {
            double val = 1234567.2324521e36;

            var msg = new OscMessage("/test/1", val);
            var bytes = msg.GetBytes();

            var msg2 = (OscMessage)OscPacket.GetPacket(bytes);
            Assert.AreEqual(val, ((double)msg2.Arguments[0]));
        }
Example #21
0
 public override void OSCMessageReceiver(OscMessage message)
 {
     float x = System.Convert.ToInt32(message.Values[2]) / 127.0f;
     x *= 25;
     if (x > 0) {
         pe.maxSize = x;
         pe.minSize = x;
         pe.Emit();
     }
 }
Example #22
0
        public void TestBlob()
        {
            var blob = new byte[5] { 23, 65, 255, 12, 6 };

            var msg = new OscMessage("/test/1", blob);
            var bytes = msg.GetBytes();

            var msg2 = (OscMessage)OscPacket.GetPacket(bytes);
            Assert.AreEqual(blob, ((byte[])msg2.Arguments[0]));
        }
Example #23
0
 public static string OscMessageToString(OscMessage message)
 {
     StringBuilder s = new StringBuilder();
     s.Append(message.Address);
     foreach(object o in message.Values) {
         s.Append(" ");
         s.Append(o.ToString());
     }
     return s.ToString();
 }
 //these fucntions are called when messages are received
 void receiveKinectA(OscMessage oscMessage)
 {
     Debug.Log("Received KinectA > " + Osc.OscMessageToString(oscMessage));
     for(int i=0;i<oscInputNames.Length;i++){
         float x = scaler.x * (float) oscMessage.Values[1];
         float y = pos[i].y;
         float z = -1.0f * scaler.z * (float) oscMessage.Values[3];
         updatePos(i,x,y,z);
     }
 }
Example #25
0
        public void TestTimetag()
        {
            var val = DateTime.Now;
            var tag = new Timetag(val);

            var msg = new OscMessage("/test/1", tag);
            var bytes = msg.GetBytes();

            var msg2 = (OscMessage)OscPacket.GetPacket(bytes);
            Assert.AreEqual(tag.Tag, ((Timetag)msg2.Arguments[0]).Tag);
        }
 public void oscReceiver(OscMessage oscMsg)
 {
     //Debug.Log("Event name: " + Osc.OscMessageToString(oscMsg));
     if (oscMsg.Values != null && oscMsg.Values.Count > 0) {
         string msg = oscMsg.Values [0].ToString().TrimEnd();
         Debug.Log("Event data:" + msg);
         if(msg.Equals("I'm bt1")) {
             Debug.Log ("Yes, bt1");
         }
     }
 }
Example #27
0
        public void TestNoAddress()
        {
            var msg = new OscMessage("", 9999, 24.24f);
            var bytes = msg.GetBytes();

            var msg2 = (OscMessage)OscPacket.GetPacket(bytes);

            Assert.AreEqual("", msg2.Address);
            Assert.AreEqual(9999, msg2.Arguments[0]);
            Assert.AreEqual(24.24f, msg2.Arguments[1]);
        }
Example #28
0
        private static void SendMessage(string messageText)
        {
            var message = new OscMessage(endPoint, "/");

            foreach (var item in messageText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                message.Append(item);
            }

            message.Send(endPoint);
        }
Example #29
0
        private void BuildTrackMessage(int[][] score, OscMessage m, int trackCount)
        {
            if (IsShortTrack(score, trackCount))
            {
                positions[trackCount] = 0;
            }

            if (HasBeat(score, trackCount)) m.Append(trackCount + 1);

            ProgressTrackPosition(trackCount);
        }
    public void AllMessageHandler(OscMessage message){
        
        Debug.Log(message);
        Debug.Log("stuff sent");
    
        string msgString =  Osc.OscMessageToString(message); //the message and value combined
        float myValue = (float)message.Values[0];
        
        int iValue = Mathf.RoundToInt(myValue);
        yRot = iValue;

    }
 void Recibir(OscMessage m)
 {
     Debug.Log("Recibido");
     Debug.Log(m.GetInt(0));
 }
    static public void MapScaleSingle(OscMessage message, Transform transform)
    {
        float x = message.GetFloat(0);

        transform.localScale = new Vector3(x, x, x);
    }
Example #33
0
 private void OnReceiveFearful(OscMessage message)
 {
     Fearful = message.GetFloat(0);
 }
Example #34
0
 private void OnReceiveNeutral(OscMessage message)
 {
     Neutral = message.GetFloat(0);
 }
Example #35
0
 private void OnReceiveAngry(OscMessage message)
 {
     Angry = message.GetFloat(0);
 }
Example #36
0
 /// <summary>
 /// Parse a single argument
 /// </summary>
 /// <param name="str">string contain the argument to parse</param>
 /// <returns>the parsed argument</returns>
 public static object ParseArgument(string str)
 {
     return(OscMessage.ParseArgument(str, CultureInfo.InvariantCulture));
 }
Example #37
0
 /// <summary>
 /// Parse a single argument
 /// </summary>
 /// <param name="str">string contain the argument to parse</param>
 /// <param name="provider">format provider to use</param>
 /// <returns>the parsed argument</returns>
 public static object ParseArgument(string str, IFormatProvider provider)
 {
     return(OscMessage.ParseArgument(str, provider));
 }
Example #38
0
    /// <summary>
    /// Creates an OscMessage from a string - extracts the address and determines each of the values.
    /// </summary>
    /// <param name="message">The string to be turned into an OscMessage</param>
    /// <returns>The OscMessage.</returns>
    public static OscMessage StringToOscMessage(string message)
    {
        OscMessage oM = new OscMessage();

        Console.WriteLine("Splitting " + message);
        string[]    ss = message.Split(new char[] { ' ' });
        IEnumerator sE = ss.GetEnumerator();

        if (sE.MoveNext())
        {
            oM.address = (string)sE.Current;
        }
        while (sE.MoveNext())
        {
            string s = (string)sE.Current;
            // Console.WriteLine("  <" + s + ">");
            if (s.StartsWith("\""))
            {
                StringBuilder quoted = new StringBuilder();
                bool          looped = false;
                if (s.Length > 1)
                {
                    quoted.Append(s.Substring(1));
                }
                else
                {
                    looped = true;
                }
                while (sE.MoveNext())
                {
                    string a = (string)sE.Current;
                    // Console.WriteLine("    q:<" + a + ">");
                    if (looped)
                    {
                        quoted.Append(" ");
                    }
                    if (a.EndsWith("\""))
                    {
                        quoted.Append(a.Substring(0, a.Length - 1));
                        break;
                    }
                    else
                    {
                        if (a.Length == 0)
                        {
                            quoted.Append(" ");
                        }
                        else
                        {
                            quoted.Append(a);
                        }
                    }
                    looped = true;
                }
                oM.values.Add(quoted.ToString());
            }
            else
            {
                if (s.Length > 0)
                {
                    try
                    {
                        int i = int.Parse(s);
                        // Console.WriteLine("  i:" + i);
                        oM.values.Add(i);
                    }
                    catch
                    {
                        try
                        {
                            float f = float.Parse(s);
                            // Console.WriteLine("  f:" + f);
                            oM.values.Add(f);
                        }
                        catch
                        {
                            // Console.WriteLine("  s:" + s);
                            oM.values.Add(s);
                        }
                    }
                }
            }
        }
        return(oM);
    }
Example #39
0
        private void oscReceiverWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            UDPListener udpListener     = null;
            bool        reinit          = true;
            OscMessage  messageReceived = null;

            int nameUpdateCounter = 0;

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            while (runThread)
            {
                try
                {
                    if (udpListener == null || reinit)
                    {
                        try
                        {
                            udpListener = new UDPListener(PORT);
                            reinit      = false;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Couldn't create udp listener");
                        }
                    }

                    /**
                     * Tuning Packet Descriptor
                     * Actual Value, Requested Value, IAccum, System Name
                     */
                    if (!initCompleted)
                    {
                        //Initialize the connection
                        sendIAccumReset();
                        initCompleted = true;
                    }

                    messageReceived = (OscMessage)udpListener.Receive();
                    if (messageReceived != null)
                    {
                        switch (messageReceived.Address)
                        {
                        case "/PIDData":
                            double timestamp    = (DateTime.Now - programLaunchTime).TotalSeconds;
                            double actualVal    = (double)messageReceived.Arguments[0];
                            double requestedVal = (double)messageReceived.Arguments[1];
                            dataChart.Invoke((MethodInvoker) delegate()
                            {
                                dataChart.Series[0].Points.AddXY(timestamp, actualVal);
                                dataChart.Series[1].Points.AddXY(timestamp, requestedVal);
                                for (int i = 0; i < dataChart.Series.Count; i++)
                                {
                                    while (dataChart.Series[i].Points.Count > CONSTRAINED_CHART_SIZE)
                                    {
                                        dataChart.Series[i].Points.RemoveAt(0);
                                    }
                                }
                                dataChart.ResetAutoValues();
                            });
                            if (stopWatch.ElapsedMilliseconds > 200)
                            {
                                //Update TextBox UI Every 200ms to avoid slowing down the app
                                double iAccum = (double)messageReceived.Arguments[2];
                                double err    = requestedVal - actualVal;
                                averageError.AddEntry(err);
                                txtActualVal.Invoke((MethodInvoker) delegate { txtActualVal.Text = actualVal.ToString("0.####"); });
                                txtDesiredVal.Invoke((MethodInvoker) delegate { txtDesiredVal.Text = requestedVal.ToString("0.####"); });
                                txtDeviation.Invoke((MethodInvoker) delegate { txtDeviation.Text = err.ToString("0.####"); });
                                txtAverageDev.Invoke((MethodInvoker) delegate { txtAverageDev.Text = averageError.Average.ToString("0.####"); });
                                txtIAccum.Invoke((MethodInvoker) delegate { txtIAccum.Text = iAccum.ToString("0.####"); });

                                if (nameUpdateCounter++ % 5 == 0)
                                {
                                    txtSysName.Invoke((MethodInvoker) delegate { txtSysName.Text = (string)messageReceived.Arguments[3]; });
                                }

                                stopWatch.Restart();
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    Thread.Sleep(1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    try
                    {
                        udpListener.Close();
                    }
                    catch (Exception)
                    {
                    }
                    reinit = true;
                }
            }

            udpListener.Close();
        }
Example #40
0
 /// <summary>
 /// Creates a packet (an array of bytes) from a single OscMessage.
 /// </summary>
 /// <remarks>A convenience method, not requiring a start index.</remarks>
 /// <param name="oscM">The OscMessage to be returned as a packet.</param>
 /// <param name="packet">The packet to be populated with the OscMessage.</param>
 /// <param name="length">The usable size of the array of bytes.</param>
 /// <returns>The length of the packet</returns>
 public static int OscMessageToPacket(OscMessage oscM, byte[] packet, int length)
 {
     return(OscMessageToPacket(oscM, packet, 0, length));
 }
Example #41
0
 public void OnReceiveSurfaceType(OscMessage message)
 {
     app.Notify(Notification.SurfaceTypeUpdateOsc, message);
 }
Example #42
0
 public void OnRecentSphereTypeIdUpdate(OscMessage message)
 {
     app.Notify(Notification.SphereTypeRecentIdUpdateOsc, message);
 }
Example #43
0
 private void OnReceiveHappy(OscMessage message)
 {
     Happy = message.GetFloat(0);
 }
    private void OnReceiveSineMax(OscMessage message)
    {
        float x = message.GetFloat(0);

        _testVfx.SetFloat(_sineMax, x);
    }
Example #45
0
 private void OnReceiveSurprised(OscMessage message)
 {
     Surprised = message.GetFloat(0);
 }
Example #46
0
 public static void Example(OscMessage m)
 {
     Debug.Log("--------------> OSC example message received: (" + m + ")");
 }
Example #47
0
 void enviarListaModelos(OscMessage message)
 {
     listaDeModelos.enviar();
 }
Example #48
0
 void enviarListaPartes(OscMessage message)
 {
     listaDePartes.enviar();
 }
Example #49
0
 private void OnReceiveDisgusted(OscMessage message)
 {
     Disgusted = message.GetFloat(0);
 }
        private void OnMessage(OscMessage message)
        {
            //エラー時はそれ以上受信しない
            if (ReceiveError)
            {
                return;
            }
            try
            {
                if (message.Address == "/VMT/Out/Log")
                {
                    int    stat = (int)message[0];
                    string msg  = (string)message[1];

                    switch (stat)
                    {
                    case 0:
                        MessageBox.Show(msg, title, MessageBoxButton.OK, MessageBoxImage.Information);
                        break;

                    case 1:
                        MessageBox.Show(msg, title, MessageBoxButton.OK, MessageBoxImage.Warning);
                        break;

                    case 2:
                        MessageBox.Show(msg, title, MessageBoxButton.OK, MessageBoxImage.Error);
                        break;

                    default:
                        MessageBox.Show(msg, title, MessageBoxButton.OK);
                        break;
                    }
                }
                else if (message.Address == "/VMT/Out/Alive")
                {
                    //Keep Alive
                    this.Dispatcher.Invoke(() =>
                    {
                        DriverVersion.Text = (string)message[0];
                        if (message.Count > 1 && message[1] is string)
                        {
                            installPath = (string)message[1];
                        }

                        ControlDock.IsEnabled = true;

                        if ((string)message[0] != Version)
                        {
                            DriverVersion.Foreground = new SolidColorBrush(Color.FromRgb(255, 100, 100));
                        }
                        else
                        {
                            DriverVersion.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                        }

                        aliveCnt = 0;
                    });
                }
                else if (message.Address == "/VMT/Out/Haptic")
                {
                    //振動
                    this.Dispatcher.Invoke(() =>
                    {
                        InputVMTHapticTextBox.Text       = string.Format("VMT_{0,0} f:{1:0.0}Hz A:{2:0.0} d:{3:0.0}s", (int)message[0], (float)message[1], (float)message[2], (float)message[3]);
                        InputVMTHapticTextBox.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                    });
                }
                else
                {
                    //Do noting
                }
            }
            catch (Exception ex)
            {
                ReceiveError = true;
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, title);
                this.Dispatcher.Invoke(() =>
                {
                    Close();
                });
                return;
            }
        }
    void InvokeMapping(OscMapping mapping, OscMessage message)
    {
        switch (mapping.type)
        {
        case OscMessageType.OscMessage:
            mapping.OscMessageHandler.Invoke(message);
            break;

        case OscMessageType.Float:
            float floatValue;
            if (message.TryGet(0, out floatValue))
            {
                mapping.FloatHandler.Invoke(floatValue);
            }
            break;

        case OscMessageType.Double:
            double doubleValue;
            if (message.TryGet(0, out doubleValue))
            {
                mapping.DoubleHandler.Invoke(doubleValue);
            }
            break;

        case OscMessageType.Int:
            int intValue;
            if (message.TryGet(0, out intValue))
            {
                mapping.IntHandler.Invoke(intValue);
            }
            break;

        case OscMessageType.Long:
            long longValue;
            if (message.TryGet(0, out longValue))
            {
                mapping.LongHandler.Invoke(longValue);
            }
            break;

        case OscMessageType.String:
            string stringValue = string.Empty;
            if (message.TryGet(0, ref stringValue))
            {
                mapping.StringHandler.Invoke(stringValue);
            }
            break;

        case OscMessageType.Char:
            char charValue;
            if (message.TryGet(0, out charValue))
            {
                mapping.CharHandler.Invoke(charValue);
            }
            break;

        case OscMessageType.Bool:
            bool boolValue;
            if (message.TryGet(0, out boolValue))
            {
                mapping.BoolHandler.Invoke(boolValue);
            }
            break;

        case OscMessageType.Color:
            Color32 colorValue;
            if (message.TryGet(0, out colorValue))
            {
                mapping.ColorHandler.Invoke(colorValue);
            }
            break;

        case OscMessageType.Midi:
            OscMidiMessage midiValue;
            if (message.TryGet(0, out midiValue))
            {
                mapping.MidiHandler.Invoke(midiValue);
            }
            break;

        case OscMessageType.Blob:
            byte[] blobValue = null;
            if (message.TryGet(0, ref blobValue))
            {
                mapping.BlobHandler.Invoke(blobValue);
            }
            break;

        case OscMessageType.TimeTag:
            OscTimeTag timeTagValue;
            if (message.TryGet(0, out timeTagValue))
            {
                mapping.TimeTagHandler.Invoke(timeTagValue);
            }
            break;

        case OscMessageType.ImpulseNullEmpty:
            mapping.ImpulseNullEmptyHandler.Invoke();
            break;
        }
    }
 void ApagarAntena4(OscMessage m)
 {
     totem4.GetComponent <totem>().ApagarTotem();
 }
Example #53
0
        /// <summary>
        /// Handles the face frame data arriving from the sensor
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void Reader_FaceFrameArrived(object sender, FaceFrameArrivedEventArgs e)
        {
            using (FaceFrame faceFrame = e.FrameReference.AcquireFrame())
            {
                if (faceFrame != null)
                {
                    // check if this face frame has valid face frame results
                    if (this.ValidateFaceBoxAndPoints(faceFrame.FaceFrameResult) && faceFrame.TrackingId == this.currentTrackingId)
                    {
                        // store this face frame result to draw later
                        this.faceFrameResult = faceFrame.FaceFrameResult;
                        var        address = "/osceleton2/face/rotation";
                        var        q       = this.faceFrameResult.FaceRotationQuaternion;
                        OscMessage message = new OscMessage(address, q.W, q.X, q.Y, q.Z);
                        if (oscSender != null)
                        {
                            oscSender.Send(message);
                        }

                        var isHappy = this.faceFrameResult.FaceProperties[FaceProperty.Happy];
                        int happy   = -1;
                        if (isHappy == DetectionResult.Yes)
                        {
                            happy = 2;
                        }
                        else if (isHappy == DetectionResult.Maybe)
                        {
                            happy = 1;
                        }
                        else if (isHappy == DetectionResult.No)
                        {
                            happy = 0;
                        }
                        address = "/osceleton2/face/happy";
                        message = new OscMessage(address, happy);
                        if (oscSender != null)
                        {
                            oscSender.Send(message);
                        }

                        address = "/osceleton2/face/id";
                        message = new OscMessage(address, (int)this.currentTrackingId);
                        if (oscSender != null)
                        {
                            oscSender.Send(message);
                        }

                        var isMouthOpen = this.faceFrameResult.FaceProperties[FaceProperty.MouthOpen];
                        int mouthOpen   = -1;
                        if (isMouthOpen == DetectionResult.Yes)
                        {
                            mouthOpen = 2;
                        }
                        else if (isMouthOpen == DetectionResult.Maybe)
                        {
                            mouthOpen = 1;
                        }
                        else if (isMouthOpen == DetectionResult.No)
                        {
                            mouthOpen = 0;
                        }
                        address = "/osceleton2/face/mouthopen";
                        message = new OscMessage(address, mouthOpen);
                        if (oscSender != null)
                        {
                            oscSender.Send(message);
                        }
                    }
                    else
                    {
                        // indicates that the latest face frame result from this reader is invalid
                        this.faceFrameResult = null;
                    }
                }
            }
        }
 void PrenderAntena4(OscMessage m)
 {
     totem4.GetComponent <totem>().EncenderTotem();
 }
Example #55
0
    // Creates an array of bytes from a single OscMessage.  Used internally.
    private static int OscMessageToPacket(OscMessage oscM, byte[] packet, int start, int length)
    {
        int index = start;

        index = InsertString(oscM.Address, packet, index, length);
        //if (oscM.Values.Count > 0)
        {
            StringBuilder tag = new StringBuilder();
            tag.Append(",");
            int tagIndex = index;
            index += PadSize(2 + oscM.Values.Count);

            foreach (object o in oscM.Values)
            {
                if (o is int)
                {
                    int i = (int)o;
                    tag.Append("i");
                    packet[index++] = (byte)((i >> 24) & 0xFF);
                    packet[index++] = (byte)((i >> 16) & 0xFF);
                    packet[index++] = (byte)((i >> 8) & 0xFF);
                    packet[index++] = (byte)((i) & 0xFF);
                }
                else
                {
                    if (o is float)
                    {
                        float f = (float)o;
                        tag.Append("f");
                        byte[]       buffer = new byte[4];
                        MemoryStream ms     = new MemoryStream(buffer);
                        BinaryWriter bw     = new BinaryWriter(ms);
                        bw.Write(f);
                        packet[index++] = buffer[3];
                        packet[index++] = buffer[2];
                        packet[index++] = buffer[1];
                        packet[index++] = buffer[0];
                    }
                    else
                    {
                        if (o is string)
                        {
                            tag.Append("s");
                            index = InsertString(o.ToString(), packet, index, length);
                        }
                        else
                        {
                            tag.Append("?");
                        }
                    }
                }
            }
            InsertString(tag.ToString(), packet, tagIndex, length);
            {
                string s = "antes:";
                for (int i = tagIndex; i < PadSize(2 + oscM.Values.Count); ++i)
                {
                    s += "_";
                }
                //Debug.Log("Message=" + index + " obj:" + oscM.Values.Count + " ->\"" + s + "\"");
            }
        }


        return(index);
    }
Example #56
0
 private void OnReceiveSad(OscMessage message)
 {
     Sad = message.GetFloat(0);
 }
Example #57
0
 public void OnReceiveGetRoomInfo(OscMessage message)
 {
     app.Notify(Notification.RoomInfoGetOsc, message);
 }
Example #58
0
 public void OnSphereTypeLiveUpdate(OscMessage message)
 {
     app.Notify(Notification.SphereTypeLiveUpdateOsc, message);
 }
Example #59
0
 public void OnReceiveShootSpeed(OscMessage message)
 {
     app.Notify(Notification.PlayerShootSpeedOsc, message);
 }
Example #60
0
        private void sendIAccumReset(double sendVal)
        {
            var message = new OscMessage("/IReset", sendVal);

            oscSender.Send(message);
        }