Пример #1
0
 private void DeconstructPacket(OscPacket oscPacket)
 {
     if (oscPacket is OscBundle)
     {
         OscBundle oscBundle = (OscBundle)oscPacket;
         oscTimeTagStack.Push(oscBundle.Timestamp);
         foreach (OscPacket bundleElement in oscBundle)
         {
             DeconstructPacket(bundleElement);
         }
         oscTimeTagStack.Pop();
     }
     else if (oscPacket is OscMessage)
     {
         OscMessage oscMessage = (OscMessage)oscPacket;
         if (oscTimeTagStack.Count > 0)
         {
             OscTimeTag oscTimeTag = oscTimeTagStack.Peek();
             textBoxBuffer.WriteLine(oscTimeTag.ToString() + " " + oscMessage.ToString());
         }
         else
         {
             textBoxBuffer.WriteLine(oscMessage.ToString());
         }
         receiveCounter.Increment();
     }
 }
    void raw_mellow(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        mellow = float.Parse(array_value[1]);         // To public array
    }
Пример #3
0
        private async Task SendPacketsAsync(OscPacket packet, CancellationToken cancellationToken)
        {
            try
            {
                int transmissionCount = 0;

                while (cancellationToken.IsCancellationRequested == false)
                {
                    IPEndPoint sourceEndPoint = new IPEndPoint(Program.ipAddress, Properties.Settings.Default.Port);
                    OscMessage labelMessage   = new OscMessage(sourceEndPoint, "/NuvoControl/ZoneName", String.Format("Hello {0}", transmissionCount));
                    labelMessage.Send(sourceEndPoint);

                    Console.Clear();
                    Console.WriteLine("Osc Transmitter: Udp");
                    Console.WriteLine("with IP Address={0} on Port={1}", sourceEndPoint.Address, sourceEndPoint.Port);
                    Console.WriteLine("IsBundle={0}", labelMessage.IsBundle);
                    if (!packet.IsBundle)
                    {
                        Console.WriteLine("Packet={0}", labelMessage.ToString());
                    }
                    Console.WriteLine("Transmission Count: {0}\n", ++transmissionCount);
                    Console.WriteLine("Press any key to exit.");

                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    void log_reg_intercept(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        intercept_ = float.Parse(array_value[1]);         // To public array
    }
    void raw_jaw_clench(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        jaw_clench = Convert.ToInt16(array_value[1]);         // To public array
    }
    void log_reg_accuracy(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        accuracy_ = float.Parse(array_value[1]);         // To public array
    }
Пример #7
0
 void OnOSCMessage(OscMessage message)
 {
     if (_messageStringQueue.Count >= messageBufferCapacity)
     {
         _messageStringQueue.Dequeue();
     }
     _messageStringQueue.Enqueue(message.ToString());
 }
    void raw_concentration(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        concentration = float.Parse(array_value[1]);         // To public array
        Debug.Log(concentration);
    }
Пример #9
0
        public void ToStringTest_NestedQuoteString()
        {
            string     expected = UnitTestHelper.MessageString_NestedQuoteString;
            OscMessage message  = UnitTestHelper.Message_NestedQuoteString();
            string     actual;

            actual = message.ToString();
            Assert.Equal(expected, actual);
        }
Пример #10
0
        // Send some keyboard event such as : F1, F2, ...
        void SendKeyboardEvent(KeyCode keyCode)
        {
            OscMessage message = new OscMessage(oscKeyCodeAddress);

            message.Add(keyCode.ToString());
            oscSend.Send(message);

            Debug.LogFormat("Sending keyboard event with ToryMessage : {0}", message.ToString());
        }
Пример #11
0
    void raw_drlref(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        float[]  float_value = new float[2];
        float_value[0] = float.Parse(array_value[1]);
        float_value[1] = float.Parse(array_value[2]);
        drlref         = float_value;      // To public array
    }
        void OnAnyMessage(OscMessage message)
        {
            if (_messageStringQueue.Count >= messageBufferCapacity)
            {
                _messageStringQueue.Dequeue();
            }
            _messageStringQueue.Enqueue(message.ToString());

            // Always recycle received messages, also when received from OscOut.
            OscPool.Recycle(message);
        }
Пример #13
0
        protected void OnOSCMessage(OscMessage message)
        {
            if (_messgeMonitorCounts.Count > messageBufferCapacity)
            {
                int count = _messgeMonitorCounts.Dequeue();
                _messageMonitorText.Remove(0, count);
            }
            int characterCountAdded = message.ToString(_messageMonitorText, true);

            _messgeMonitorCounts.Enqueue(characterCountAdded);
        }
Пример #14
0
    void OnReceiveName1(OscMessage message)
    {
        Name1 = message.ToString();

        if (Name1.Contains("/track1name"))
        {
            Name1.Replace("/track1name", "");
        }

        GetComponent <TextMesh>().text = Name1;
    }
Пример #15
0
    void GotFinalTranscript(OscMessage message)
    {
        string mess = message.ToString();
        int    pos  = mess.IndexOf(" ");

        mess = mess.Substring(pos, mess.Length - pos);

        text2.GetComponent <UnityEngine.UI.Text>().text = mess;

        queue.Add(mess);
    }
Пример #16
0
    void raw_horseshoe(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        float[]  float_value = new float[4];
        float_value[0] = float.Parse(array_value[1]);
        float_value[1] = float.Parse(array_value[2]);
        float_value[2] = float.Parse(array_value[3]);
        float_value[3] = float.Parse(array_value[4]);
        horseshoe      = float_value;         // To public array
    }
Пример #17
0
    void raw_notch_filtered_eeg(OscMessage value)
    {
        string string_value = value.ToString();

        string[] array_value = string_value.Split(' ');
        float[]  float_value = new float[4];
        float_value[0]     = float.Parse(array_value[1]);
        float_value[1]     = float.Parse(array_value[2]);
        float_value[2]     = float.Parse(array_value[3]);
        float_value[3]     = float.Parse(array_value[4]);
        notch_filtered_eeg = float_value;            // To public array
    }
    void PrintMessage(Text text, OscMessage oscMessage)
    {
        string newText = oscMessage.ToString();

        string[] texts = text.text.Split(Environment.NewLine.ToCharArray());

        text.text = newText + "\n";
        for (int i = 0; i < 15 && i < texts.Length; i++)
        {
            text.text += texts[i] + "\n";
        }
    }
Пример #19
0
    void AllMessageHandler(OscMessage message)
    {
        Debug.Log(message.ToString());

        var address = message.address.Split('/');

        if (address[1] == "processed")
        {
            _processed = true;
        }
        ;
    }
Пример #20
0
    void GotLiveTranscript(OscMessage message)
    {
        string mess = message.ToString();
        int    pos  = mess.IndexOf(" ");

        mess = mess.Substring(pos, mess.Length - pos);

        text2.GetComponent <UnityEngine.UI.Text>().text = mess;

        // add messages during live transcripts??
        // sort of chaotic lol
        // queue.Add(mess);
    }
Пример #21
0
    public void OscHandler(OscMessage om)
    {
        ArrayList oms = new ArrayList();        // make a list of replies

        OSCpage1(om, oms);
        cameraOverlay.OSCHandler(om, oms);
        OSCtext  = om.ToString();
        OSCtimer = 20;
        if (oms.Count > 0)                       // send any replies
        {
            osc.Send(oms);
        }
    }
Пример #22
0
        void Update()
        {
            // Create a bundle, add two messages with seperate addresses and values, then send.
            OscBundle bundle = new OscBundle();
            OscMessage message1 = new OscMessage( address1, Random.value );
            OscMessage message2 = new OscMessage( address2, Random.value );
            bundle.Add( message1 );
            bundle.Add( message2 );
            oscOut.Send( bundle );

            // Update UI.
            sendLabel1.text = message1.ToString();
            sendLabel2.text = message2.ToString();
        }
Пример #23
0
        void Update()
        {
            // Create a bundle, add two messages with seperate addresses and values, then send.
            OscBundle  bundle   = new OscBundle();
            OscMessage message1 = new OscMessage(address1, Random.value);
            OscMessage message2 = new OscMessage(address2, Random.value);

            bundle.Add(message1);
            bundle.Add(message2);
            oscOut.Send(bundle);

            // Update UI.
            sendLabel1.text = message1.ToString();
            sendLabel2.text = message2.ToString();
        }
Пример #24
0
    void OnData(OscMessage message)

    {
        string words = message.ToString();

        words = words.Substring(words.IndexOf(transcript) + transcript.Length);
        words = words.Replace("\\n", "");
        words = words.Replace("\"", "");
        words = words.Replace("}", "");
        words = words.Replace("{", "");

        output = words;
        if (output.Contains("("))
        {
            string[] input = output.Split('(', ')');
            output       = input[1];
            caption.text = "(" + output + ")";
            captiontime  = 8f;
        }

        string[] phrase = words.Split("."[0]);
        words = phrase[0];


        if (words.Length < 10)
        {
            words = phrase[1];
        }

        words = words.Replace(".", " ");
        words = words.Replace("Hamm", " ");
        words = words.Replace("ESTRAGON", "    ");
        words = words.Replace("VLADIMIR", "    ");
        words = words.Replace("GUIL", "     ");
        words = words.Replace("ROS", "     ");
        words = words.Replace("Pause", " ");
        words = words.Replace("Mr Paradock", "     ");
        words = words.Replace("Mrs Paradock", " ");
        words = words.Replace("no, no, no, no,", "no");
        words = words.Replace("no, no, no, no,", "no");
        words = words.Replace("no, no, no, no,", "no");
        words = words.Replace("no, no, no, no,", "no");


        tts.dialogue = words;
        tts.Speak();
        Debug.Log(words);
    }
    void log_reg_coefs(OscMessage value)
    {
        string string_value = value.ToString();

        Debug.Log(string_value);

        string[] array_value = string_value.Split(' ');
        //float[] float_value = new float[14];
        for (int i = 0; i < 12; i++)
        {
            float_value[i] = float.Parse(array_value[i + 1]);

            Debug.Log("Coeff b(" + i + "): " + float_value[i]);
        }
        coefs_ = float_value;
    }
Пример #26
0
    void GotResult(OscMessage message)
    {
        string mess = message.ToString();

        // remove header
        int pos = mess.IndexOf(" ");

        mess = mess.Substring(pos, mess.Length - pos);
        //phraseReady = true;
        PhraseResult = mess;

        Debug.Log("Phrase: " + mess);
        QueueText(PhraseResult);

        text1.GetComponent <UnityEngine.UI.Text>().text = mess;
    }
Пример #27
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            OscMessage message = new OscMessage();
            message.address = "/foo1";
            osc.Send(message);
            print(message.ToString());
            //message.address = "/IncreaseVolume";
            //message.values.Add(0.1f);
            //osc.Send(message);
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            OscMessage message = new OscMessage();
            message.address = "/foo2";
            osc.Send(message);
            print(message.ToString());
            //message.address = "/IncreaseVolume";
            //message.values.Add(0.1f);
            //osc.Send(message);
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            OscMessage message = new OscMessage();
            message.address = "/foo3";
            osc.Send(message);
            print(message.ToString());
            //message.address = "/IncreaseVolume";
            //message.values.Add(0.1f);
            //osc.Send(message);
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            OscMessage message = new OscMessage();
            message.address = "/foo4";
            osc.Send(message);
            print(message.ToString());
            //message.address = "/IncreaseVolume";
            //message.values.Add(0.1f);
            //osc.Send(message);
        }
    }
Пример #28
0
    void GotSources(OscMessage message)
    {
        string mess = message.ToString();
        // remove header
        int pos = mess.IndexOf(" ");

        mess = mess.Substring(pos, mess.Length - pos);
        string[] sources = mess.Split('#');

        //sourceWordsInPhrase = new List<List<string>>();
        //fullSourcePhrases = new List<string>();

        for (int i = 0; i < sources.Length; i++)
        {
            string[] src = sources[i].Split('@');
            sourceWordsInPhrase.Add(new List <string>(src[0].Split(' ')));
            fullSourcePhrases.Add(src[1]);
        }

        //sourcesReady = true;
    }
Пример #29
0
    /// <summary>
    /// Raises the receive event.
    /// </summary>
    /// <param name="packet">Packet.</param>

    void OnReceive(OscMessage packet)
    {
        OscMessage messageOSC   = new OscMessage();
        string     remoteHostIP = oscHandshaker.RemoteHost();

//		print ("address = "+packet.address+" full = "+packet.ToString ());
        if (packet.ToString() == "HELO")
        {
            Debug.Log("server says Hi, sending a Hello");

            messageOSC.address = "HELO";
            oscHandshaker.Send(messageOSC);
        }
        else if (packet.ToString() == "TEST")
        {
            messageOSC.address = "TEST";
            oscHandshaker.Send(messageOSC);
        }
        else if (packet.ToString() == "REQU")
        {
            RemoteClients();
            messageOSC.address = "REQU OK";
            oscHandshaker.Send(messageOSC);
        }
        else if (packet.ToString() == "PREL")
        {
            messageOSC.address = "PREL PRESET_NAME_LIST(test)";
            oscHandshaker.Send(messageOSC);
        }
        else if (packet.ToString() == "PREL OK")
        {
            connected = true;
        }
        else if (packet.ToString() == "CIAO")
        {
            oscInit   = true;
            connected = false;
        }
        else
        {
        }
    }
Пример #30
0
 void OnMessage1Received( OscMessage message )
 {
     // Update UI.
     receiveLabel1.text = message.ToString();
 }
 public void OnMessage(Connection source, MessageDirection direction, OscMessage message)
 {
     Print((direction == MessageDirection.Receive ? "RX " : "TX ") + message.ToString());
 }
Пример #32
0
 void OnMessage2Received( OscMessage message )
 {
     // Update UI
     receiveLabel2.text = message.ToString();
 }
Пример #33
0
 void OnMessage2Received(OscMessage message)
 {
     // Update UI
     receiveLabel2.text = message.ToString();
 }