|
|
@ -34,9 +34,11 @@ import engine.api as api |
|
|
|
|
|
|
|
class QuickMidiInputComboController(QtWidgets.QWidget): |
|
|
|
"""This widget breaks a bit with the convention of engine/gui. However, it is a pure convenience |
|
|
|
fire-and-forget function with no callbacks.""" |
|
|
|
fire-and-forget function with no callbacks. |
|
|
|
|
|
|
|
def __init__(self, parentWidget): |
|
|
|
If you give a text it must already be translated.""" |
|
|
|
|
|
|
|
def __init__(self, parentWidget, text=None, stretch=True): |
|
|
|
super().__init__(parentWidget) |
|
|
|
self.parentWidget = parentWidget |
|
|
|
self.layout = QtWidgets.QHBoxLayout() |
|
|
@ -54,7 +56,10 @@ class QuickMidiInputComboController(QtWidgets.QWidget): |
|
|
|
self.wholePanel = parentWidget.ui.auditionerWidget |
|
|
|
""" |
|
|
|
self.label = QtWidgets.QLabel(self) |
|
|
|
self.label.setText(QtCore.QCoreApplication.translate("QuickMidiInputComboController", "Midi Input. Use JACK to connect multiple inputs.")) |
|
|
|
if text: |
|
|
|
self.label.setText(text) #already translated by parent. |
|
|
|
else: |
|
|
|
self.label.setText(QtCore.QCoreApplication.translate("QuickMidiInputComboController", "Midi Input. Use JACK to connect multiple inputs.")) |
|
|
|
self.layout.addWidget(self.label) |
|
|
|
|
|
|
|
#if not api.isStandaloneMode(): |
|
|
@ -66,9 +71,8 @@ class QuickMidiInputComboController(QtWidgets.QWidget): |
|
|
|
self.comboBox.showPopup = self.showPopup |
|
|
|
self.comboBox.activated.connect(self._newPortChosen) |
|
|
|
|
|
|
|
self.cboxPortname, self.cboxMidiPortUid = api.getMidiInputNameAndUuid() #these don't change during runtime. |
|
|
|
|
|
|
|
self.layout.addStretch() |
|
|
|
if stretch: |
|
|
|
self.layout.addStretch() |
|
|
|
#api.callbacks.startLoadingAuditionerInstrument.append(self.callback_startLoadingAuditionerInstrument) |
|
|
|
#api.callbacks.auditionerInstrumentChanged.append(self.callback_auditionerInstrumentChanged) |
|
|
|
#api.callbacks.auditionerVolumeChanged.append(self.callback__auditionerVolumeChanged) |
|
|
@ -130,17 +134,23 @@ class QuickMidiInputComboController(QtWidgets.QWidget): |
|
|
|
"""externalPort is in the Client:Port JACK format |
|
|
|
If "" False or None disconnect all ports.""" |
|
|
|
|
|
|
|
cboxPortname, cboxMidiPortUid = api.getMidiInputNameAndUuid() #these don't change during runtime. But if the system it not ready yet it returns None, None |
|
|
|
|
|
|
|
if cboxPortname is None and cboxMidiPortUid is None: |
|
|
|
logging.info("engine is not ready yet to deliver midi input name and port id. This is normal during startup but a problem during normal runtime.") |
|
|
|
return #startup delay |
|
|
|
|
|
|
|
try: |
|
|
|
currentConnectedList = cbox.JackIO.get_connected_ports(self.cboxMidiPortUid) |
|
|
|
currentConnectedList = cbox.JackIO.get_connected_ports(cboxMidiPortUid) |
|
|
|
except: #port not found. |
|
|
|
currentConnectedList = [] |
|
|
|
|
|
|
|
for port in currentConnectedList: |
|
|
|
cbox.JackIO.port_disconnect(port, self.cboxPortname) |
|
|
|
cbox.JackIO.port_disconnect(port, cboxPortname) |
|
|
|
|
|
|
|
if externalPort: |
|
|
|
availablePorts = self.getAvailablePorts() |
|
|
|
if not (externalPort in availablePorts["hardware"] or externalPort in availablePorts["software"]): |
|
|
|
raise RuntimeError(f"QuickMidiInput was instructed to connect to port {externalPort}, which does not exist") |
|
|
|
|
|
|
|
cbox.JackIO.port_connect(externalPort, self.cboxPortname) |
|
|
|
cbox.JackIO.port_connect(externalPort, cboxPortname) |
|
|
|