IEnumerator ConnectMidiOnStart() { yield return(new WaitUntil(() => MIDI.initialized )); try { for (int i = 0; i < MidiOUTPlugin.GetDeviceCount(); i++) { var deviceName = MidiOUTPlugin.GetDeviceName(i); MidiOUTPlugin.DisconnectDeviceByName(deviceName); //Debug.Log($"DisconnectMidiOut {deviceName}"); } for (int i = 0; i < MidiINPlugin.GetDeviceCount(); i++) { var deviceName = MidiINPlugin.GetDeviceName(i); if (!deviceName.Contains("Session")) { MidiINPlugin.ConnectDeviceByName(deviceName); //Debug.Log($"ConnectMidiIn {deviceName}"); break; } } } catch (Exception e) { Debug.LogWarning("ConnectMidiOnStart " + e); } }
public void OnDeviceClick(MidiSelectionUIDeviceButton button) { Debug.Log("Device : " + button.device.ToString() + " " + button.text.text); if (button.connected) { switch (button.device) { case MidiSelectionUIDeviceButton.Device.IN: MidiINPlugin.DisconnectDeviceByName(button.text.text); button.image.color = disconnectedColor; button.connected = false; MidiINPlugin.StoreConnections(); break; case MidiSelectionUIDeviceButton.Device.OUT: MidiOUTPlugin.DisconnectDeviceByName(button.text.text); button.image.color = disconnectedColor; button.connected = false; MidiOUTPlugin.StoreConnections(); break; } } else { switch (button.device) { case MidiSelectionUIDeviceButton.Device.IN: if (MidiINPlugin.ConnectDeviceByName(button.text.text) != null) { button.image.color = connectedColor; button.connected = true; MidiINPlugin.StoreConnections(); } break; case MidiSelectionUIDeviceButton.Device.OUT: if (MidiOUTPlugin.ConnectDeviceByName(button.text.text) != null) { button.image.color = connectedColor; button.connected = true; MidiOUTPlugin.StoreConnections(); } break; } } }
public void HandleClick() { try { //Debug.Log("HandleClick " + Button.name); if (Button.name.Contains("IN CONNECT")) { Debug.Log("MidiINPlugin.ConnectDeviceByName(" + Text.text + ")"); MidiINPlugin.ConnectDeviceByName(Text.text); } if (Button.name.Contains("IN DISCONNECT")) { Debug.Log("MidiINPlugin.DisconnectDeviceByName(" + Text.text + ")"); MidiINPlugin.DisconnectDeviceByName(Text.text); } if (Button.name.Contains("OUT CONNECT")) { Debug.Log("MidiOUTPlugin.ConnectDeviceByName(" + Text.text + ")"); MidiOUTPlugin.ConnectDeviceByName(Text.text); } if (Button.name.Contains("OUT DISCONNECT")) { Debug.Log("MidiOUTPlugin.DisconnectDeviceByName(" + Text.text + ")"); MidiOUTPlugin.DisconnectDeviceByName(Text.text); } GameObject.Find("PanelSetting").GetComponent <PanelSetting>().GetMidiInOut(); } catch (Exception e) { Debug.LogWarning("HandleClick " + e); } }