public void floatArrayToPD(float[] arrayInput) { //LibPD.SendList ("testing", 10,1); float[] array = new float[1024 * 2]; for (int i = 0; i < 1024; i++) //i++) { { if (i % 2 == 0) { int idx = i / 2; array[idx * 2] = idx; array[idx * 2 + 1] = (Mathf.Cos(arrayInput[idx * 20000 / 1024])); // - Mathf.Cos(1-lastArray[idx*20000/1024]); } } System.Array.Copy(arrayInput, lastArray, 1024); //arrayInput.Length); object[] objectArray = new object[2048]; System.Array.Copy(array, objectArray, 2048); //array.Length); //print (objectArray.Length);//array[6] + " " + array[7]); LibPD.SendList("params", objectArray); }
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); }
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); }
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; }
public void SetCurrentTeam(Team team) { _team = team; LibPD.SendList("data", team.ToPdArgs()); }