Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
    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);
        }
    }
Ejemplo n.º 3
0
 public bool SendBang(string receiverName)
 {
     return(LibPD.SendBang(receiverName) == 0);
 }
Ejemplo n.º 4
0
 public static void SendMessage(string message)
 {
     LibPD.SendBang(message);
 }
Ejemplo n.º 5
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;
        }