From 62823b4072531108fcae44efead5d2d0b4937852 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Sun, 17 Apr 2022 21:06:52 +0200 Subject: [PATCH] Don't discard user data when setting or deleting steps in a multiplicator-measure. --- engine/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/api.py b/engine/api.py index 14d8fb5..86f962c 100644 --- a/engine/api.py +++ b/engine/api.py @@ -1340,10 +1340,12 @@ def setStep(trackId, stepExportDict): This function checks if the new step is within the limits of the current sounding pattern and will prevent changes or additions outside the current limits. """ + track = session.data.trackById(trackId) if not track: return - inRange = stepExportDict["index"] < session.data.howManyUnits and stepExportDict["pitch"] < track.pattern.numberOfSteps + #index is from 0 and howManyUnits*Multp is from 1 (because it is length), so we just need <, and not <=. + inRange = stepExportDict["index"] < session.data.howManyUnits*track.patternLengthMultiplicator and stepExportDict["pitch"] < track.pattern.numberOfSteps if not inRange: return session.history.register(lambda trId=trackId, v=track.pattern.copyData(): setPattern(trId, v, "Change Step"), descriptionString="Change Step") @@ -1365,7 +1367,7 @@ def removeStep(trackId, index, pitch): track = session.data.trackById(trackId) if not track: return - inRange = index < session.data.howManyUnits and pitch < track.pattern.numberOfSteps + inRange = index < session.data.howManyUnits*track.patternLengthMultiplicator and pitch < track.pattern.numberOfSteps if not inRange: return session.history.register(lambda trId=trackId, v=track.pattern.copyData(): setPattern(trId, v, "Remove Step"), descriptionString="Remove Step")