diff --git a/engine/api.py b/engine/api.py index 4298939..94bd84a 100644 --- a/engine/api.py +++ b/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() diff --git a/qtgui/songeditor.py b/qtgui/songeditor.py index b739058..18ec073 100644 --- a/qtgui/songeditor.py +++ b/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