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]; } }
void Open(int port, string address) { _port = port; _address = address; var server = OscMaster.GetSharedServer(_port); server.MessageDispatcher.AddCallback(_address, OnDataReceive); }
public void Close() { var server = OscMaster.GetSharedServer(_port); server.MessageDispatcher.RemoveCallback(_address, OnDataReceive); _port = 0; _address = null; }
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 }
void Update() { var data = OscMaster.GetData("/audio/loud"); if (data != null) { var loud = (float)data[0]; transform.localScale = Vector3.one * loud; Debug.Log(loud); } }
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); }
private void OnDestroy() { if (string.IsNullOrEmpty(oscAddress)) { return; } var server = OscMaster.GetSharedServer(udpPort); server.MessageDispatcher.RemoveCallback(oscAddress, OnDataReceive); }
void Update() { var data = OscMaster.GetData(_path); if (data != null) { var val = (float)data[0]; _knob.value = val; } OscMaster.ClearData(_path); }
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); }
// 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); }
void OnDisable() { if (string.IsNullOrEmpty(_currentAddress)) { return; } var server = OscMaster.GetSharedServer(_currentPort); server.MessageDispatcher.RemoveCallback(_currentAddress, OnDataReceive); _currentAddress = null; }
// 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; }
// 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); } } }
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); }
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; } }
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); } }
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); } }
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; }
// 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; }
// // 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"); } }
void GetSharedServer() { s_SharedServer = OscMaster.GetSharedServer(Port); }
void OnDestroy() { OscMaster.SendData("/" + route + "/off 1"); }