From db83234471c77eaba4f960e743b042cefb5ea69a Mon Sep 17 00:00:00 2001 From: Nils Date: Wed, 20 Apr 2022 00:25:16 +0200 Subject: [PATCH] update template --- template/engine/sampler_sf2.py | 23 ++++++++++++++--------- template/engine/session.py | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/template/engine/sampler_sf2.py b/template/engine/sampler_sf2.py index b5f0d10..d2f81a6 100644 --- a/template/engine/sampler_sf2.py +++ b/template/engine/sampler_sf2.py @@ -47,7 +47,7 @@ class Sampler_sf2(Data): but we always fetch the active patches (16 channels) live from calfbox through self.activePatches() """ - def __init__(self, parentSession, filePath, activePatches, ignoreProgramChanges, mixer:bool, defaultSoundfont=None): + def __init__(self, parentSession, filePath, activePatches, ignoreProgramChanges, defaultSoundfont=None): super().__init__(parentSession) self._unlinkOnSave:List[Union[str, PathLike]] = [] #old sf2 files no longer in use. @@ -79,16 +79,12 @@ class Sampler_sf2(Data): except: self._correctActivePatches() + #Create a dynamic pair of audio output ports and route all stereo pairs to our summing channel. #This does _not_ need updating when loading another sf2 or changing instruments. - - assert not self.parentSession.standaloneMode is None - if self.parentSession.standaloneMode: - lmixUuid = cbox.JackIO.create_audio_output('left_mix', "#1") #add "#1" as second parameter for auto-connection to system out 1 - rmixUuid = cbox.JackIO.create_audio_output('right_mix', "#2") #add "#2" as second parameter for auto-connection to system out 2 - else: - lmixUuid = cbox.JackIO.create_audio_output('left_mix') - rmixUuid = cbox.JackIO.create_audio_output('right_mix') + #There is also a function below to connect those to system 1/2 + lmixUuid = cbox.JackIO.create_audio_output('left_mix') + rmixUuid = cbox.JackIO.create_audio_output('right_mix') for i in range(16): router = cbox.JackIO.create_audio_output_router(lmixUuid, rmixUuid) @@ -344,6 +340,15 @@ class Sampler_sf2(Data): return self.midiInputJackName, self.midiInput.cboxMidiPortUid + def connectMixerToSystemPorts(self): + hardwareAudioPorts = cbox.JackIO.get_ports("system*", cbox.JackIO.AUDIO_TYPE, cbox.JackIO.PORT_IS_SINK | cbox.JackIO.PORT_IS_PHYSICAL) #don't sort. This is correctly sorted. Another sorted will do 1, 10, 11, + + l = f"{cbox.JackIO.status().client_name}:left_mix" + r = f"{cbox.JackIO.status().client_name}:right_mix" + + cbox.JackIO.port_connect(l, hardwareAudioPorts[0]) + cbox.JackIO.port_connect(r, hardwareAudioPorts[1]) + #Save / Load / Export def serialize(self)->dict: diff --git a/template/engine/session.py b/template/engine/session.py index c963cd9..5ec07c0 100644 --- a/template/engine/session.py +++ b/template/engine/session.py @@ -105,7 +105,7 @@ class Session(object): self.sessionPrefix = ourPath #if we want to save and load resources they need to be in the session dir. We never load from outside, the scheme is always "import first, load local file" self.absoluteJsonFilePath = os.path.join(ourPath, "save." + METADATA["shortName"] + ".json") - self.standaloneMode = sessionName == "NOT-A-SESSION" + self.standaloneMode = sessionName == "NOT-A-SESSION" #this is a bool! not a chain variable creation. The second is a double == try: self.data = self.openFromJson(self.absoluteJsonFilePath)