Browse Source

fix duplicate group regression

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

2
qtgui/songeditor.py

@ -390,7 +390,9 @@ class TrackStructure(QtWidgets.QGraphicsRectItem):
return return
menu = QtWidgets.QMenu() menu = QtWidgets.QMenu()
position = self.scenePos2switchPosition(event.scenePos().x()) #measure number 0 based 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 measuresPerGroup = self.parentScene.measuresPerGroupCache
offset = position % measuresPerGroup offset = position % measuresPerGroup
startMeasureForGroup = position - offset startMeasureForGroup = position - offset

Loading…
Cancel
Save