Browse Source

replace mixer autoconnect in standalone mode with setting in menu to do so

master
Nils 6 months ago
parent
commit
5f2836cab7
  1. 7
      engine/api.py
  2. 4
      engine/main.py
  3. 35
      qtgui/mainwindow.py

7
engine/api.py

@ -53,6 +53,10 @@ def startEngine(nsmClient, additionalData:dict={}): # type: ignore
callbacks._soundfontChanged()
callbacks._ignoreProgramChangesChanged()
#Maybe autoconnect the mixer.
if session.standaloneMode and additionalData["autoconnectMixer"]: #this is only for startup.
connectMixerToSystemPorts()
logger.info("Fluajho api startEngine complete")
@ -83,6 +87,9 @@ def _registerMidiCallbacks():
session.data.midiInput.midiProcessor.register_ProgramChange(_programChange)
def connectMixerToSystemPorts():
session.data.connectMixerToSystemPorts()
#Sampler
def playTestSignal(channel:int):
"""Channel 1-16

4
engine/main.py

@ -63,6 +63,6 @@ class Data(template.engine.sampler_sf2.Sampler_sf2):
if not filePath: #First start or save file with no filePath -> Default GM soundfont
#The default sf2 has a dynamic path. It depends on where the program is run from. We need to prevent an absolute path.
super().__init__(parentSession, filePath, activePatches, ignoreProgramChanges, mixer=True, defaultSoundfont=DEFAULT_GM_SF2)
super().__init__(parentSession, filePath, activePatches, ignoreProgramChanges, defaultSoundfont=DEFAULT_GM_SF2)
else:
super().__init__(parentSession, filePath, activePatches, ignoreProgramChanges, mixer=True)
super().__init__(parentSession, filePath, activePatches, ignoreProgramChanges)

35
qtgui/mainwindow.py

@ -35,6 +35,7 @@ from template.qtgui.midiinquickwidget import QuickMidiInputComboController
#Client modules
import engine.api as api
from engine.config import METADATA
class MainWindow(TemplateMainWindow):
@ -127,6 +128,31 @@ class MainWindow(TemplateMainWindow):
#New menu entries and template-menu overrides
self.menu.connectMenuEntry("actionOpen_sf2_Soundfont", self.openSoundfontDialog)
#Show and parse the options to autconnect the mixer ports, but only when not in NSM mode
#We will send the var autoconnectMixer to the engine in any case, but it will default to False.
autoconnectMixer = False
if api.isStandaloneMode():
self.menu.addSubmenu("menuSettings", QtCore.QCoreApplication.translate("mainWindow", "Settings"))
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"])
if settings.contains("autoconnectMixer"):
autoconnectMixer = settings.value("autoconnectMixer", type=bool)
else:
autoconnectMixer = False
self.menu.addMenuEntry(
submenu = "menuSettings",
actionAsString = "actionAutoconnectMixer",
text = QtCore.QCoreApplication.translate("mainWindow", "Autoconnect Mixer Ports"),
connectedFunction = self.reactToAutoconnectMixerCheckbox,
tooltip = QtCore.QCoreApplication.translate("mainWindow", "Wether to autoconnect the mixer ports on program start. Not for NSM."),
checkable=True,
startChecked=autoconnectMixer,
)
self.menu.orderSubmenus(["menuFile", "menuSettings", "menuHelp"])
#self.menu.addMenuEntry("menuEdit", "actionNils", "Nils", lambda: print("Merle"))
#self.menu.connectMenuEntry("actionNils", lambda: print("Perle"))
@ -134,7 +160,7 @@ class MainWindow(TemplateMainWindow):
self.ui.actionRedo.setVisible(False)
self.ui.menuEdit.menuAction().setVisible(False)
self.start() #Starts the engine, starts the eventLoop, shows the GUI, or not, depends on the NSM gui save setting. We need to call that after the menu, otherwise the about dialog will block and then we get new menu entries, which looks strange.
self.start(additionalData={"autoconnectMixer":autoconnectMixer}) #Starts the engine, starts the eventLoop, shows the GUI, or not, depends on the NSM gui save setting. We need to call that after the menu, otherwise the about dialog will block and then we get new menu entries, which looks strange.
#There is so much going on in the engine, we never reach a save status on load.
#Here is the crowbar-method.
@ -164,6 +190,13 @@ class MainWindow(TemplateMainWindow):
channelTreeItem.unloadData()
def reactToAutoconnectMixerCheckbox(self, state:bool):
assert api.isStandaloneMode()
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"])
settings.setValue("autoconnectMixer", state)
if state:
api.connectMixerToSystemPorts()
def saveCheckBox_playTestAfterSelectingProgram(self, state:int):
"""#one parameter: int state. 0 is unchecked, 1 is partially, 2 is checked"""
api.session.guiSharedDataToSave["playTestAfterSelectingProgram"] = state

Loading…
Cancel
Save