//-------------------------------------------------------------------------- // 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"; } } }