コード例 #1
0
        void OnEnable()
        {
            if (string.IsNullOrEmpty(_oscAddress))
            {
                _currentAddress = null;
                return;
            }

            var server = OscMaster.GetSharedServer(_udpPort);

            server.MessageDispatcher.AddCallback(_oscAddress, OnDataReceive);

            _currentPort    = _udpPort;
            _currentAddress = _oscAddress;

            if (_floatQueue == null)
            {
                _floatQueue = new Queue <float>(MAX_OSC_PARAMS);
            }

            if (_floatBuffer == null)
            {
                _floatBuffer = new float[MAX_OSC_PARAMS];
            }

            if (_timeOutBuffer == null)
            {
                _timeOutBuffer = new float[MAX_OSC_PARAMS];
            }
        }
コード例 #2
0
        void Open(int port, string address)
        {
            _port = port;
            _address = address;

            var server = OscMaster.GetSharedServer(_port);
            server.MessageDispatcher.AddCallback(_address, OnDataReceive);
        }
コード例 #3
0
            public void Close()
            {
                var server = OscMaster.GetSharedServer(_port);

                server.MessageDispatcher.RemoveCallback(_address, OnDataReceive);

                _port    = 0;
                _address = null;
            }
コード例 #4
0
 IEnumerator Deactivate(object[] parms)
 {
     while (Time.time < (float)parms[0] + (float)parms[1])
     {
         yield return(null);
     }
     gameObject.SetActive(false);
     OscMaster.SendData("/source/stop " + indexNum); //here we tell maxmsp to turn off the sound
 }
コード例 #5
0
 void Update()
 {
     var data = OscMaster.GetData("/audio/loud");
     if (data != null) {
         var loud = (float)data[0];
         transform.localScale = Vector3.one * loud;
         Debug.Log(loud);
     }
 }
コード例 #6
0
            public void Open(int port, string address)
            {
                _port    = port;
                _address = address;
                _queue   = new Queue <Vector3>();

                var server = OscMaster.GetSharedServer(_port);

                server.MessageDispatcher.AddCallback(_address, OnDataReceive);
            }
コード例 #7
0
        private void OnDestroy()
        {
            if (string.IsNullOrEmpty(oscAddress))
            {
                return;
            }

            var server = OscMaster.GetSharedServer(udpPort);

            server.MessageDispatcher.RemoveCallback(oscAddress, OnDataReceive);
        }
コード例 #8
0
ファイル: OSCKnobControl.cs プロジェクト: parkblvd/orb
    void Update()
    {
        var data = OscMaster.GetData(_path);

        if (data != null)
        {
            var val = (float)data[0];
            _knob.value = val;
        }
        OscMaster.ClearData(_path);
    }
コード例 #9
0
        ControlOutput OnEnter(Flow flow)
        {
            var sendto = flow.GetValue <string>(SendTo);
            var port   = (int)flow.GetValue <uint>(Port);
            var client = OscMaster.GetSharedClient(sendto, port);

            var address = flow.GetValue <string>(Address);

            client.Send(address);

            return(Exit);
        }
コード例 #10
0
        // Used to store values on initialization
        //private int _currentPort;

        #endregion

        #region MonoBehaviour implementation

        private void Start()
        {
            if (string.IsNullOrEmpty(oscAddress))
            {
                return;
            }

            var server = OscMaster.GetSharedServer(udpPort);

            server.MessageDispatcher.AddCallback(oscAddress, OnDataReceive);

            Debug.Log(server);
        }
コード例 #11
0
        void OnDisable()
        {
            if (string.IsNullOrEmpty(_currentAddress))
            {
                return;
            }

            var server = OscMaster.GetSharedServer(_currentPort);

            server.MessageDispatcher.RemoveCallback(_currentAddress, OnDataReceive);

            _currentAddress = null;
        }
コード例 #12
0
 // Update is called once per frame
 void Update()
 {
     pos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
     rot = gameObject.transform.rotation.eulerAngles;
     if ((pos != lastPos || rot != lastRot) && Time.frameCount % 3 == 0)
     {
         //rot.x = pitch
         //rot.y = yaw
         //rot.z = roll
         OscMaster.SendData("/listener/position " + pos.x + " " + pos.y + " " + pos.z + " " + rot.z + " " + rot.x + " " + rot.y);
     }
     lastPos = pos;
     lastRot = rot;
 }
コード例 #13
0
    // Update is called once per frame
    void Update()
    {
        var data = OscMaster.GetData(_path);

        if (data != null)
        {
            var val = (string)data[0];
            if (val.Equals(_acceptValue))
            {
                _toggle.isOn = true;
                OscMaster.ClearData(_path);
            }
        }
    }
コード例 #14
0
 public void Launch()
 {
     rb                 = GetComponent <Rigidbody>();
     rb.velocity        = Vector3.zero;
     rb.angularVelocity = Vector3.zero;
     // orbitCenter = GameObject.Find("Camera (eye)");
     print(indexNum);
     direction = orbitCenter.transform.position - gameObject.transform.position;
     initialTangent.Normalize();
     binormal = Vector3.Cross(initialTangent, direction);
     rb.AddForce(gameObject.transform.forward * 1000);
     object[] parms = new object[2] {
         10f, Time.time
     };
     StartCoroutine("Deactivate", parms);
     OscMaster.SendData("/source/start " + indexNum);
 }
コード例 #15
0
    void FixedUpdate()
    {
        if (gameObject.activeSelf)
        {
            direction = orbitCenter.transform.position - gameObject.transform.position;
            rb.AddForce(direction);

            Vector3 tangentForce = Vector3.Cross(direction, binormal);
            rb.AddForce(tangentForce * 100f);
            pos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
            if (pos != lastPos && Time.frameCount % 3 == 0)
            {
                OscMaster.SendData("/source/position " + indexNum + " " + pos.x + " " + pos.y + " " + pos.z);
            }
            lastPos = pos;
        }
    }
コード例 #16
0
    void Update()
    {
        var data = OscMaster.GetData("/audio/loud");

        if (data != null)
        {
            var loud = (float)data[0];
            transform.localScale = Vector3.one * loud;
            Debug.Log(loud);
        }

        if (OscMaster.HasData("/audio/attack"))
        {
            Camera.main.backgroundColor = Color.red;
            OscMaster.Remove("/audio/attack");
        }
        else
        {
            Camera.main.backgroundColor = new Color(0.2f, 0.3f, 0.5f, 1.0f);
        }
    }
コード例 #17
0
        void Update()
        {
            System.Object[] data = OscMaster.GetData(address);
            if (data == null)
            {
                return;
            }

            var level = (float)data[dataIndex];

            if (scaleMode == ScaleMode.Linear01)
            {
                const float refLevel = 0.70710678118f; // 1/sqrt(2)
                const float zeroOffs = 1.5849e-13f;
                level   = Mathf.Clamp01(level);
                dbLevel = Mathf.Log(level / refLevel + zeroOffs, 10) * 20;
            }
            else
            {
                dbLevel = Mathf.Min(level, 0.0f);
            }
        }
コード例 #18
0
    void Update()
    {
        var position = OscMaster.GetData("/camera/position");

        if (position != null)
        {
            if (position.Length > 2)
            {
                pos = new Vector3(
                    (float)position[0] * (InvertSignPosX ? -1.0f : 1.0f),
                    (float)position[1] * (InvertSignPosY ? -1.0f : 1.0f),
                    (float)position[2] * (InvertSignPosZ ? -1.0f : 1.0f)
                    ) * Scale;
            }
            OscMaster.ClearData("/camera/position");
        }

        var rotation = OscMaster.GetData("/camera/quaternion");

        if (rotation != null)
        {
            if (rotation.Length > 3)
            {
                rot = new Quaternion(
                    (float)rotation[0] * (InvertSignRotX ? -1.0f : 1.0f),
                    (float)rotation[1] * (InvertSignRotY ? -1.0f : 1.0f),
                    (float)rotation[2] * (InvertSignRotZ ? -1.0f : 1.0f),
                    (float)rotation[3] * (InvertSignRotW ? -1.0f : 1.0f)
                    );
            }
            OscMaster.ClearData("/camera/quaternion");
        }

        transform.localPosition = pos;
        transform.localRotation = rot;

        //OscMessageDebugger.oscMessage = mess;
    }
コード例 #19
0
    // Update is called once per frame
    void FixedUpdate()
    {
        direction = orbitCenter.transform.position - transform.position;
        //direction.Normalize();
        rb.AddForce(direction);

        Vector3 tangentForce = Vector3.Cross(direction, binormal);

        rb.AddForce(tangentForce * 30f);
        pos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
        if (pos != lastPos)
        {
            OscMaster.SendData("/" + route + "/x " + pos.x);
            OscMaster.SendData("/" + route + "/y " + pos.y);
            OscMaster.SendData("/" + route + "/z " + pos.z);
        }
        trail = lastPos - pos;
        trail.Normalize();
        trail = trail * 10f;
        spray1.initialVelocity = trail;
        spray2.initialVelocity = trail;

        lastPos = pos;
    }
コード例 #20
0
        //    // Update is called once per frame
        void Update()
        {
            totalMessages = OscMaster.MasterDirectory.TotalMessageCount;

            if (OscMaster.HasData("/track2") || Input.GetKeyDown(KeyCode.Space))
            {
                onStartTrack2.Invoke();
                OscMaster.ClearData("/track2");
            }

            for (var i = 1; i <= numDials; i++)
            {
                var address = "/osc/dial/" + i.ToString();
                if (OscMaster.HasData(address))
                {
                    var val = (float)OscMaster.GetData(address).LastOrDefault();
                    dials[i - 1] = val;
                    onUpdateDial[i - 1].Invoke(val);
                    OscMaster.ClearData(address);
                }
            }
            dialBuffer.SetData(dials);
            for (var i = 1; i <= numSliders; i++)
            {
                var address = "/osc/slider/" + i.ToString();
                if (OscMaster.HasData(address))
                {
                    var val = (float)OscMaster.GetData(address).LastOrDefault();
                    sliders[i - 1] = val;
                    onUpdateSlider[i - 1].Invoke(val);
                    OscMaster.ClearData(address);
                }
            }
            compute.SetFloats("_Dial", dials);
            compute.SetFloats("_Slider", sliders);

            if (OscMaster.HasData("/light/color"))
            {
                var data = OscMaster.GetData("/light/color");
                if (data.Length > 3)
                {
                    var color = new Color((float)data[0], (float)data[1], (float)data[2], (float)data[3]);
                    Shader.SetGlobalColor("_LightColor", color);
                }
                OscMaster.ClearData("/light/color");
            }
            if (OscMaster.HasData("/light/intensity"))
            {
                var val = (float)OscMaster.GetData("/light/intensity").FirstOrDefault();
                Shader.SetGlobalFloat("_LightIntensity", val);
                OscMaster.ClearData("/light/intensity");
            }
            if (OscMaster.HasData("/core/color"))
            {
                var data  = OscMaster.GetData("/core/color");
                var color = new Color((float)data[0], (float)data[1], (float)data[2], (float)data[3]);
                onCoreColor.Invoke(color);
                OscMaster.ClearData("/core/color");
            }
            sliderBuffer.SetData(sliders);

            if (OscMaster.HasData("/beat"))
            {
                if (cpUpdater.gameObject.activeSelf)
                {
                    cpUpdater.OnClick();
                }
                OscMaster.ClearData("/beat");
            }
        }
コード例 #21
0
 void GetSharedServer()
 {
     s_SharedServer = OscMaster.GetSharedServer(Port);
 }
コード例 #22
0
 void OnDestroy()
 {
     OscMaster.SendData("/" + route + "/off 1");
 }