Browse Source

fix duplicate group regression

master
Nils 2 years ago
parent
commit
78fd82a675
  1. 20
      engine/api.py
  2. 2
      qtgui/songeditor.py

20
engine/api.py

@ -514,7 +514,7 @@ def setSwitchHalftoneTranspose(trackId, position, transpose):
callbacks._trackStructureChanged(track)
return True
def insertSilence(howMany, beforeMeasureNumber):
def insertSilence(howMany:int, beforeMeasureNumber:int):
"""Insert empty measures into all tracks"""
#In each track shift every switch to the right if it is before the dividing measure number
@ -532,16 +532,20 @@ def insertSilence(howMany, beforeMeasureNumber):
def duplicateSwitchGroup(startMeasureForGroup:int, endMeasureExclusive:int):
groupSize = endMeasureExclusive-startMeasureForGroup
insertSilence(groupSize, endMeasureExclusive)
insertSilence(groupSize, endMeasureExclusive) #insert silence handles multiplicator-tracks on its own
for track in session.data.tracks:
for switch in range(startMeasureForGroup+groupSize, endMeasureExclusive+groupSize): #One group after the given one.
if switch-groupSize in track.structure:
thisTrackStartMeasure = startMeasureForGroup // track.patternLengthMultiplicator #integer division
thisTrackEndMeasure = endMeasureExclusive // track.patternLengthMultiplicator
thisGroupSize = groupSize // track.patternLengthMultiplicator
for switch in range(thisTrackStartMeasure+thisGroupSize, thisTrackEndMeasure+thisGroupSize): #One group after the given one.
if switch-thisGroupSize in track.structure:
track.structure.add(switch)
if switch-groupSize in track.whichPatternsAreScaleTransposed:
track.whichPatternsAreScaleTransposed[switch] = track.whichPatternsAreScaleTransposed[switch-groupSize]
if switch-groupSize in track.whichPatternsAreHalftoneTransposed:
track.whichPatternsAreHalftoneTransposed[switch] = track.whichPatternsAreHalftoneTransposed[switch-groupSize]
if switch-thisGroupSize in track.whichPatternsAreScaleTransposed:
track.whichPatternsAreScaleTransposed[switch] = track.whichPatternsAreScaleTransposed[switch-thisGroupSize]
if switch-thisGroupSize in track.whichPatternsAreHalftoneTransposed:
track.whichPatternsAreHalftoneTransposed[switch] = track.whichPatternsAreHalftoneTransposed[switch-thisGroupSize]
callbacks._trackStructureChanged(track)
session.data.buildAllTracks()
updatePlayback()

2
qtgui/songeditor.py

@ -390,7 +390,9 @@ class TrackStructure(QtWidgets.QGraphicsRectItem):
return
menu = QtWidgets.QMenu()
position = self.scenePos2switchPosition(event.scenePos().x()) #measure number 0 based
position = position * self.exportDict["patternLengthMultiplicator"] #We need the position in the global system, without the factor
measuresPerGroup = self.parentScene.measuresPerGroupCache
offset = position % measuresPerGroup
startMeasureForGroup = position - offset

Loading…
Cancel
Save