public virtual void testPrint() { var msgs = new string[] { "print: bang\n", "print: 0\n", "print: 42\n", "print: symbol", " ", "don't panic", "\n", }; var i = 0; LibPDPrint del = delegate(string text) { Assert.AreEqual(msgs [i++], text); }; LibPD.Print += del; LibPD.SendBang("foo"); LibPD.SendFloat("foo", 0); LibPD.SendFloat("foo", 42); LibPD.SendSymbol("foo", "don't panic"); Assert.AreEqual(msgs.Length, i); LibPD.Print -= del; }
void OnCollisionEnter(Collision collision) { if (enabled) { //Debug.Log("dur: "+dur+" - amp: "+ vel+" - note: "+ (nota*2+60)); Placa p = collision.collider.GetComponent <Placa>(); //Debug.Log (p.note); if (p != null) { LibPD.SendFloat("dur" + index, dur * emisor.art * 1000); //LibPD.SendFloat ("envOut"+index, (dur-(dur*emisor.art)) * 1000); LibPD.SendFloat("vel" + index, 127 * vel * 1f); LibPD.SendFloat("har" + index, emisor.har); LibPD.SendFloat("modIn" + index, emisor.iMod); LibPD.SendFloat("note" + index, p.note); if (emisor.decay > 0) { vel *= emisor.decay; gameObject.transform.localScale = new Vector3(vel * 0.5f, vel * 0.5f, vel * 0.5f); } material.color = Color.white; //LibPD.SendBang ("play"); Invoke("ResetColor", dur); } } }
// Update is called once per frame void Update() { Vector3 v3Velocity = rb.velocity; thisVelocity = v3Velocity.y; if (thisVelocity - lastVelocity > 0) { bounceMoment = true; } else { bounceMoment = false; } if (bounceMoment) { LibPD.SendFloat("bounce", 1); bounceMoment = false; lastVelocity = -1; } lastVelocity = thisVelocity; float sphereY = GameObject.Find("Sphere").transform.position.y; LibPD.SendFloat("pitchOffset", sphereY); }
void OnGUI() { float x = 0; float y = 0; float btnWidth = Screen.width * .4f; float btnHeight = btnWidth * .2f; float margin = 20.0f; if (!patchOpened) { if (GUI.Button(new Rect(x, y, btnWidth, btnHeight), "Open Patch")) { patchOpened = true; libPd.OpenPatch(patch, id => patchId = id); libPd.LoadClip("sample0", clip, "sample_length"); libPd.Subscribe("frequency"); } } else if (patchId != -1 && GUI.Button(new Rect(x, y, btnWidth, btnHeight), "Close patch")) { libPd.ClosePatch(patchId); patchOpened = false; } y += btnHeight + margin; GUI.Label(new Rect(x, y, btnWidth, btnHeight), "Pitch:"); y += margin; pitch = GUI.HorizontalSlider(new Rect(x, y, btnWidth, btnHeight), pitch, .0f, 1.0f); libPd.SendFloat("pitch", pitch); Debug.Log("STREAM OF FLOATS: " + LibPD.receivedFloatValue); }
// sends all the non controlled randomised parameters to the various receivers in pd void send_init_parameters() { // LibPD.SendFloat ("volume", 0.7f); for (int i = 0; i < instrument_genome.filter_gen.Length; i++) { LibPD.SendFloat(instrument_genome.filter [i], instrument_genome.filter_gen [i]); } for (int i = 0; i < instrument_genome.env_gen.Length; i++) { LibPD.SendFloat(instrument_genome.env [i], instrument_genome.env_gen [i]); } for (int i = 0; i < instrument_genome.metro_gen.Length; i++) { LibPD.SendFloat(instrument_genome.metro [i], instrument_genome.metro_gen [i]); } // check if the user is controlling the frequency of the instrument_genome // if (instrument_genome.metro_on == 1) { // LibPD.SendFloat ("metro-on", 1); // // } else { // LibPD.SendFloat ("metro-on", 0); // } }
void OnGUI() { float x = 0; float y = 0; float btnWidth = Screen.width * .4f; float btnHeight = btnWidth * .2f; float margin = 20.0f; if (!patchOpened) { if (GUI.Button(new Rect(x, y, btnWidth, btnHeight), "Open Patch")) { patchOpened = true; libPd.OpenPatch(patch, id => patchId = id); libPd.Subscribe("frequency"); /* * Microphone stream */ var audio = GetComponent <AudioSource>(); audio.clip = Microphone.Start("Built-in Microphone", true, 1, 44100); audio.loop = true; while (!(Microphone.GetPosition(null) > 0)) { } audio.Play(); libPd.SendFloat("metroOnOff", 1); // Turn frequency snapshots ON } } else if (patchId != -1 && GUI.Button(new Rect(x, y, btnWidth, btnHeight), "Close Patch")) { libPd.ClosePatch(patchId); patchOpened = false; } y += btnHeight + margin; GUI.Label(new Rect(x, y, btnWidth, btnHeight), "Pitch:"); y += margin; inputGain = GUI.HorizontalSlider(new Rect(x, y, btnWidth, btnHeight), inputGain, .0f, 1.0f); libPd.SendFloat("inputGain", inputGain); Debug.Log("STREAM OF FLOATS: " + LibPD.receivedFloatValue); }
void OnCollisionEnter(Collision collision) { if (enabled && collision.collider.tag == "Placa") { LibPD.SendFloat("dur", dur); LibPD.SendFloat("vel", vel); LibPD.SendFloat("note", nota * 2 + 60); material.color = Color.red; LibPD.SendBang("play"); Invoke("ResetColor", dur); } }
void OnGUI() { toggleCheck = GUI.Toggle(new Rect(10, 10, 200, 200), toggleCheck, " Toggle Random in Pd"); if (toggleCheck) { LibPD.SendFloat("oscControl", 1); } else { LibPD.SendFloat("oscControl", 0); } }
void SetLibPD() { LibPD.Subscribe("Debug"); LibPD.Bang += ReceiveDebugBang; LibPD.Float += ReceiveDebugFloat; LibPD.Symbol += ReceiveDebugSymbol; LibPD.List += ReceiveDebugList; LibPD.Message += ReceiveDebugMessage; sampleRate = AudioSettings.outputSampleRate; AudioSettings.GetDSPBufferSize(out bufferSize, out bufferAmount); LibPD.SendFloat("BufferSize", bufferSize); LibPD.SendFloat("BufferAmount", bufferAmount); LibPD.SendFloat("SampleRate", sampleRate); }
public void OnAudioFilterRead(float[] data, int channels) { if (dataPtr == IntPtr.Zero) { dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned); dataPtr = dataHandle.AddrOfPinnedObject(); } if (islibpdready) { LibPD.SendFloat(SPatch + "freq", send_freq); LibPD.SendFloat(SPatch + "turn", 1f); LibPD.Process(32, dataPtr, dataPtr); LibPD.SendFloat(SPatch + "turn", 0f); } }
// Update is called once per frame void Update() { // Debug.Log ("LibControl Update"); float prop_float = instrument_genome.get_property_float(); string pd_receive = instrument_genome.get_pd_string(); // Debug.Log ("pd_receive"); Debug.Log(pd_receive); // Debug.Log ("instrument_genome.rb_property_index"); Debug.Log(instrument_genome.rb_property_index); // Debug.Log ("prop_float"); // Debug.Log (prop_float); LibPD.SendFloat(pd_receive, prop_float); }
public static bool SendValue(string sendName, object toSend) { int success = -1; if (toSend is int) { success = LibPD.SendFloat(sendName, (float)((int)toSend)); } else if (toSend is int[]) { success = LibPD.SendList(sendName, ((int[])toSend).ToFloatArray()); } else if (toSend is float) { success = LibPD.SendFloat(sendName, (float)toSend); } else if (toSend is float[]) { success = LibPD.SendList(sendName, (float[])toSend); } else if (toSend is double) { success = LibPD.SendFloat(sendName, (float)((double)toSend)); } else if (toSend is double[]) { success = LibPD.SendList(sendName, ((double[])toSend).ToFloatArray()); } else if (toSend is bool) { success = LibPD.SendFloat(sendName, (float)((bool)toSend).GetHashCode()); } else if (toSend is bool[]) { success = LibPD.SendList(sendName, ((bool[])toSend).ToFloatArray()); } else if (toSend is char) { success = LibPD.SendSymbol(sendName, ((char)toSend).ToString()); } else if (toSend is char[]) { success = LibPD.SendSymbol(sendName, new string((char[])toSend)); } else if (toSend is string) { success = LibPD.SendSymbol(sendName, (string)toSend); } else if (toSend is string[]) { success = LibPD.SendList(sendName, (string[])toSend); } else if (toSend is System.Enum) { success = LibPD.SendFloat(sendName, (float)(toSend.GetHashCode())); } else if (toSend is System.Enum[]) { success = LibPD.SendList(sendName, ((System.Enum[])toSend).ToFloatArray()); } else if (toSend is Vector2) { success = LibPD.SendList(sendName, ((Vector2)toSend).x, ((Vector2)toSend).y); } else if (toSend is Vector3) { success = LibPD.SendList(sendName, ((Vector3)toSend).x, ((Vector3)toSend).y, ((Vector3)toSend).z); } else if (toSend is Vector4) { success = LibPD.SendList(sendName, ((Vector4)toSend).x, ((Vector4)toSend).y, ((Vector4)toSend).z, ((Vector4)toSend).w); } else if (toSend is Quaternion) { success = LibPD.SendList(sendName, ((Quaternion)toSend).x, ((Quaternion)toSend).y, ((Quaternion)toSend).z, ((Quaternion)toSend).w); } else if (toSend is Rect) { success = LibPD.SendList(sendName, ((Rect)toSend).x, ((Rect)toSend).y, ((Rect)toSend).width, ((Rect)toSend).height); } else if (toSend is Color) { success = LibPD.SendList(sendName, ((Color)toSend).r, ((Color)toSend).g, ((Color)toSend).b, ((Color)toSend).a); } else { Debug.LogError("Invalid type to send to Pure Data: " + toSend); } return(success == 0); }
void Update() { Cursor.visible = false; if (Input.GetKeyDown(KeyCode.Alpha1)) { state = 0; } if (Input.GetKeyDown(KeyCode.Alpha2)) { state = 1; } if (Input.GetKeyDown(KeyCode.Alpha3)) { state = 2; } if (Input.GetKeyDown(KeyCode.Alpha4)) { state = 3; } if (Input.GetKeyDown(KeyCode.Alpha5)) { state = 4; } if (Input.GetKeyDown(KeyCode.Alpha6)) { state = 5; } if (Input.GetKeyDown(KeyCode.Alpha7)) { state = 6; } if (Input.GetKeyDown(KeyCode.Alpha8)) { state = 7; } if (Input.GetKeyDown(KeyCode.Alpha9)) { state = 8; } if (Input.GetKeyDown(KeyCode.Alpha0)) { state = 9; } if (Input.GetKeyDown(KeyCode.Minus)) { state = -1; } if (Input.GetKeyDown(KeyCode.Backspace) || Input.GetKeyDown(KeyCode.Mouse1)) { state = 10; } if (Input.GetKeyDown(KeyCode.Return)) { reset(); } if (Input.GetKeyDown(KeyCode.A)) { colorSet = 0; } if (Input.GetKeyDown(KeyCode.S)) { colorSet = 1; } if (Input.GetKeyDown(KeyCode.D)) { colorSet = 2; } if (Input.GetKeyDown(KeyCode.F)) { colorSet = 3; } if (Input.GetKeyDown(KeyCode.G)) { colorSet = 4; } if (Input.GetKeyDown(KeyCode.H)) { colorSet = 5; } if (Input.GetKeyDown(KeyCode.J)) { colorSet = 6; } driver += 0.01f; Debug.Log("STATE: " + state); Color[] pix = tex.GetPixels(); Color[] pixKoa = koa.GetPixels(); for (int x = 2; x < tex.width - 2; x++) { // Loop through every pixel row for (int y = 2; y < tex.height - 2; y++) { float mouseX = Input.mousePosition.x; float mouseY = Input.mousePosition.y; float startMean = 0.0f; Vector3 hsl = new Vector3(1.0f, 1.0f, 0.7f); if (state == 0) { wat[g2d(x, y)] = Mathf.Abs(Mathf.Sin(((wat[g2d(x, y)]) + (wat[g2d(x - 1, y)]) + (wat[g2d(x, y - 1)]) + (wat[g2d(x, y + 1)])) + (driver))); } if (state == 1) { wat[g2d(x, y)] = Mathf.Abs(Mathf.Cos(((wat[g2d(x, y)]) + (wat[g2d(x - 1, y)]) + (wat[g2d(x, y + 1)])) * Mathf.Sin(driver * 0.01f)) * Mathf.Cos(((wat[g2d(x, y)]) + (wat[g2d(x + 1, y + 1)]) + (wat[g2d(x, y + 1)])) * Mathf.Cos(driver))); } if (state == 2) { wat[g2d(x, y)] = Mathf.Tan(((wat[g2d(x + 1, y - 1)]) + (float)x + (wat[g2d(x - 1, y)]) + (wat[g2d(x, y + 1)])) * Mathf.Cos(driver)); } if (state == 3) { wat[g2d(x, y)] = Mathf.Cos(((wat[g2d(x + 1, y - 1)]) + (wat[g2d(x - 1, y - 1)]) + (wat[g2d(x + 1, y + 1)]) + (wat[g2d(x, y + 1)])) * Mathf.Cos(driver)); } if (state == 4) { wat[g2d(x, y)] = Mathf.Sin(((wat[g2d(x, y)]) + (wat[g2d(x - 1, y)]) * 0.2f + (wat[g2d(x, y + 1)]) * 2f)); } if (state == 5) { wat[g2d(x, y)] = Mathf.Cos(Mathf.Sin((wat[g2d(x + 1, y - 1)]) + (float)x + (wat[g2d(x - 1, y)]) + (wat[g2d(x, y + 1)])) * Mathf.Cos(driver)); } if (state == 6) { wat[g2d(x, y)] = Mathf.Abs(Mathf.Sin(((wat[g2d(x, y)]) + (wat[g2d(x - 2, y)]) + (wat[g2d(x, y - 2)]) + (wat[g2d(x, y + 2)])) + (driver))); } if (state == 7) { wat[g2d(x, y)] = Mathf.Abs(Mathf.Cos(( (wat[g2d(x - 1, y)]) + (wat[g2d(x, y + 1)])) * Mathf.Sin(driver * 0.04f)) * (((wat[g2d(x, y)]) + (wat[g2d(x + 1, y + 1)]) + (wat[g2d(x, y + 1)])) * Mathf.Cos(driver))); } if (state == 8) { wat[g2d(x, y)] = Mathf.Tan((Mathf.Cos(( (wat[g2d(x - 1, y)]) * 0.01f + (wat[g2d(x - 2, y)]) * 0.05f + (wat[g2d(x, y + 1)]) * 0.2f + (wat[g2d(x - 1, y + 2)]) * 0.001f + (wat[g2d(x + 1, y + 1)]) * 0.3f + (wat[g2d(x - 1, y - 2)]) * 0.2f + (wat[g2d(x - 2, y - 1)]) * 0.1f + (wat[g2d(x, y - 2)]) * 0.2f)))); } if (state == 9) { float val = wat[g2d(x, y)]; if (val < 0.5f) { wat[g2d(x, y)] = Mathf.Tan((Mathf.Cos(( (wat[g2d(x - 1, y)]) * 0.01f + (wat[g2d(x - 2, y)]) * 0.05f + (wat[g2d(x, y + 1)]) * 0.1f + (wat[g2d(x - 1, y + 2)]) * 0.001f + (wat[g2d(x + 1, y + 1)]) * 0.1f + (wat[g2d(x - 1, y - 2)]) * 0.1f + (wat[g2d(x - 2, y - 1)]) * 0.1f + (wat[g2d(x, y - 2)]) * 0.1f)))); } else { wat[g2d(x, y)] = Mathf.Sin((float)(x % 10) * (float)(y % 5)); } } if (state == 10) { } if (state == -1) { wat[g2d(x, y)] = 0f; } float watput = wat[g2d(x, y)]; //pix[g2d (x,y)] = HSVToRGB(watput,watput*4f,1f); //pixKoa[g2d (x,y)] = koa.GetPixel(x,y);//(Color.red); //if (colorSet==0) { //pix[g2d (x,y)] = HSVToRGB(watput,watput*4f,1f); //} if (colorSet == 0) { pix[g2d(x, y)] = HSVToRGB(watput, watput * 4f, 1f); } else if (colorSet == 1) { pix[g2d(x, y)] = (Color.Lerp(Color.black, Color.red, watput * watput)); //, Color.Lerp(Color.green,Color.red,Mathf.Cos (watput)),Mathf.Sin(watput)); pix[g2d(x, y)] = Color.Lerp(pix[g2d(x, y)], Color.green, watput * watput * watput); pix[g2d(x, y)] = pix[g2d(x, y)] * pix[g2d(x, y)]; } else if (colorSet == 2) { pix[g2d(x, y)] = HSVToRGB(watput, 1f, watput); } else if (colorSet == 3) { pix[g2d(x, y)] = HSVToRGB(watput * 2f, watput * 4f, 1f); } else if (colorSet == 4) { //nice bw + colors pix[g2d(x, y)] = HSVToRGB(watput * 2f, watput * 2f, 1f); } else if (colorSet == 5) { //dgpix[g2d (x,y)] = HSVToRGB(watput%255,watput%255,watput%255); pix[g2d(x, y)] = HSVToRGB(watput * 8f, watput * 2f, 1f); } else if (colorSet == 6) { //dgpix[g2d (x,y)] = HSVToRGB(watput%255,watput%255,watput%255); pix[g2d(x, y)] = HSVToRGB(watput, watput * 2f, 1f); } else { } } } LibPD.SendFloat("colormode", colorSet); tex.SetPixels(pix); //tex.SetPixels( pixKoa); //tex.SetPixels( koa.GetPixels()); // actually apply all SetPixels, don't recalculate mip levels tex.Apply(false); // audio wgController.floatArrayToPD(wat); }
public static void SendFloat(string message, float value) { LibPD.SendFloat(message, value); }
public void SetMaxPoints(int maxPoints) { LibPD.SendFloat("max_points", maxPoints); }
// Update is called once per frame void Update() { // This first list contains every vertex of the mesh that we are going to render triangleVertices = new List <Vector3>(); triangles = new List <int>(); UV = new List <Vector2>(); float[] wat = mh.wat; float[] koalaMatrix = mh.koalaMatrix; Color[] clrs = mh.tex.GetPixels(); //float maxAmplitude = 10f; int timer = 50; if (Input.GetKeyDown(KeyCode.Mouse2) || Input.GetKeyDown(KeyCode.K)) { KOALA = true; count = timer; //print ("mouse = " + KeyCode.Mouse2); } if (KOALA) { KOALA = !KOALA; //print ("KOALA!!! " + count); } count--; //float z = maxAmplitude * Mathf.Sin (Time.time * Mathf.PI * 2) / numOfTrianglesinRow; depthScroll = depthScroll + Input.mouseScrollDelta.y * 3; // print (depthScroll); LibPD.SendFloat("depthScroll", depthScroll); for (int k = 0; k < numOfTrianglesinColumn; k++) { for (int i = 0; i < numOfTrianglesinRow; i++) { int wati = 200 * i / numOfTrianglesinRow; //int wati = w*i/numOfSquaresinRow; int watk = 100 * k / numOfTrianglesinColumn; //int watk = h*k/numOfSquaresinColumn; //float startZ = - koalaMatrix[g2d (i,k) ]; // float startZ = clrs[g2d (i,k)].grayscale; float startZ = mh.tex.GetPixel(wati, watk).grayscale; float koalaZ = mh.koa.GetPixel(wati, watk).grayscale; //float startZ = wat[g2d (i,k)]; //float z = wat[g2d (i,k)]; //slow? float totalZ = 1f; //float watZ = wat[g2d (i,k)]; //this doesn't make sense; if (count > 0 && count > timer / 2) { totalZ = (startZ * count / timer + koalaZ * (timer - count) / timer) * 0.5f; } else if (count > 0 && count <= timer / 2) //reverse { totalZ = (startZ * (timer - count) / timer + koalaZ * count / timer) * 0.5f; } else if (count <= 0) { count = 0; totalZ = startZ; } totalZ = totalZ * depthScroll; triangleVertices.Add(new Vector3(i * edgeLength, k * triHeight, totalZ)); // first corner triangleVertices.Add(new Vector3(i * edgeLength, k * triHeight + triHeight, totalZ + totalZ / 30 * (timer - count) / timer)); //second corner triangleVertices.Add(new Vector3(i * edgeLength + edgeLength, k * triHeight + triHeight, totalZ)); //third corner triangleVertices.Add(new Vector3(i * edgeLength + edgeLength, k * triHeight, totalZ + totalZ / 30 * (timer - count) / timer)); //fourth corner triangles.Add(4 * k * numOfTrianglesinRow + 4 * i); triangles.Add(4 * k * numOfTrianglesinRow + 4 * i + 1); triangles.Add(4 * k * numOfTrianglesinRow + 4 * i + 2); triangles.Add(4 * k * numOfTrianglesinRow + 4 * i); triangles.Add(4 * k * numOfTrianglesinRow + 4 * i + 2); triangles.Add(4 * k * numOfTrianglesinRow + 4 * i + 3); } } int vertecesLength = triangleVertices.Count; Color[] colors = new Color[vertecesLength]; Color colorT = Color.red; Color colorK = Color.yellow; clrs = mh.tex.GetPixels(); if (count <= 0) { for (int i = 0; i < vertecesLength; i++) { colorT = clrs[i / 3]; colors[i] = colorT; } } else if (count > 0) { for (int k = 0; k < numOfTrianglesinColumn; k++) { for (int i = 0; i < numOfTrianglesinRow; i++) { int wati = 200 * i / numOfTrianglesinRow; int watk = 100 * k / numOfTrianglesinColumn; if (count % 2 == 0) { colorK = Color.Lerp(mh.koa.GetPixel(wati, watk), Color.yellow, (float)(count) / timer); } else { colorK = Color.Lerp(mh.koa.GetPixel(wati, watk), Color.cyan, (float)(count) / timer); } if (count > 0 && count > timer / 2) { colorT = Color.Lerp(colorK, mh.tex.GetPixel(wati, watk), (float)(count) / timer); //colorT = Color.Lerp(mh.koa.GetPixel(wati,watk),mh.tex.GetPixel(wati,watk), (float)(count)/timer); } else if (count > 0 && count <= timer / 2) //reverse //Color colorB = Color.Lerp(mh.koa.GetPixel(wati,watk),Color.yellow, (float)(timer-count)/timer); { colorT = Color.Lerp(colorK, mh.tex.GetPixel(wati, watk), (float)(timer - count) / timer); //colorT = Color.Lerp(mh.koa.GetPixel(wati,watk),mh.tex.GetPixel(wati,watk), (float)(timer-count)/timer); } colors[8 * k * numOfTrianglesinColumn + i * 4] = colorT; colors[8 * k * numOfTrianglesinColumn + i * 4 + 1] = colorT; colors[8 * k * numOfTrianglesinColumn + i * 4 + 2] = colorT; colors[8 * k * numOfTrianglesinColumn + i * 4 + 3] = colorT; } } } uniCornerMesh.colors = colors; uniCornerMesh.Clear(); uniCornerMesh.vertices = triangleVertices.ToArray(); uniCornerMesh.triangles = triangles.ToArray(); uniCornerMesh.Optimize(); uniCornerMesh.RecalculateNormals(); //this.transform.Rotate(0f,Random.value-0.5f,0f); }
public virtual void testReceive() { var receiver = "spam"; var listArgs = new object[] { "hund", 1, "katze", 2.5, "maus", 3.1f }; var msgName = "testing"; var msgArgs = new object[] { "one", 1, "two", 2 }; LibPD.Subscribe(receiver); var n = 0; LibPDBang delBang = delegate(string recv) { Assert.AreEqual(receiver, recv); n++; }; LibPD.Bang += delBang; LibPDFloat delFloat = delegate(string recv, float x) { Assert.AreEqual(receiver, recv); Assert.AreEqual(42, x); n++; }; LibPD.Float += delFloat; LibPDSymbol delSymbol = delegate(string recv, string sym) { Assert.AreEqual(receiver, recv); Assert.AreEqual("hund katze maus", sym); n++; }; LibPD.Symbol += delSymbol; LibPDList delList = delegate(string recv, object[] args) { Assert.AreEqual(receiver, recv); Assert.AreEqual(listArgs.Length, args.Length); for (int i = 0; i < args.Length; i++) { Assert.AreEqual(listArgs [i], args [i]); } n++; }; LibPD.List += delList; LibPDMessage delMessage = delegate(string recv, string msg, object[] args) { Assert.AreEqual(receiver, recv); Assert.AreEqual(msgName, msg); Assert.AreEqual(msgArgs.Length, args.Length); for (int i = 0; i < args.Length; i++) { Assert.AreEqual(msgArgs [i], args [i]); } n++; }; LibPD.Message += delMessage; LibPD.SendBang(receiver); LibPD.SendFloat(receiver, 42); LibPD.SendSymbol(receiver, "hund katze maus"); LibPD.SendList(receiver, listArgs); LibPD.SendMessage(receiver, msgName, msgArgs); Assert.AreEqual(5, n); LibPD.Bang -= delBang; LibPD.Float -= delFloat; LibPD.Symbol -= delSymbol; LibPD.List -= delList; LibPD.Message -= delMessage; }
void send_volume_control() { LibPD.SendFloat("volume", volume); }
public bool Send(string receiverName, object toSend) { int success = -1; if (toSend is IList && ((IList)toSend).Count == 1) { toSend = ((IList)toSend)[0]; } if (toSend is int) { success = LibPD.SendFloat(receiverName, (float)((int)toSend)); } else if (toSend is int[]) { success = LibPD.SendList(receiverName, ((int[])toSend).ToFloatArray()); } else if (toSend is float) { success = LibPD.SendFloat(receiverName, (float)toSend); } else if (toSend is float[]) { success = LibPD.SendList(receiverName, (float[])toSend); } else if (toSend is double) { success = LibPD.SendFloat(receiverName, (float)((double)toSend)); } else if (toSend is double[]) { success = LibPD.SendList(receiverName, ((double[])toSend).ToFloatArray()); } else if (toSend is bool) { success = LibPD.SendFloat(receiverName, (float)((bool)toSend).GetHashCode()); } else if (toSend is bool[]) { success = LibPD.SendList(receiverName, ((bool[])toSend).ToFloatArray()); } else if (toSend is char) { success = LibPD.SendSymbol(receiverName, ((char)toSend).ToString()); } else if (toSend is char[]) { success = LibPD.SendSymbol(receiverName, new string((char[])toSend)); } else if (toSend is string) { success = LibPD.SendSymbol(receiverName, (string)toSend); } else if (toSend is string[]) { success = LibPD.SendList(receiverName, (string[])toSend); } else if (toSend is System.Enum) { success = LibPD.SendFloat(receiverName, (float)(toSend.GetHashCode())); } else if (toSend is System.Enum[]) { success = LibPD.SendList(receiverName, ((System.Enum[])toSend).ToFloatArray()); } else if (toSend is object[]) { success = LibPD.SendList(receiverName, (object[])toSend); } else if (toSend is Vector2) { success = LibPD.SendList(receiverName, ((Vector2)toSend).x, ((Vector2)toSend).y); } else if (toSend is Vector3) { success = LibPD.SendList(receiverName, ((Vector3)toSend).x, ((Vector3)toSend).y, ((Vector3)toSend).z); } else if (toSend is Vector4) { success = LibPD.SendList(receiverName, ((Vector4)toSend).x, ((Vector4)toSend).y, ((Vector4)toSend).z, ((Vector4)toSend).w); } else if (toSend is Quaternion) { success = LibPD.SendList(receiverName, ((Quaternion)toSend).x, ((Quaternion)toSend).y, ((Quaternion)toSend).z, ((Quaternion)toSend).w); } else if (toSend is Rect) { success = LibPD.SendList(receiverName, ((Rect)toSend).x, ((Rect)toSend).y, ((Rect)toSend).width, ((Rect)toSend).height); } else if (toSend is Bounds) { success = LibPD.SendList(receiverName, ((Bounds)toSend).center.x, ((Bounds)toSend).center.y, ((Bounds)toSend).size.x, ((Bounds)toSend).size.y); } else if (toSend is Color) { success = LibPD.SendList(receiverName, ((Color)toSend).r, ((Color)toSend).g, ((Color)toSend).b, ((Color)toSend).a); } else { Logger.LogError("Invalid type to send to Pure Data: " + toSend); } return(success == 0); }
// void Start() // { // inicio = true; // //Debug.Log(velocidade); // ball = GetComponent<Rigidbody>(); // material = GetComponent<Renderer>().material; // material.color = new Color(UnityEngine.Random.Range(1, 255) / 255f, UnityEngine.Random.Range(1, 255) / 255f, UnityEngine.Random.Range(1, 255) / 255f); // ForceToDown(300); // } // void FixedUpdate() { // // Debug.Log(ball.velocity); // if ((ball.position.y >= alturaMaxima) && (!inicio)) { // if (alturaMaxima == 4) // Debug.Log(ball.position.y); // ForceToDown(300); // } // if (ball.position.y <= alturaMinima) { // if (inicio) // inicio = false; // ForceToUp(300); // } // } // void ForceToUp(float velocity) { // ClearForce(); // ball.AddForce(Vector3.up * velocity, ForceMode.Acceleration); // } // void ForceToDown(float velocity) { // ClearForce(); // ball.AddForce(Vector3.down * velocity, ForceMode.Acceleration); // } // void ClearForce() { // ball.velocity = new Vector3(0,0,0); // material.color = new Color(UnityEngine.Random.Range(1, 255) / 255f, UnityEngine.Random.Range(1, 255) / 255f, UnityEngine.Random.Range(1, 255) / 255f); // } void PlaySound() { LibPD.SendFloat("som", instrumento); }