示例#1
0
    /// We send a bang when the player steps on the button (enters the collision
    /// volume).
    void OnTriggerEnter(Collider other)
    {
        //To send a bang to our PD patch, the patch needs a named receive object
        //(in this case, named triggerOn), and then we can just use the
        //SendBang() function to send a bang to that object from Unity.

        pdPatch.SendBang("triggerOn");
    }
示例#2
0
 /// We send a bang when the player steps on the button (enters the collision
 /// volume).
 void OnTriggerEnter(Collider other)
 {
     //To send a bang to our PD patch, the patch needs a named receive object
     //(in this case, named VolumeUp), and then we can just use the
     //SendBang() function to send a bang to that object from Unity.
     //
     //See the BangExample.pd patch for details.
     pdPatch.SendBang("VolumeUp");
 }
示例#3
0
    /// Where we animate the door breaking.
    private void Update()
    {
        if (breaking)
        {
            float lastTime = animTime;

            animTime += Time.deltaTime;

            if (animTime >= frameTime)
            {
                ++animStep;

                switch (animStep)
                {
                case 1:
                    doorObject.GetComponent <MeshFilter>().mesh = animationMeshes[0];
                    pdPatch.SendBang("doorBreak1");
                    break;

                case 2:
                    doorObject.GetComponent <MeshFilter>().mesh = animationMeshes[1];
                    pdPatch.SendBang("doorBreak2");
                    break;

                case 3:
                    breakingEvent.Invoke();
                    pdPatch.SendBang("doorBreak3");
                    doorObject.SetActive(false);
                    breaking = false;
                    break;
                }

                animTime = 0.0f;
            }
        }
    }
示例#4
0
    //--------------------------------------------------------------------------
    // Called when we click on the bang button.
    private void ButtonCallback(Button b)
    {
        if (b == bangButton)
        {
            WriteInputText("Sent triggerIn: ", "bang");
            mainPatch.SendBang("triggerIn");
        }
        else if (b == listButton)
        {
            WriteInputText("Sent listIn: ", "0; 15.99; test;");
            mainPatch.SendList("listIn", 0, 15.99, "test");
        }
        else if (b == messageButton)
        {
            WriteInputText("Sent messageIn: ", "test 1;");
            mainPatch.SendMessage("messageIn", "test", 1);
        }
        else if (b == midiNoteButton)
        {
            WriteInputText("Sent MIDI Note: ", "channel = 0; note = 60; velocity = 127");
            mainPatch.SendMidiNoteOn(0, 60, 127);
        }
        else if (b == midiCcButton)
        {
            WriteInputText("Sent MIDI CC: ", "channel = 0; controller = 0; value = 127");
            mainPatch.SendMidiCc(0, 0, 127);
        }
        else if (b == midiProgButton)
        {
            WriteInputText("Sent MIDI Program Change: ", "channel = 0; program = 0");
            mainPatch.SendMidiProgramChange(0, 0);
        }
        else if (b == midiBendButton)
        {
            WriteInputText("Sent MIDI Pitch Bend: ", "channel = 0; value = 8191");
            mainPatch.SendMidiPitchBend(0, 8191);
        }
        else if (b == midiAftertouchButton)
        {
            WriteInputText("Sent MIDI Aftertouch: ", "channel = 0; value = 127");
            mainPatch.SendMidiAftertouch(0, 127);
        }
        else if (b == midiPolyAftertouchButton)
        {
            WriteInputText("Sent MIDI Poly Aftertouch: ", "channel = 0; note = 60; value = 127");
            mainPatch.SendMidiPolyAftertouch(0, 60, 127);
        }
        else if (b == midiByteButton)
        {
            WriteInputText("Sent MIDI Byte: ", "port = 0; value = 127");
            mainPatch.SendMidiByte(0, 127);
        }
        else if (b == midiSysexButton)
        {
            WriteInputText("Sent MIDI Sysex: ", "port = 0; value = 127");
            mainPatch.SendMidiSysex(0, 127);
        }
        else if (b == midiRealtimeButton)
        {
            WriteInputText("Sent MIDI Realtime: ", "port = 0; value = 250");
            mainPatch.SendMidiSysRealtime(0, 250);
        }
        else if (b == arrayRandomButton)
        {
            float[] tempArr = new float[] { Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f),
                                            Random.Range(-1.0f, 1.0f) };

            string arrayData = "";
            if (writeToFile)
            {
                for (int i = 0; i < 10; ++i)
                {
                    arrayData += tempArr[i].ToString() + " ";
                }
            }

            WriteInputText("Sent random array data:", arrayData);
            mainPatch.WriteArray("TestArray", 0, tempArr, 10);

            for (int i = 0; i < 10; ++i)
            {
                tempArr[i] = 0.0f;
            }
            mainPatch.ReadArray(tempArr, "TestArray", 0, 10);

            for (int i = 0; i < 10; ++i)
            {
                libpdArray.SetPosition(i,
                                       new Vector3((float)i * 40.0f,
                                                   tempArr[i] * 100.0f,
                                                   0.0f));
            }

            if (writeToFile)
            {
                arrayData = "";
                for (int i = 0; i < 10; ++i)
                {
                    arrayData += tempArr[i].ToString() + " ";
                }

                testWriter.WriteLine("Received Random array:\r\n" + arrayData);

                if (arrayData == testInput)
                {
                    AddToConsole("Random Array\t\t\t\t\t" + " <color=green>PASSED</color>");
                }
                else
                {
                    AddToConsole("Random Array\t\t\t\t\t" + " <color=red>FAILED</color>");
                }
            }
        }
        else if (b == arraySineButton)
        {
            float[] tempArr = new float[10];

            for (int i = 0; i < 10; ++i)
            {
                tempArr[i] = Mathf.Sin(((float)i / 9.0f) * 2.0f * Mathf.PI);
            }

            string arrayData = "";
            if (writeToFile)
            {
                for (int i = 0; i < 10; ++i)
                {
                    arrayData += tempArr[i].ToString() + " ";
                }
            }

            WriteInputText("Sent sine wave array data:", arrayData);
            mainPatch.WriteArray("TestArray", 0, tempArr, 10);

            for (int i = 0; i < 10; ++i)
            {
                tempArr[i] = 0.0f;
            }
            mainPatch.ReadArray(tempArr, "TestArray", 0, 10);

            for (int i = 0; i < 10; ++i)
            {
                libpdArray.SetPosition(i,
                                       new Vector3((float)i * 40.0f,
                                                   tempArr[i] * 100.0f,
                                                   0.0f));
            }

            if (writeToFile)
            {
                arrayData = "";
                for (int i = 0; i < 10; ++i)
                {
                    arrayData += tempArr[i].ToString() + " ";
                }

                testWriter.WriteLine("Received Sine array:\r\n" + arrayData);

                if (arrayData == testInput)
                {
                    AddToConsole("Sine Array\t\t\t\t\t\t" + " <color=green>PASSED</color>");
                }
                else
                {
                    AddToConsole("Sine Array\t\t\t\t\t\t" + " <color=red>FAILED</color>");
                }
            }
        }
        else if (b == spatialiseButton)
        {
            statusBar.text = "Running spatialisation test";
            circleScript.Trigger();
        }
        else if (b == dynamicCreationButton)
        {
            if (dynamicCreationButton.GetComponentInChildren <Text>().text == "Dynamic Creation")
            {
                Instantiate(dynamicCreationPrefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);

                dynamicCreationButton.GetComponentInChildren <Text>().text = "Dynamic Deletion";
                statusBar.text = "Instantiated LibPdInstance prefab";
            }
            else
            {
                GameObject obj = GameObject.Find("DynamicCreationSphere(Clone)");

                if (obj)
                {
                    Destroy(obj);
                }

                dynamicCreationButton.GetComponentInChildren <Text>().text = "Dynamic Creation";
                statusBar.text = "Deleted LibPdInstance instance";
            }
        }
        else if (b == automatedTestsButton)
        {
            writeToFile  = true;
            testFilePath = Path.GetFullPath(".") + "\\TestResults " + System.DateTime.Now.ToString("dd.MM.yyy - H.mm.ss") + ".txt";

            if (!File.Exists(testFilePath))
            {
                testWriter           = new StreamWriter(File.Create(testFilePath));
                testWriter.AutoFlush = true;
            }

            StartCoroutine("AutomatedTests");
        }
        else if (b == printButton)
        {
            WriteInputText("Sent printIn: ", "This is a print test.");
            mainPatch.SendSymbol("printIn", "This is a print test.");

            if (writeToFile)
            {
                writeToFile = false;
            }
        }
        else if (b == wrapTestButton)
        {
            if (wrapTestButton.GetComponentInChildren <Text>().text == "Start 64-bit Patch")
            {
                Instantiate(wrapTestPrefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);

                wrapTestButton.GetComponentInChildren <Text>().text = "Stop 64-bit Patch";
                statusBar.text = "Instantiated LibPdInstance 64-bit test prefab";
            }
            else
            {
                GameObject obj = GameObject.Find("WrapTest(Clone)");

                if (obj)
                {
                    Destroy(obj);
                }

                wrapTestButton.GetComponentInChildren <Text>().text = "Start 64-bit Patch";
                statusBar.text = "Deleted LibPdInstance 64-bit test instance";
            }
        }
    }
示例#5
0
 ///	Toggle note playback when player enters trigger volume.
 private void OnTriggerEnter(Collider other)
 {
     pdPatch.SendBang("Toggle");
 }
示例#6
0
 void Start()
 {
     //notes = new GameObject[8];
     //pdPatch.Bind("sequenzer_00.pd");
     pdPatch.SendBang("toggle");
 }