diff --git a/engine/api.py b/engine/api.py index ef10bc6..0d62f02 100644 --- a/engine/api.py +++ b/engine/api.py @@ -10,6 +10,7 @@ from calfbox import cbox #Template Modules import template.engine.api #we need direct access to the module to inject data in the provided structures. but we also need the functions directly. next line: from template.engine.api import * +from template.engine.duration import baseDurationToTraditionalNumber #Our modules from .pattern import NUMBER_OF_STEPS @@ -59,7 +60,7 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks def _timeSignatureChanged(self): nr = session.data.howManyUnits - typ = session.data.whatTypeOfUnit + typ = session.data.whatTypeOfUnit for func in self.timeSignatureChanged: func(nr, typ) @@ -73,7 +74,22 @@ class ClientCallbacks(Callbacks): #inherits from the templates api callbacks """Subdivisions are tricky, therefore we keep them isolated in their own callback. You don't need to redraw anything if you don't want to. One recommendation is to draw every n step a little more important (bigger, different color). - where n = subdivions""" + where n = subdivions + + We also place JACK BBT via tempoMap here because we need it every time the time sig + changes (which calls _subdivisionsChanged) and if subdivisions change. + """ + typ = baseDurationToTraditionalNumber[session.data.whatTypeOfUnit] + nr = session.data.howManyUnits + tradNr = int(nr / session.data.subdivisions) + #JACK BBT for Timebase Master. No matter if we are master at the moment or not. + if tradNr == nr / session.data.subdivisions: + #Easier to read than the else case. Not possible with 9 Steps per Pattern in Groups of 2 because that is a 4.5/4 timesig. + session.data.tempoMap.setTimeSignature(tradNr, typ) + else: + #Always possible, compared to first if case. + session.data.tempoMap.setTimeSignature(nr, typ*session.data.subdivisions) + export = session.data.subdivisions for func in self.subdivisionsChanged: func(export) @@ -221,30 +237,33 @@ def set_quarterNotesPerMinute(value:int): session.data.tempoMap.isTransportMaster = False #triggers rebuild elif value == "on": assert not session.data.tempoMap.isTransportMaster - #keep old bpm value - session.data.tempoMap.isTransportMaster = True #triggers rebuild + #keep old bpm value. 120 bpm is default. + session.data.tempoMap.isTransportMaster = True #triggers rebuild else: assert value > 0 session.data.tempoMap.setQuarterNotesPerMinute(value) - session.data.tempoMap.isTransportMaster = True #triggers rebuild + session.data.tempoMap.isTransportMaster = True #triggers rebuild #Does not need track rebuilding updatePlayback() - callbacks._quarterNotesPerMinuteChanged() - + callbacks._quarterNotesPerMinuteChanged() + def set_whatTypeOfUnit(ticks): - if session.data.whatTypeOfUnit == ticks: return + """Denominator of Time Signature""" + if session.data.whatTypeOfUnit == ticks: return session.data.whatTypeOfUnit = ticks session.data.buildAllTracks() updatePlayback() callbacks._timeSignatureChanged() def set_howManyUnits(value): - if session.data.howManyUnits == value: return + """Numerator of Time Signature""" + if session.data.howManyUnits == value: return session.data.howManyUnits = value session.data.buildAllTracks() updatePlayback() callbacks._timeSignatureChanged() + def set_subdivisions(value): if session.data.subdivisions == value: return