OscMessageToString() public static méthode

General static helper that returns a string suitable for printing representing the supplied OscMessage.
public static OscMessageToString ( OscMessage, message ) : string
message OscMessage, The OscMessage to be stringified.
Résultat string
Exemple #1
0
 public void Example(OscMessage m)
 {
     Debug.Log("Called Example One > " + Osc.OscMessageToString(m));
     Debug.Log("Message Values > " + m.Values[0] + " " + m.Values[1]);
     yRot = (float)m.Values[0];
     zRot = (float)m.Values[1];
 }
Exemple #2
0
    public void AllMessageHandler(OscMessage oscMessage)
    {
        if (playerID == null)
        {
            return;
        }
        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]);
        }

        cam_pos = new Vector3(vals[9] * (playerID == "P1" ? -1 : 1), vals[10], -vals[11] * (playerID == "P1" ? -1 : 1) + 19) + anchor;

        left_hand_pos  = new Vector3(vals [33] * (playerID == "P1" ? -1 : 1) + anchor.x, vals [34], -vals [35] * (playerID == "P1" ? -1 : 1) + 19) + anchor;
        right_hand_pos = new Vector3(vals[21] * (playerID == "P1" ? -1 : 1), vals[22], -vals[23] * (playerID == "P1" ? -1 : 1) + 19) + anchor;

        left_elbow_pos  = new Vector3(vals[15] * (playerID == "P1" ? -1 : 1), vals[16], -vals[17] * (playerID == "P1" ? -1 : 1) + 19) + anchor;
        right_elbow_pos = new Vector3(vals [27] * (playerID == "P1" ? -1 : 1), vals [28], -vals [29] * (playerID == "P1" ? -1 : 1) + 19) + anchor;

        body_pos = new Vector3(vals[3] * (playerID == "P1" ? -1 : 1), vals[4], -vals[5] * (playerID == "P1" ? -1 : 1) + 19) + anchor;
    }
    /// <summary>
    /// Call SentFromPd function when the /sentFromPd OSC message is received.
    /// </summary>
    public void SentFromPd(OscMessage m)
    {
        string s = (Osc.OscMessageToString(m)).Substring(("/sentFromPd".Length + 1));

        // set the tank height variable to the float received from Pd
        m_size = System.Convert.ToSingle(s);
    }
Exemple #4
0
 //This is called when /wek/outputs arrives, since this is what's specified in Start()
 void Example1(OscMessage oscMessage)
 {
     Debug.Log("Called Example One > " + Osc.OscMessageToString(oscMessage));
     Debug.Log("Message Values > " + oscMessage.Values[0] + " " + oscMessage.Values[1]);
     sig1 = (float)oscMessage.Values[0];
     sig2 = (float)oscMessage.Values[1];
 }
Exemple #5
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     while (true)
     {
         int       count;
         int       i;
         ArrayList messages;
         String    message_string;
         Console.Write("get2\n");
         count = udpPacket.ReceivePacket(buffer);
         //Console.Write(Encoding.ASCII.GetString(buffer,0,count)+ "\r\n");
         Console.Write("read:" + count.ToString() + "\n");
         if (count != 0)
         {
             messages = Osc.PacketToOscMessages(buffer, count);
             for (i = 0; i < messages.Count; i++)
             {
                 message_string = Osc.OscMessageToString((OscMessage)messages[i]);
                 //                       output_box.Text = Osc.OscMessageToString((OscMessage)messages[i]) + Environment.NewLine + output_box.Text;
                 Invoke(new add_text_delegate(add_text), message_string);
                 Console.Write(message_string + "\n");
                 Console.Write(messages.Count.ToString() + "\n");
             }
         }
     }
 }
    public void getMellowInput(OscMessage oscMessage)
    {
        OscMessage m = oscMessage;

//		Debug.Log (m.Address);
        Osc.OscMessageToString(m);

        if (m.Address == "/muse/elements/experimental/mellow")
        {
            mellowValue = (float)(m.Values [0]);
        }


        if (m.Address == "/muse/elements/touching_forehead")
        {
            touchingForehead = (int)(m.Values [0]);
        }

        if (m.Address == "/muse/batt")
        {
            batteryPercentage = (int)(m.Values [0]);
            batteryPercentage = CustomFunc.Map(batteryPercentage, 0, 10000, 0, 100);
        }

        if (m.Address == "/muse/elements/blink")
        {
            blink = (int)m.Values [0];
        }


//		Osc.OscMessageToString(oscMessage);
//		mellowValue =  (float)(oscMessage.Values[0]);
//		Debug.Log("mellow: " + inputData );
    }
Exemple #7
0
    /// <summary>
    /// Example method that is called when /wek/outputs arrives (specified on Start)
    /// </summary>
    /// <param name="message"></param>
    public void Example1(OscMessage message)
    {
        // Debug calls to show how the osc message from Wekinator looks like
        Debug.Log("Called Example One > " + Osc.OscMessageToString(message));
        Debug.Log("Message Values > " + message.Values[0] + " " + message.Values[1]);

        // Get the two first values from the message
        sig1 = (float)message.Values[0];
        sig2 = (float)message.Values[1];
    }
Exemple #8
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]);
        }
    }
Exemple #9
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

        for (int i = 0; i < OSCcount; i++)
        {
            OSCvalues[i] = float.Parse(message.Values[i].ToString());
        }
    }
 void receiveWiimoteIR(OscMessage oscMessage)
 {
     Debug.Log("Received Wiimote > " + Osc.OscMessageToString(oscMessage));
     for (int i = 0; i < oscInputNames.Length; i++)
     {
         float x = scaler.x * (float)oscMessage.Values[0];
         float y = pos[i].y;
         float z = -1.0f * scaler.z * (float)oscMessage.Values[1];
         updatePos(i, x, y, z);
     }
 }
Exemple #11
0
    public void AllMessageHandler(OscMessage message)
    {
        Debug.Log("received message");
        //handler.Send("/message received");

        string msgString = Osc.OscMessageToString(message);         //the message and value combined

//		OscMessage oscM = Osc.StringToOscMessage(msgString);
//		handler.Send(oscM);

        //Debug.Log(msgString); //log the message and values coming from OSC

        string msgValue = msgString.Split("/"[0])[1];

        Debug.Log("message value is:" + msgValue.Substring(3, 2));
        //FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
        switch (msgValue)
        {
        case "1":
            //Debug.Log('we have a match');
            dim = orig_dim;
            break;

        case "2":
            //Debug.Log('we have a match');
            dim  = orig_dim;
            dim *= 2;
            break;

        case "3":
            //Debug.Log('we have a match');
            dim  = orig_dim;
            dim *= 3;
            break;

        case "trial_start":
            //Debug.Log('we have a match');
            gui_script.ChangeStatus("Trial has begun");
            trial_is_active = true;
            break;

        case "trial_end":
            //Debug.Log('we have a match');
            gui_script.ChangeStatus("Trial is done");
            ResetTrialParameters();
            SendMessage("trial is valid");
            break;

        default:
            Debug.Log("we dont have a match");
            break;
        }
    }
Exemple #12
0
    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;
    }
    //These functions are called when messages are received
    //Access values via: oscMessage.Values[0], oscMessage.Values[1], etc

    public void AllMessageHandler(OscMessage oscMessage)
    {
        var    msgString  = Osc.OscMessageToString(oscMessage); //the message and value combined
        string msgAddress = oscMessage.Address;                 //the message parameters
        var    msgValue   = oscMessage.Values[0];               //the message value

        Debug.Log("Entire msg: " + msgString);                  //log the message and values coming from OSC
        Debug.Log("Msg address: " + msgAddress);
        Debug.Log("Msg value: " + msgValue.ToString());

        var msgValueBool = msgValue.ToString() == "1" ? true : false;

        Debug.Log("Message value bool: " + msgValueBool);

        const string button1 = "/1/push1"; // Up
        const string button2 = "/1/push2"; // Down
        const string button3 = "/1/push3"; // Right
        const string button4 = "/1/push4"; // Left

        //FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
        switch (msgAddress)
        {
        case button1:
            Debug.Log("Moving Up");
            Catheter.MoveUp = msgValueBool;
            Debug.Log("Moved Up");
            break;

        case button2:
            Debug.Log("Moving down");
            Catheter.MoveDown = msgValueBool;
            Debug.Log("Moved down");
            break;

        case button3:
            Debug.Log("Rotating Right");
            Catheter.RotateRight = msgValueBool;
            Debug.Log("Rotated Right");
            break;

        case button4:
            Debug.Log("Rotating Left");
            Catheter.RotateLeft = msgValueBool;
            Debug.Log("Rotated Left");
            break;

        default:
            Debug.Log("Oops, got a message we didnt expect");
            break;
        }
    }
 void receiveKvl(OscMessage oscMessage)
 {
     Debug.Log("Received KVL Tracker > " + Osc.OscMessageToString(oscMessage));
     for (int i = 0; i < oscInputNames.Length; i++)
     {
         if ((int)oscMessage.Values[0] == 1)              //KVL tracker starts numbering at 1!
         {
             float x = scaler.x * (float)oscMessage.Values[3];
             float y = pos[i].y;
             float z = -1.0f * scaler.z * (float)oscMessage.Values[5];
             updatePos(i, x, y, z);
         }
     }
 }
Exemple #15
0
    //these fucntions are called when messages are received
    public void Example1(OscMessage oscMessage)
    {
        //How to access values:
        //oscMessage.Values[0], oscMessage.Values[1], etc
        //r01=(float)oscMessage.Values[1];
        rr = Osc.OscMessageToString(oscMessage);
        string str1 = rr.Replace("/myo1/emg/scaled ,ffffffff ", " ");
        string str2 = str1.Replace(" ", "/");

        str3 = str2.Split('/');
        //Debug.Log (str2);

        //Debug.Log("Called Example One > " + Osc.OscMessageToString(oscMessage));
    }
 void receiveOsceleton(OscMessage oscMessage)
 {
     Debug.Log("Received Osceleton > " + Osc.OscMessageToString(oscMessage));
     for (int i = 0; i < oscInputNames.Length; i++)
     {
         if ((string)oscMessage.Values[0] == (string)oscInputNames[i])
         {
             float x = scaler.x * (float)oscMessage.Values[2];
             float y = pos[i].y;
             float z = -1.0f * scaler.z * (float)oscMessage.Values[4];
             updatePos(i, x, y, z);
         }
     }
 }
Exemple #17
0
 public void lightFromOSC(OscMessage m)
 {
     Debug.Log("Called light from OSC >> " + Osc.OscMessageToString(m));
     //setText((string) m.Values[0]);
     string[] addressParts = m.Address.Split('/');
     Debug.Log("   Address Last Parts: " + addressParts[addressParts.Length - 1]);
     if (addressParts[addressParts.Length - 1] == "intensity")
     {
         lightLevel = (float)(((int)m.Values[0]) * 0.01);
     }
     if (addressParts[addressParts.Length - 1] == "direction")
     {
         xRot = (float)(((int)m.Values[0]) * 0.01);
         yRot = (float)(((int)m.Values[1]) * 0.01);
         zRot = (float)(((int)m.Values[2]) * 0.01);
     }
 }
    public void messageHandler(OscMessage oscMessage)
    {
        for (int i = 0; i < oscMessage.Values.Count; i++)
        {
            Debug.Log("int value:" + oscMessage.Values[i]);
        }
        int action            = (int)oscMessage.Values[0];
        int state_size        = 14;
        int num_objects       = 30;
        int num_angle_step    = 6;
        int num_scale_step    = 4;
        int num_dist_step     = 4;
        int num_rotation_bool = 2;


        if (action % num_rotation_bool == 0)
        {
            act_rotate = true;
        }
        else
        {
            act_rotate = false;
        }
        action    /= num_rotation_bool;
        act_scale  = action % num_scale_step;
        action    /= num_scale_step;
        act_dist   = action % num_dist_step;
        action    /= num_dist_step;
        act_angle  = action % num_angle_step;
        action    /= num_angle_step;
        act_object = action;

        objectSwaper.polarPosition    = act_angle;
        objectSwaper.rotation         = act_rotate;
        objectSwaper.scale            = act_scale;
        objectSwaper.distance         = act_dist;
        objectSwaper.newSelectedModel = act_object;


        Debug.Log("Called Example One > " + Osc.OscMessageToString(oscMessage));
        startFrameCounter = true;
        Debug.Log("after message sending");
    }
    public void AllMessageHandler(OscMessage oscMessage)
    {
        string msgString  = Osc.OscMessageToString(oscMessage); //the message and value combined
        string msgAddress = oscMessage.Address;                 //the message parameters
        //since we are just transferring double/float types I will just declare the message as float
        float msgValue = (float)oscMessage.Values[0];           //the message value

        /**if (calculated == false) {
         *      //Debug.Log(msgValue);
         *      testNumber++;
         * }**/

        //FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
        switch (msgAddress)
        {
        default:
            pushRates(msgValue);
            break;
        }
    }
Exemple #20
0
    public void textFromOSC(OscMessage m)
    {
        Debug.Log("Called text from OSC > " + Osc.OscMessageToString(m));
        string text     = (string)m.Values[0];
        string new_text = "";

        foreach (string t in text.Split(' '))
        {
            if (words.Contains(t))
            {
                new_text += "[" + t + "] ";
            }
            else
            {
                new_text += t + " ";
            }
        }

        setText(new_text);
    }
Exemple #21
0
 //these functions are called when messages are received
 void Example1(OscMessage oscMessage)
 {
     //How to access values:
     //oscMessage.Values[0], oscMessage.Values[1], etc
     Debug.Log("Called Example One > " + Osc.OscMessageToString(oscMessage));
     for (int i = 0; i < osceletonNames.Length; i++)
     {
         string name = (string)oscMessage.Values[0];
         if (name == osceletonNames[i])
         {
             float x = (float)oscMessage.Values[2];
             float y = (float)oscMessage.Values[3];
             float z = (float)oscMessage.Values[4];
             pos[i] = new Vector3(x, y, z);
             if (mirrorY)
             {
                 pos[i].y *= -1.0f;
             }
         }
     }
 }
    //These functions are called when messages are received
    //Access values via: oscMessage.Values[0], oscMessage.Values[1], etc

    public void AllMessageHandler(OscMessage oscMessage)
    {
        string msgString  = Osc.OscMessageToString(oscMessage); //the message and value combined
        string msgAddress = oscMessage.Address;                 //the message address

        Debug.Log(msgString);                                   //log the message and values coming from OSC
        bool sentMessage = false;

        foreach (OSCAnimation animator in scriptsToCall)
        {
            // send the message to the right OSCAnimator scripts
            if (animator.messageAddress.Equals(msgAddress))
            {
                animator.Animate(oscMessage);
                sentMessage = true;
            }
        }
        if (!sentMessage)
        {
            Debug.Log("OSC message with address " + msgAddress + " was not sent to any object");
        }
    }
    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;
        }
    }
Exemple #24
0
    public void AllMessageHandler(OscMessage message)
    {
        Debug.Log("received message");
        //handler.Send("/message received");

        string     msgString = Osc.OscMessageToString(message);     //the message and value combined
        OscMessage oscM      = Osc.StringToOscMessage(msgString);

        handler.Send(oscM);
        Debug.Log(msgString);         //log the message and values coming from OSC
        string msgValue = msgString.Split("/"[0])[1];

        //Debug.Log(msgValue);
        //FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
        switch (msgValue)
        {
        case "1":
            //Debug.Log('we have a match');
            dim = orig_dim;
            break;

        case "2":
            //Debug.Log('we have a match');
            dim  = orig_dim;
            dim *= 2;
            break;

        case "3":
            //Debug.Log('we have a match');
            dim  = orig_dim;
            dim *= 3;
            break;

        default:
            Debug.Log("we dont have a match");
            break;
        }
    }
    void RecMessage(OscMessage m)
    {
        //Debug.Log("--------------> OSC message received: ("+m+")");
        Debug.Log("--------------> OSC message received > " + Osc.OscMessageToString(m));

        // need the addr index to tell what object needs to be notified
        int i = 0;

        for (int a = 0; a < addrs.Length; a++)
        {
            if (addrs[a] == m.Address)
            {
                i = a;
            }
        }

        // save the index and the data, notify Update that a message needs to be sent out
        sendNeeded  = true;
        sendToIndex = i;
        data        = Osc.OscMessageToString(m);

        // >>>> TO DO: Messages could come in so fast that data could be lost - use lists
    }
    //These functions are called when messages are received
    //Access values via: oscMessage.Values[0], oscMessage.Values[1], etc
    void AllMessageHandler(OscMessage oscMessage)
    {
        string msgString  = Osc.OscMessageToString(oscMessage); //the message and value combined
        string msgAddress = oscMessage.Address;                 //the message parameters

        float posX = (float)oscMessage.Values[0];
        float posY = (float)oscMessage.Values[1];
        float posZ = (float)oscMessage.Values[2];

        Debug.Log(msgString);         //log the message and values coming from OSC
        //FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
        Debug.Log("message tag: " + msgAddress);
        switch (msgAddress)
        {
        case "/tracker/head/pos_xyz/cyclope_eye":
            Debug.Log("eye position received: " + posZ);
            Set_Position(posX, posY, posZ);
            break;

        default:
            break;
        }
    }
Exemple #27
0
    public void AllMessageHandler(OscMessage oscMessage)
    {
        string msgString  = Osc.OscMessageToString(oscMessage);     //the message and value combined
        string msgAddress = oscMessage.Address;                     //the message parameters
        float  msgValue0  = -((float)oscMessage.Values[0]) * 2 + 1; //the message value
        float  msgValue1  = -((float)oscMessage.Values[1]) * 2 + 1; //the message value

        switch (msgAddress)
        {
        case "/wii/irdata":
            if (msgValue0 != -1 && msgValue1 != -1)
            {
                tryShoot(msgValue0, msgValue1);
            }
            else
            {
                readyCount = 0;
            }
            break;

        default:
            break;
        }
    }
Exemple #28
0
    public void AllMessageHandler(OscMessage message)
    {
        Debug.Log("yessire!");
        //handler.Send("/message received");

        string msgString = Osc.OscMessageToString(message);         //the message and value combined

        Debug.Log("received message:" + msgString);
        msgString = msgString.Split("/"[0])[1];
        string[] msgType = ParseOscMessageForType(msgString);
//		SendMessage ("message_received:ready");

//		OscMessage oscM = Osc.StringToOscMessage("message received");
//		handler1.Send(oscM);

        Debug.Log("here!");
        //Debug.Log(msgString); //log the message and values coming from OSC
        Debug.Log("message type is:" + msgType[0]);
        Debug.Log("message content is:" + msgType[1]);

        //FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
        switch (msgType[0])
        {
        case "trial_status":
            compute.ParseTrialStatus(msgType[1]);
            break;

        case "sphere_sizes":
            compute.SetSphereSizes(msgType[1]);
            break;

        default:
            Debug.Log("we dont have a match");
            break;
        }
    }
Exemple #29
0
 public void Find(OscMessage m)
 {
     Debug.Log("Finding > " + m.Address);
     //Find()
     Debug.Log("Called Example One > " + Osc.OscMessageToString(m));
 }
Exemple #30
0
 //these functions are called when messages are received
 void Example2(OscMessage oscMessage)
 {
     //How to access values:
     //oscMessage.Values[0], oscMessage.Values[1], etc
     Debug.Log("Called Example Two > " + Osc.OscMessageToString(oscMessage));
 }