|
|
@ -200,9 +200,39 @@ def startEngine(nsmClient): |
|
|
|
for track in session.data.tracks: |
|
|
|
callbacks._trackMetaDataChanged(track) #for colors, scale and simpleNoteNames |
|
|
|
|
|
|
|
session.data.buildAllTracks() |
|
|
|
session.data.buildAllTracks(buildSongDuration=True) #will set to max track length, we always have a song duration. |
|
|
|
|
|
|
|
updatePlayback() |
|
|
|
|
|
|
|
|
|
|
|
def _loopOff(): |
|
|
|
session.data.buildSongDuration() #no parameter removes the loop |
|
|
|
updatePlayback() |
|
|
|
session.inLoopMode = None |
|
|
|
callbacks._loopChanged(None, None, None) |
|
|
|
|
|
|
|
def _loopNow(): |
|
|
|
now = cbox.Transport.status().pos_ppqn |
|
|
|
_setLoop(now) |
|
|
|
|
|
|
|
def _setLoop(loopMeasureAroundPpqn): |
|
|
|
if loopMeasureAroundPpqn < 0: |
|
|
|
_loopOff() |
|
|
|
return |
|
|
|
|
|
|
|
loopStart, loopEnd = session.data.buildSongDuration(loopMeasureAroundPpqn) |
|
|
|
|
|
|
|
updatePlayback() |
|
|
|
session.inLoopMode = (loopStart, loopEnd) |
|
|
|
|
|
|
|
assert loopStart <= loopMeasureAroundPpqn < loopEnd |
|
|
|
if not playbackStatus(): |
|
|
|
cbox.Transport.play() |
|
|
|
|
|
|
|
oneMeasureInTicks = (session.data.howManyUnits * session.data.whatTypeOfUnit) / session.data.subdivisions |
|
|
|
|
|
|
|
measurenumber, rest = divmod(loopStart, oneMeasureInTicks) |
|
|
|
callbacks._loopChanged(int(measurenumber), loopStart, loopEnd) |
|
|
|
|
|
|
|
def toggleLoop(): |
|
|
|
"""Plays the current measure as loop. |
|
|
@ -211,26 +241,9 @@ def toggleLoop(): |
|
|
|
session.inLoopMode is a tuple (start, end) |
|
|
|
""" |
|
|
|
if session.inLoopMode: |
|
|
|
session.data.buildSongDuration() #no parameter removes the loop |
|
|
|
updatePlayback() |
|
|
|
session.inLoopMode = None |
|
|
|
callbacks._loopChanged(None, None, None) |
|
|
|
_loopOff() |
|
|
|
else: |
|
|
|
now = loopMeasureAroundPpqn=cbox.Transport.status().pos_ppqn |
|
|
|
loopStart, loopEnd = session.data.buildSongDuration(now) |
|
|
|
|
|
|
|
updatePlayback() |
|
|
|
session.inLoopMode = (loopStart, loopEnd) |
|
|
|
|
|
|
|
assert loopStart <= now < loopEnd |
|
|
|
if not playbackStatus(): |
|
|
|
cbox.Transport.play() |
|
|
|
|
|
|
|
oneMeasureInTicks = (session.data.howManyUnits * session.data.whatTypeOfUnit) / session.data.subdivisions |
|
|
|
|
|
|
|
measurenumber, rest = divmod(loopStart, oneMeasureInTicks) |
|
|
|
callbacks._loopChanged(int(measurenumber), loopStart, loopEnd) |
|
|
|
|
|
|
|
_loopNow() |
|
|
|
|
|
|
|
def seek(value): |
|
|
|
"""override template one, which does not have a loop""" |
|
|
@ -262,6 +275,8 @@ def set_whatTypeOfUnit(ticks): |
|
|
|
if session.data.whatTypeOfUnit == ticks: return |
|
|
|
session.data.whatTypeOfUnit = ticks |
|
|
|
session.data.buildAllTracks() |
|
|
|
if session.inLoopMode: |
|
|
|
_loopNow() |
|
|
|
updatePlayback() |
|
|
|
callbacks._timeSignatureChanged() |
|
|
|
|
|
|
@ -270,6 +285,8 @@ def set_howManyUnits(value): |
|
|
|
if session.data.howManyUnits == value: return |
|
|
|
session.data.howManyUnits = value |
|
|
|
session.data.buildAllTracks() |
|
|
|
if session.inLoopMode: |
|
|
|
_loopNow() |
|
|
|
updatePlayback() |
|
|
|
callbacks._timeSignatureChanged() |
|
|
|
|
|
|
@ -278,6 +295,8 @@ def set_subdivisions(value): |
|
|
|
if session.data.subdivisions == value: return |
|
|
|
session.data.subdivisions = value |
|
|
|
session.data.buildAllTracks() |
|
|
|
if session.inLoopMode: |
|
|
|
_loopNow() |
|
|
|
updatePlayback() |
|
|
|
callbacks._subdivisionsChanged() |
|
|
|
|
|
|
@ -293,6 +312,8 @@ def convert_subdivisions(value, errorHandling): |
|
|
|
callbacks._patternChanged(tr) |
|
|
|
else: |
|
|
|
callbacks._subdivisionsChanged() #to reset the GUI value back to the working one. |
|
|
|
if session.inLoopMode: |
|
|
|
_loopNow() |
|
|
|
return result |
|
|
|
|
|
|
|
def set_numberOfMeasures(value): |
|
|
|