The Osc class provides the methods required to send, receive, and manipulate OSC messages. Several of the helper methods are static since a running Osc instance is not required for their use. When instanciated, the Osc class opens the PacketIO instance that's handed to it and begins to run a reader thread. The instance is then ready to service Send OscMessage requests and to start supplying OscMessages as received back. The Osc class can be called to Send either individual messages or collections of messages in an Osc Bundle. Receiving is done by delegate. There are two ways: either submit a method to receive all incoming messages or submit a method to handle only one particular address. Messages can be encoded and decoded from Strings via the static methods on this class, or can be hand assembled / disassembled since they're just a string (the address) and a list of other parameters in Object form.
Inheritance: MonoBehaviour
    void Start()
    {
        // initialize udp and osc stuff (both necessary for OSC network communication)
        UDPPacketIO udp = new UDPPacketIO();

        udp.init(oscSenderIp, sendToPort, listenerPort);

        oscHandler = new Osc();
        oscHandler.init(udp);

        // oscHandler.SetAddressHandler("/rigidbody", onRigidBody);
        oscHandler.SetAllMessageHandler(onOscMessage);

        // the rigidBodyObject attribute shouldn't logically be part of this class, but is added as
        // a convenience property to quick and easily visualize the mocap rigid bodies by just specifieing
        // an object to visually represent the rigid bodies. We'll outsource all the logic to the
        // MoCapRigidBodiesCloner class whose tasks is exactly this.
        if (rigidBodyObject)
        {
            // create a GameObject to hold all the rigid bodies
            GameObject go = new GameObject();
            go.name = "GeneratedRigidBodies";
            // add the cloner component
            MoCapRigidBodiesCloner cloner = go.AddComponent <MoCapRigidBodiesCloner>();
            // give it the specified object and let it take care of the rest
            cloner.rigidBodyObject = rigidBodyObject;
        }
    }
    private void Socket_MessageReceived(Windows.Networking.Sockets.DatagramSocket sender,
                                        Windows.Networking.Sockets.DatagramSocketMessageReceivedEventArgs args)
    {
        Debug.Log("Datagram socket message received");

        //Read the message that was received from the UDP echo client.
        Stream streamIn = args.GetDataStream().AsStreamForRead();

        byte[] msg = ReadToEnd(streamIn);

        ArrayList messages = Osc.PacketToOscMessages(msg, msg.Length);

        foreach (OscMessage om in messages)
        {
            if (AllMessageHandler != null)
            {
                try
                {
                    AllMessageHandler(om);
                }
                catch (Exception e)
                {
                    Debug.Log(e.ToString());
                    return;
                }
            }
        }
    }
Exemplo n.º 3
0
    // Read Thread.  Loops waiting for packets.  When a packet is received, it is
    // dispatched to any waiting All Message Handler.  Also, the address is looked up and
    // any matching handler is called.
    private void Read()
    {
        try
        {
            while (ReaderRunning)
            {
                byte[] buffer;
                int    length = OscPacketIO.ReceivePacket(out buffer, packetSize);
                string s      = "";
                for (int i = 0; i < length; ++i)
                {
                    s += (char)buffer[i];
                }
                //Debug.Log("received packed of len=" + length + " ::" + s);
                if (length > 0)
                {
                    ArrayList messages = Osc.PacketToOscMessages(buffer, length);
                    if (messages.Count < 1)
                    {
                        Debug.LogWarning("Empty package");
                    }
                    foreach (OscMessage om in messages)
                    {
                        if (AllMessageHandler != null)
                        {
                            AllMessageHandler(om);
                        }
                        else
                        {
                            Debug.LogWarning("No all handler");
                        }
                        OscMessageHandler h = (OscMessageHandler)Hashtable.Synchronized(AddressTable)[om.Address];
                        if (h != null)
                        {
                            h(om);
                        }

                        /*else
                         * {
                         *  Debug.LogWarning("No custom handler");
                         * }*/
                    }
                }
                else
                {
                    Thread.Sleep(20);
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log("ThreadAbortException" + e);
        }
        finally
        {
            //Debug.Log("terminating thread - clearing handlers");
            //Cancel();
            //Hashtable.Synchronized(AddressTable).Clear();
        }
    }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            for (int i = 0; i < args.Length && i < 3; i++)
            {
                if (i == 0)
                {
                    dstIP = args[i];
                }
                else if (i == 1)
                {
                    sendToPort = int.Parse(args[i]);
                }
                else if (i == 2)
                {
                    listenToPort = int.Parse(args[i]);
                }
            }

            Console.WriteLine("current IP is " + dstIP + ",sendToPort:" + sendToPort + ",listenToPort:" + listenToPort);

            udpManager = new UDPPacketIO();
            udpManager.init(dstIP, sendToPort, listenToPort);
            oscManager = new Osc();
            oscManager.init(udpManager);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MultipleWiimoteForm());
        }
Exemplo n.º 5
0
    // Sends a list of OSC Messages.  Internally takes the OscMessage objects and
    // serializes them into a byte[] suitable for sending to the PacketExchange.

    //oms - The OSC Message to send.
    public void Send(ArrayList oms)
    {
        byte[] packet = new byte[1000];
        int    length = Osc.OscMessagesToPacket(oms, packet, 1000);

        OscPacketIO.SendPacket(packet, length);
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        GameObject monomeSquare = (GameObject)Resources.Load("Square");
        int        row          = 0;

        while (row < amountRows)
        {
            for (int i = 0; i < amountPerRow; i++)
            {
                Vector3    pos   = new Vector3((-i * 1.2f), 0, row * 1.2f);
                GameObject clone = Instantiate(monomeSquare, gameObject.transform.position + pos, Quaternion.identity) as GameObject;
                clone.transform.parent = gameObject.transform;
                clone.SendMessage("SetID", (row * amountPerRow) + (i + 1));
                clone.tag = "col" + (i + 1);
            }
            row++;
        }

        if (udp = (UDPPacketIO)gameObject.GetComponent("UDPPacketIO"))
        {
            udp.init(OSCHost, SendToPort, ListenerPort);

            handler = (Osc)gameObject.GetComponent("Osc");
            handler.init(udp);
            handler.SetAddressHandler("/press", IncomingValues);
            handler.SetAddressHandler("/sync", ResetTime);
        }

        OSCHandler.Instance.Init();

        startTime = Time.time;
    }
    void Update()
    {
        OscMessage msg;

        msg = Osc.StringToOscMessage("/camhead "
                                     + camhead.transform.position.x + " "
                                     + camhead.transform.position.y + " "
                                     + camhead.transform.position.z + " "
                                     + camhead.transform.rotation.x + " "
                                     + camhead.transform.rotation.y + " "
                                     + camhead.transform.rotation.z
                                     );
        osc.Send(msg);
        msg = Osc.StringToOscMessage("/ctrlleft "
                                     + ctrlleft.transform.position.x + " "
                                     + ctrlleft.transform.position.y + " "
                                     + ctrlleft.transform.position.z + " "
                                     + ctrlleft.transform.rotation.x + " "
                                     + ctrlleft.transform.rotation.y + " "
                                     + ctrlleft.transform.rotation.z
                                     );
        osc.Send(msg);
        msg = Osc.StringToOscMessage("/ctrlright "
                                     + ctrlright.transform.position.x + " "
                                     + ctrlright.transform.position.y + " "
                                     + ctrlright.transform.position.z + " "
                                     + ctrlright.transform.rotation.x + " "
                                     + ctrlright.transform.rotation.y + " "
                                     + ctrlright.transform.rotation.z
                                     );
        osc.Send(msg);
    }
Exemplo n.º 8
0
	void Start () {
		UDPPacketIO udp = (UDPPacketIO) GetComponent ("UDPPacketIO");
		udp.init (remoteIP, sendToPort, listenerPort);
		handler = (Osc) GetComponent ("Osc");
		handler.init(udp);
		handler.SetAllMessageHandler(AllMessageHandler);
	}
Exemplo n.º 9
0
    /// <summary>
    /// Sends a list of OSC Messages.  Internally takes the OscMessage objects and
    /// serializes them into a byte[] suitable for sending to the PacketExchange.
    /// </summary>
    /// <param name="oms">The OSC Message to send.</param>
    public void Send(ArrayList oms)
    {
        byte[] packet = new byte[MAX_BUFFER_SIZE];
        int    length = Osc.OscMessagesToPacket(oms, packet, MAX_BUFFER_SIZE);

        OscPacketIO.SendPacket(packet, length);
    }
Exemplo n.º 10
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;
    }
Exemplo n.º 11
0
 void OnDisable()
 {
     // close UDP socket of the listener
     Debug.Log("Closing UDP socket");
     osc.Cancel();
     osc = null;
 }
Exemplo n.º 12
0
    public static void ResetServo()
    {
        OscMessage oscM = Osc.StringToOscMessage("/unity/reset ");

        handler.Send(oscM);
        print("OSC sent: ResetServo");
    }
Exemplo n.º 13
0
    public void setup(int port)
    {
        if (_isSetUp)
        {
            return;
        }

        Debug.Log("OscReceiver SETUP: " + port);
        _isSetUp = true;

        UDPPacketIO udp;

        udp = this.gameObject.GetComponent <UDPPacketIO>();
        if (udp == null)
        {
            udp = this.gameObject.AddComponent <UDPPacketIO>();
        }
        udp.Init("", port, false);

        oscHandler = this.gameObject.GetComponent <Osc>();
        if (oscHandler == null)
        {
            oscHandler = this.gameObject.AddComponent <Osc>();
        }
//        oscHandler.init(udp);
        oscHandler.initReader(udp);
    }
Exemplo n.º 14
0
    // Send an individual OSC message.  Internally takes the OscMessage object and
    // serializes it into a byte[] suitable for sending to the PacketIO.
    public void Send(OscMessage oscMessage)
    {
        byte[] packet = new byte[1000];
        int    length = Osc.OscMessageToPacket(oscMessage, packet, 1000);

        OscPacketIO.SendPacket(packet, length);
    }
Exemplo n.º 15
0
    //	float lastTime=0;

    void Start()
    {
        udp = this.GetComponent <UDPPacketIO>();
        udp.init(UDPHost, broadcastPort, listenerPort);
        oscHandler = this.gameObject.AddComponent <Osc>();
        oscHandler.init(udp);
    }
Exemplo n.º 16
0
 /// <summary>
 /// Shut down OSC connection nicely.
 /// </summary>
 void OnDisable()
 {
     // close OSC UDP socket
     // Debug.Log("closing OSC UDP socket in OnDisable");
     oscHandler.Cancel();
     oscHandler = null;
 }
Exemplo n.º 17
0
    public void Start()
    {
        //Initializes on start up to listen for messages
        //make sure this game object has both UDPPackIO and OSC script attached

        UDPPacketIO udp = (UDPPacketIO)GetComponent("UDPPacketIO");

        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = (Osc)GetComponent("Osc");
        handler.init(udp);
        handler.SetAllMessageHandler(AllMessageHandler);


        tornadoSlider    = GameObject.Find("Tornado Slider").GetComponent <UnityEngine.UI.Slider>();
        munchkinSlider   = GameObject.Find("Munchkin Slider").GetComponent <UnityEngine.UI.Slider>();
        poppySlider      = GameObject.Find("Poppy Slider").GetComponent <UnityEngine.UI.Slider>();
        monkeySlider     = GameObject.Find("Monkey Slider").GetComponent <UnityEngine.UI.Slider>();
        fireSlider       = GameObject.Find("Fire Slider").GetComponent <UnityEngine.UI.Slider>();
        transSpeedSlider = GameObject.Find("Transition Slider").GetComponent <UnityEngine.UI.Slider>();


        nv = GameObject.Find("Network").GetComponent <NetworkView>();

        Debug.Log("Osc Running");
    }
Exemplo n.º 18
0
	//	float lastTime=0;

	void Start () {
		
		udp  = this.GetComponent<UDPPacketIO>();
		udp.init(UDPHost, broadcastPort, listenerPort);
		oscHandler = this.gameObject.AddComponent<Osc>();
		oscHandler.init(udp);
	}
Exemplo n.º 19
0
    /// <summary>
    /// Send an individual OSC message.  Internally takes the OscMessage object and
    /// serializes it into a byte[] suitable for sending to the PacketIO.
    /// </summary>
    /// <param name="oscMessage">The OSC Message to send.</param>
    public void Send(OscMessage oscMessage)
    {
        byte[] packet = new byte[MAX_BUFFER_SIZE];
        int    length = Osc.OscMessageToPacket(oscMessage, packet, MAX_BUFFER_SIZE);

        OscPacketIO.SendPacket(packet, length);
    }
Exemplo n.º 20
0
    public void udpSend(string text)
    {
        mct.WriteLine("UDP < " + text);
        OscMessage oscM = Osc.StringToOscMessage(text);

        oscUdp.Send(oscM);
    }
Exemplo n.º 21
0
	public void Start ()
	{
		//Initializes on start up to listen for messages
		//make sure this game object has both UDPPackIO and OSC script attached
		
		UDPPacketIO udp = (UDPPacketIO)GetComponent("UDPPacketIO");
		udp.init(RemoteIP, SendToPort, ListenerPort);
		handler = (Osc)GetComponent("Osc");
		handler.init(udp);
		handler.SetAllMessageHandler(AllMessageHandler);


		tornadoSlider = GameObject.Find("Tornado Slider").GetComponent<UnityEngine.UI.Slider>();
		munchkinSlider = GameObject.Find("Munchkin Slider").GetComponent<UnityEngine.UI.Slider>();
		poppySlider = GameObject.Find("Poppy Slider").GetComponent<UnityEngine.UI.Slider>();
		monkeySlider = GameObject.Find("Monkey Slider").GetComponent<UnityEngine.UI.Slider>();
		fireSlider = GameObject.Find("Fire Slider").GetComponent<UnityEngine.UI.Slider>();
		transSpeedSlider = GameObject.Find("Transition Slider").GetComponent<UnityEngine.UI.Slider>();


		nv = GameObject.Find("Network").GetComponent<NetworkView>();

		Debug.Log("Osc Running");
		
	}
Exemplo n.º 22
0
    MCTest()
    {
        mct = new MCTestForm(this);

        //usbPacket = new UsbWin32Packet();
        usbPacket = new UsbPacket();
        usbPacket.Open();
        if (usbPacket.IsOpen())
        {
            mct.SetUsbPortName(usbPacket.Name);
        }
        oscUsb = null;
        oscUsb = new Osc(usbPacket);
        oscUsb.SetAllMessageHandler(UsbMessages);

        udpPacket = new UdpPacket();
        udpPacket.RemoteHostName = mct.GetUdpRemoteHostName();
        udpPacket.RemotePort     = mct.GetUdpRemotePort();
        udpPacket.LocalPort      = mct.GetUdpLocalPort();
        udpPacket.Open();
        oscUdp = new Osc(udpPacket);
        oscUdp.SetAllMessageHandler(UdpMessages);
        oscUdp.SetAddressHandler("/analogin/0/value", AIn0Message);

        Application.Run(mct);
    }
Exemplo n.º 23
0
 void OnDisable()
 {
     // close OSC UDP socket
     Debug.Log("closing OSC UDP socket in OnDisable");
     oscHandler.Cancel();
     oscHandler = null;
 }
    void Start()
    {
        pos  = new Vector3[oscInputNames.Length];
        ppos = new Vector3[oscInputNames.Length];

        //Initializes on start up to listen for messages
        //make sure this game object has both UDPPackIO and OSC script attached
        udp = (UDPPacketIO)GetComponent("UDPPacketIO");
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = (Osc)GetComponent("Osc");
        handler.init(udp);

        /*
         * handler.SetAddressHandler("/objects/ID-centralXYZ", receiveKinectA); //KinectA blob tracker
         * handler.SetAddressHandler("/skeletons/ID-centralXYZ", receiveKinectA); //KinectA blob tracker
         *
         * handler.SetAddressHandler("/tracker", receiveSoniskel); //Processing SimpleOpenNI skeleton tracker
         *
         * handler.SetAddressHandler("/kinect/blobs", receiveKvl); //KVL blob tracker
         */

        handler.SetAddressHandler("/joint", receiveOsceleton);         //OSCeleton skeleton tracker

        //handler.SetAddressHandler("/wii/1/accel/pry", receiveWiimoteAccel); //Osculator Wiimote tracker
        handler.SetAddressHandler("/wii/1/accel/xyz", receiveWiimoteAccel);
        //handler.SetAddressHandler("/wii/1/motion/angles", receiveWiimoteAccel);
        //handler.SetAddressHandler("/wii/1/motion/velo", receiveWiimoteAccel);

        //handler.SetAddressHandler("/wii/1/ir", receiveWiimoteIR);
    }
Exemplo n.º 25
0
    /// <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);
    }
Exemplo n.º 26
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,OSC,Contato,Telefone")] Osc osc)
        {
            if (id != osc.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(osc);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OscExists(osc.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(osc));
        }
Exemplo n.º 27
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RazaoSocial,Nome,Cnpj,Responsavel,Email,Telefone,Cep," +
                                                             "Endereço,Numero,Complemento,Bairro,Cidade,Estado,Contato,Observacao")] Osc osc)
        {
            if (id != osc.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(osc);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OscExists(osc.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(osc));
        }
Exemplo n.º 28
0
    public void setup(string host_, int port_)
    {
        if (_isSetUp)
        {
            return;
        }

        Debug.Log("OscSender SETUP: " + host_ + " / " + port_);
        host     = host_;
        port     = port_;
        _isSetUp = true;

        UDPPacketIO udp;

        udp = this.gameObject.GetComponent <UDPPacketIO>();
        if (udp == null)
        {
            udp = this.gameObject.AddComponent <UDPPacketIO>();
        }
        udp.enableQueue = false;
        udp.Init(host_, port_, true);

        oscHandler = this.gameObject.GetComponent <Osc>();
        if (oscHandler == null)
        {
            oscHandler = this.gameObject.AddComponent <Osc>();
        }
        oscHandler.init(udp);
    }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        GameObject monomeSquare = (GameObject) Resources.Load("Square");
        int row = 0;
        while (row < amountRows) {
            for (int i=0; i < amountPerRow; i++) {
                Vector3 pos = new Vector3((-i*1.2f),0, row*1.2f);
                GameObject clone = Instantiate(monomeSquare, gameObject.transform.position + pos, Quaternion.identity) as GameObject;
                clone.transform.parent = gameObject.transform;
                clone.SendMessage("SetID", (row * amountPerRow) + (i+1));
                clone.tag = "col" + (i+1);
            }
            row++;
        }

        if(udp = (UDPPacketIO) gameObject.GetComponent("UDPPacketIO")) {
            udp.init(OSCHost, SendToPort, ListenerPort);

            handler = (Osc) gameObject.GetComponent("Osc");
            handler.init(udp);
            handler.SetAddressHandler("/press", IncomingValues);
            handler.SetAddressHandler("/sync", ResetTime);
        }

        OSCHandler.Instance.Init();

        startTime = Time.time;
    }
Exemplo n.º 30
0
 /// <summary>
 /// Read Thread.  Loops waiting for packets.  When a packet is received, it is
 /// dispatched to any waiting All Message Handler.  Also, the address is looked up and
 /// any matching handler is called.
 /// </summary>
 private void Read()
 {
     while (ReaderRunning)
     {
         Debug.Log("Read");
         byte[] buffer = new byte[1000];
         int    length = OscPacketIO.ReceivePacket(buffer);
         if (length > 0)
         {
             ArrayList messages = Osc.PacketToOscMessages(buffer, length);
             foreach (OscMessage om in messages)
             {
                 if (AllMessageHandler != null)
                 {
                     AllMessageHandler(om);
                 }
                 OscMessageHandler h = (OscMessageHandler)Hashtable.Synchronized(AddressTable)[om.Address];
                 if (h != null)
                 {
                     h(om);
                 }
             }
         }
         else
         {
             Thread.Sleep(500);
         }
     }
 }
Exemplo n.º 31
0
    public void usbSend(string text)
    {
        mct.WriteLine("USB < " + text);
        OscMessage oscM = Osc.StringToOscMessage(text);

        oscUsb.Send(oscM);
    }
    void ListenerAndSpace()
    {
        OscMessage lisPos = null, verb = null, roomParameters = null;

        lisPos = Osc.StringToOscMessage("/listenerPositions " + (listener.position.x + (roomSizeInMeters[0] / 2)).ToString() + " " +
                                        (listener.position.z + (roomSizeInMeters[2] / 2)).ToString() + " " + (listener.position.y + (roomSizeInMeters[1] / 2)).ToString() + " " +
                                        (listener.rotation.eulerAngles[1].ToString()));

        verb = Osc.StringToOscMessage("/reverbAmount " + (reverbAmount.ToString()));

        if (roomSizeInMeters[0] < 2)
        {
            roomSizeInMeters[0] = 2;
        }
        if (roomSizeInMeters[1] < 2)
        {
            roomSizeInMeters[1] = 2;
        }
        if (roomSizeInMeters[2] < 2)
        {
            roomSizeInMeters[2] = 2;
        }

        roomParameters = Osc.StringToOscMessage("/roomParameters " + (roomSizeInMeters[0].ToString() + " " + roomSizeInMeters[2].ToString() + " " +
                                                                      roomSizeInMeters[1].ToString() + " " + lowFreqReverbTime.ToString() + " " + highFreqReverbTime.ToString() + " " + wallHighAbsptnCoeff.ToString() + " " +
                                                                      wallLowAbsptnCoeff.ToString() + " " + wallGain250Hz.ToString() + " " + wallGain1000Hz.ToString() + " " + wallGain4000Hz.ToString() + " " +
                                                                      floorHighAbsptnCoeff.ToString() + " " + floorLowAbsptnCoeff.ToString() + " " + floorGain250Hz.ToString() + " " + floorGain1000Hz.ToString() + " " +
                                                                      floorGain4000Hz.ToString() + " " + ceilingHighAbsptnCoeff.ToString() + " " + ceilingLowAbsptnCoeff.ToString() + " " + ceilingGain250Hz.ToString() + " " +
                                                                      ceilingGain1000Hz.ToString() + " " + ceilingGain4000Hz.ToString()));

        oscHandler.Send(lisPos);

        oscHandler.Send(verb);
        oscHandler.Send(roomParameters);
    }
Exemplo n.º 33
0
	void Start() {
		UDPPacketIO udp = (UDPPacketIO) GetComponent("UDPPacketIO");
		udp.init(remoteIp, sendToPort, listenerPort);
		handler = (Osc) GetComponent("Osc");
		handler.init(udp);
		//oscHandler.SetAddressHandler("/1/push1", Example);
	}
Exemplo n.º 34
0
    /// <summary>
    /// Start is called just before any of the Update methods is called the first time.
    /// </summary>
    void Start()
    {
        words = codeword.Split(' ');
        UDPPacketIO udp = GetComponent <UDPPacketIO>();

        udp.init(remoteIp, sendToPort, listenerPort);

        oscHandler = GetComponent <Osc>();
        oscHandler.init(udp);

        oscHandler.SetAddressHandler("/remoteIP", setRemoteIP);
        oscHandler.SetAddressHandler("/text", textFromOSC);

        if (messageCanvas == null)
        {
            messageCanvas = transform.Find("OscMessageCanvas").gameObject;
            if (messageCanvas != null)
            {
                messageText = messageCanvas.transform.Find("MessageText").GetComponent <Text>();
            }
        }

        string localIP;

        using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0)) {
            socket.Connect("8.8.8.8", 65530);
            IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;
            localIP = endPoint.Address.ToString();
        }
        setText("This IP is: " + localIP);
    }
Exemplo n.º 35
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];
 }
Exemplo n.º 36
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];
 }
    /// <summary>
    /// Does the processing for sending spacial information to Csound.
    /// </summary>

    void SoundPositions(int algorithm, int soundSource, Transform soundObject, float level)
    {
        OscMessage sourceAttributes = null;

        //Positions sent to Csound

        if (algorithm == 0)
        {
            //to OSC
            sourceAttributes = Osc.StringToOscMessage("/sourceAttributes" + soundSource.ToString() + " " +
                                                      (soundObject.position.x + (roomSizeInMeters[0] / 2)).ToString() + " " +
                                                      (soundObject.position.z + (roomSizeInMeters[2] / 2)).ToString() + " " +
                                                      (soundObject.position.y + (roomSizeInMeters[1] / 2)).ToString() + " " +
                                                      (level).ToString());
        }

        else if (algorithm == 1)
        {
            sourceAttributes = Osc.StringToOscMessage("/sourceAttributes" + soundSource.ToString()
                                                      + " " + (((Mathf.Atan2((soundObject.position.x - listener.position.x), (soundObject.position.z - listener.position.z))) * (180 / Mathf.PI)) - listener.rotation.eulerAngles[1]).ToString()
                                                      + " " + (((Mathf.Atan2((soundObject.position.y - listener.position.y), (soundObject.position.z - listener.position.z))) * (180 / Mathf.PI)) + listener.rotation.eulerAngles[0]).ToString()
                                                      + " " + ((1 / (((Mathf.Pow(((soundObject.position.x) - (listener.position.x)), 2) + Mathf.Pow(((soundObject.position.y) - (listener.position.y)), 2) + Mathf.Pow(((soundObject.position.z) - (listener.position.z)), 2) + 1)))) * level).ToString());
        }


        oscHandler.Send(sourceAttributes);
    }
 void Start()
 {
     udp = GetComponent<UDPPacketIO>();
     handler = GetComponent<Osc>();
     udp.init(RemoteIP, SendToPort, ListenerPort);
     handler.init(udp);
     handler.SetAddressHandler("/htrack/",Ta_filler0);
 }
Exemplo n.º 39
0
 void Start()
 {
     Debug.Log(remoteIp);
     UDPPacketIO udp = (UDPPacketIO) GetComponent("UDPPacketIO");
     udp.init(remoteIp, sendToPort);
     handler = (Osc) GetComponent("Osc");
     handler.init(udp);
     skeletonrender = GetComponent<SkeletonRender> ();
 }
    // Use this for initialization
    void Start()
    {
        UDPPacketIO udp = GetComponent<UDPPacketIO>();
        udp.init(remoteIp, senderPort, listenerPort);

        oscHandler = GetComponent<Osc>();
        oscHandler.init(udp);
        oscHandler.SetAddressHandler("/hand1", Example);
    }
 //    private AvgFixedBuffer buffer;
 // Use this for initialization
 void Start()
 {
     //Initializes on start up to listen for messages
     //make sure this game object has both UDPPackIO and OSC script attached
     UDPPacketIO udp = (UDPPacketIO) GetComponent("UDPPacketIO");
     udp.init(RemoteIP, SendToPort, ListenerPort);
     handler = (Osc) GetComponent("Osc");
     handler.init(udp);
     handler.SetAllMessageHandler(AllMessageHandler);
 }
Exemplo n.º 42
0
    // Use this for initialization
    void Start()
    {
        UDPPacketIO udp = GetComponent<UDPPacketIO>();
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = GetComponent<Osc>();
        handler.init(udp);

        handler.SetAddressHandler("/test", Cry);
        Debug.Log("Running");
    }
Exemplo n.º 43
0
	// Use this for initialization
	void Start () {
        
  
    UDPPacketIO udp = GetComponent<UDPPacketIO>();
   Debug.Log(udp);
	udp.init(RemoteIP, SendToPort, ListenerPort);
	handler = GetComponent<Osc>();
	handler.init(udp);
	handler.SetAllMessageHandler(AllMessageHandler);
	
	}
 // Use this for initialization
 void Start()
 {
     Application.runInBackground = true;
     UDPPacketIO udp = GetComponent<UDPPacketIO>();
     udp.init(UDPHost,broadcastPort,listenerPort);
     oscHandler = GetComponent<Osc>();
     oscHandler.init(udp);
     //		oscHandler.SetAddressHandler("/breathdata",getInput);
     oscHandler.SetAddressHandler("/breathdata", getInput);
     oscStatusText.text = "Sending Data to "+UDPHost+" : "+broadcastPort;
 }
Exemplo n.º 45
0
    // public var output_txt : GUIText;
    // Use this for initialization
    public void Start()
    {
        UDPPacketIO udp = (UDPPacketIO)GetComponent("UDPPacketIO");
        udp.init(UDPHost, broadcastPort, listenerPort);
        oscHandler = (Osc) GetComponent("Osc");
        oscHandler.init(udp);

        oscHandler.SetAddressHandler("/eventTest", updateText);
        oscHandler.SetAddressHandler("/counterTest", counterTest);
        Debug.Log("Running");
    }
    /* ----- SETUP ----- */
    void Start()
    {
        // Set up OSC connection
        udp = (UDPPacketIO)GetComponent("UDPPacketIO");
        udp.init(RemoteIP, outgoingPort, incomingPort);
        handler = (Osc)GetComponent("Osc");
        handler.init(udp);

        // Listen to the channels set in the Processing sketch
        handler.SetAddressHandler("/data", ListenEvent);
    }
Exemplo n.º 47
0
    /*
    void OnDisable()
    {
        // close OSC UDP socket
        Debug.Log("closing OSC UDP socket in OnDisable");
        oscHandler.Cancel();
        oscHandler = null;
    }*/
    // Start is called just before any of the Update methods is called the first time.
    void Start()
    {
        UDPPacketIO udp = GetComponent<UDPPacketIO>();
        udp.init(remoteIp, 9000, 8000);

        oscHandler = GetComponent<Osc>();
        oscHandler.init(udp);

        if (Application.loadedLevelName != "Date") {
            print("WHAT");
            OscMessage oscM = Osc.StringToOscMessage ("/2");
            oscHandler.Send (oscM);
        }
        //oscHandler.SetAddressHandler("/hand1", Example);
    }
Exemplo n.º 48
0
	void Start () {
		UDPPacketIO udp = (UDPPacketIO) GetComponent ("UDPPacketIO");
		udp.init (RemoteIP, SendToPort, ListenerPort);
		handler = (Osc) GetComponent ("Osc");
		handler.init(udp);
		handler.SetAllMessageHandler(AllMessageHandler);
		debug_message = "" + RemoteIP;

		cam_pos = new Vector3 (0, 0, 0);
		left_hand_pos = new Vector3 (0, 0, 0);
		right_hand_pos = new Vector3 (0, 0, 0);
		left_elbow_pos = new Vector3 (0, 0, 0);
		right_elbow_pos = new Vector3 (0, 0, 0);
		body_pos = new Vector3 (0, 0, 0);
	}
Exemplo n.º 49
0
    void Start()
    {
        osceletonNames = new string[] { //standard non-mirrored
            "head", "neck", "torso", "l_shoulder", "l_elbow", "l_hand", "r_shoulder", "r_elbow", "r_hand", "l_hip", "l_knee", "l_foot", "r_hip", "r_knee", "r_foot"
        };
        pos = new Vector3[osceletonNames.Length];
        //target = new Transform[osceletonNames.Length];

        //Initializes on start up to listen for messages
        //make sure this game object has both UDPPackIO and OSC script attached
        udp = (UDPPacketIO) GetComponent("UDPPacketIO");
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = (Osc) GetComponent("Osc");
        handler.init(udp);

        handler.SetAddressHandler("/joint", Example1);
        handler.SetAddressHandler("/example2", Example2);
    }
Exemplo n.º 50
0
	// Use this for initialization
	void Start () {

		//Initializes on start up to listen for messages
		udp = new UDPPacketIO ();
		udp.init(RemoteIP, SendToPort, ListenerPort);
		handler = new Osc ();
		handler.init(udp);
		handler.SetAllMessageHandler(AllMessageHandler);
		Debug.Log ("OSC Connection initialized");

		// builds a list of OSCAnimation scripts that are attached to objects in receiverGameObjects array
		for (int i = 0; i< receiverGameObjects.Length; i++) {

			OSCAnimation[] scripts = receiverGameObjects [i].GetComponents<OSCAnimation> ();
			scriptsToCall.AddRange(scripts );

		}
	
	}
    void Start()
    {
        DontDestroyOnLoad (this.gameObject);

        Debug.Log ("Starting reciever");

        // Set up OSC connection
        UDPPacketIO udp = GetComponent<UDPPacketIO>();
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = GetComponent<Osc> ();
        handler.init(udp);

        // Listen to the channels set in the Processing sketch
        handler.SetAddressHandler("/pulseVals", ListenEvent);

        player1BPM = 70; //You can put temp values in here for testing! Or get fancy and put a random value or something
        player2BPM = 40;
        player3BPM = 55;
        player4BPM = 75;
    }
Exemplo n.º 52
0
    MCTest()
    {
        mct = new MCTestForm(this);

        //usbPacket = new UsbWin32Packet();
        usbPacket = new UsbPacket();
        usbPacket.Open();
        if (usbPacket.IsOpen())
          mct.SetUsbPortName(usbPacket.Name);
        oscUsb = null;
        oscUsb = new Osc(usbPacket);
        oscUsb.SetAllMessageHandler(UsbMessages);

        udpPacket = new UdpPacket();
        udpPacket.RemoteHostName = mct.GetUdpRemoteHostName();
        udpPacket.RemotePort = mct.GetUdpRemotePort();
        udpPacket.LocalPort = mct.GetUdpLocalPort();
        udpPacket.Open();
        oscUdp = new Osc(udpPacket);
        oscUdp.SetAllMessageHandler(UdpMessages);
        oscUdp.SetAddressHandler("/analogin/0/value", AIn0Message);

        Application.Run(mct);
    }
Exemplo n.º 53
0
    void Start()
    {
        // initialize udp and osc stuff (both necessary for OSC network communication)
        UDPPacketIO udp = new UDPPacketIO ();
        udp.init(oscSenderIp, sendToPort, listenerPort);

        oscHandler = new Osc ();
        oscHandler.init(udp);

        // oscHandler.SetAddressHandler("/rigidbody", onRigidBody);
        oscHandler.SetAllMessageHandler (onOscMessage);

        // the rigidBodyObject attribute shouldn't logically be part of this class, but is added as
        // a convenience property to quick and easily visualize the mocap rigid bodies by just specifieing
        // an object to visually represent the rigid bodies. We'll outsource all the logic to the
        // MoCapRigidBodiesCloner class whose tasks is exactly this.
        if (rigidBodyObject) {
            // create a GameObject to hold all the rigid bodies
            GameObject go = new GameObject();
            go.name = "GeneratedRigidBodies";
            // add the cloner component
            MoCapRigidBodiesCloner cloner = go.AddComponent<MoCapRigidBodiesCloner>();
            // give it the specified object and let it take care of the rest
            cloner.rigidBodyObject = rigidBodyObject;
        }
    }
    // Use this for initialization
    void Start()
    {
        //Initializes on start up to listen for messages
        //make sure this game object has both UDPPackIO and OSC script attached
        stackOfRates = new float[500];

        //The scripts that will do the changes
        playerChanges = GameObject.FindWithTag("PlayerChange").GetComponent<PlayerChanges>();
        envChanges = GameObject.FindWithTag("EnvChange").GetComponent<EnvironmentChanges>();

        UDPPacketIO udp = GetComponent<UDPPacketIO>();
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = GetComponent<Osc>();
        handler.init(udp);
        handler.SetAllMessageHandler(AllMessageHandler);
    }
Exemplo n.º 55
0
 public Osc()
 {
     p = n = this;
 }
Exemplo n.º 56
0
 void onDisable()
 {
     oscHandler.Cancel();
     oscHandler = null;
 }
Exemplo n.º 57
0
    void Start()
    {
        UDPPacketIO udp = GetComponent<UDPPacketIO>();
        udp.init(remoteIp, senderPort, listenerPort);

        oscHandler = GetComponent<Osc>();
        oscHandler.init(udp);
        oscHandler.SetAddressHandler("/acw", OSCCallback);
    }
Exemplo n.º 58
0
 public Osc into(Osc x)
 {
     p = x.p;
     n = x;
     p.n = this;
     n.p = this;
     return this;
 }
Exemplo n.º 59
0
    void Start()
    {
        pos = new Vector3[oscInputNames.Length];
        ppos = new Vector3[oscInputNames.Length];

        //Initializes on start up to listen for messages
        //make sure this game object has both UDPPackIO and OSC script attached
        udp = (UDPPacketIO) GetComponent("UDPPacketIO");
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = (Osc) GetComponent("Osc");
        handler.init(udp);

        /*
        handler.SetAddressHandler("/objects/ID-centralXYZ", receiveKinectA); //KinectA blob tracker
        handler.SetAddressHandler("/skeletons/ID-centralXYZ", receiveKinectA); //KinectA blob tracker

        handler.SetAddressHandler("/tracker", receiveSoniskel); //Processing SimpleOpenNI skeleton tracker

        handler.SetAddressHandler("/kinect/blobs", receiveKvl); //KVL blob tracker
        */

        handler.SetAddressHandler("/joint", receiveOsceleton); //OSCeleton skeleton tracker

        //handler.SetAddressHandler("/wii/1/accel/pry", receiveWiimoteAccel); //Osculator Wiimote tracker
        handler.SetAddressHandler("/wii/1/accel/xyz", receiveWiimoteAccel);
        //handler.SetAddressHandler("/wii/1/motion/angles", receiveWiimoteAccel);
        //handler.SetAddressHandler("/wii/1/motion/velo", receiveWiimoteAccel);

        //handler.SetAddressHandler("/wii/1/ir", receiveWiimoteIR);
    }
Exemplo n.º 60
0
	void OnDisable() {
		Debug.Log("Closing OSC UDP socket in OnDisable");
		handler.Cancel();
		handler = null;
	}