Browse Source

save and load length multiplicator

master
Nils 4 years ago
parent
commit
ab34dd996c
  1. 2
      engine/api.py
  2. 8
      engine/track.py
  3. 9
      qtgui/pattern_grid.py
  4. 6
      qtgui/songeditor.py

2
engine/api.py

@ -208,6 +208,8 @@ def startEngine(nsmClient):
for track in session.data.tracks:
callbacks._trackMetaDataChanged(track) #for colors, scale and simpleNoteNames
callbacks._patternLengthMultiplicatorChanged(track) #for colors, scale and simpleNoteNames
session.data.buildAllTracks(buildSongDuration=True) #will set to max track length, we always have a song duration.

8
engine/track.py

@ -108,7 +108,7 @@ class Track(object): #injection at the bottom of this file!
"pattern" : self.pattern.serialize(),
"whichPatternsAreScaleTransposed" : self.whichPatternsAreScaleTransposed,
"whichPatternsAreHalftoneTransposed" : self.whichPatternsAreHalftoneTransposed,
#"patternLengthMultiplicator" : self.patternLengthMultiplicator,
"patternLengthMultiplicator" : self.patternLengthMultiplicator,
}
@classmethod
@ -116,7 +116,11 @@ class Track(object): #injection at the bottom of this file!
self = cls.__new__(cls)
self.parentData = parentData
self.sequencerInterface = template.engine.sequencer.SequencerInterface.instanceFromSerializedData(self, serializedData["sequencerInterface"])
#self.patternLengthMultiplicator = serializedData["patternLengthMultiplicator"]
if "patternLengthMultiplicator" in serializedData: #Version 1.8
self.patternLengthMultiplicator = serializedData["patternLengthMultiplicator"]
else:
self.patternLengthMultiplicator = 1
self.color = serializedData["color"]
self.structure = set(serializedData["structure"])
self.whichPatternsAreHalftoneTransposed = {int(k):int(v) for k,v in serializedData["whichPatternsAreHalftoneTransposed"].items()} #json saves dict keys as strings

9
qtgui/pattern_grid.py

@ -100,7 +100,6 @@ class PatternGrid(QtWidgets.QGraphicsScene):
def callback_patternLengthMultiplicatorChanged(self, exportDict):
self._tracks[exportDict["id"]] = exportDict
self._fullRedraw(exportDict["id"])
def callback_timeSignatureChanged(self, howMany, typeInTicks):
@ -122,11 +121,11 @@ class PatternGrid(QtWidgets.QGraphicsScene):
self.removeItem(existingStep)
self._steps = {} # (x,y):Step()
if not self.parentView.parentMainWindow.currentTrackId or not self.parentView.parentMainWindow.currentTrackId in self._tracks:
factor = 1 #program start
if forceId:
factor = self._tracks[forceId]["patternLengthMultiplicator"]
else:
if forceId:
factor = self._tracks[forceId]["patternLengthMultiplicator"]
if not self.parentView.parentMainWindow.currentTrackId or not self.parentView.parentMainWindow.currentTrackId in self._tracks:
factor = 1 #program start. Purely internal. Will be overriden by a second callback before the user sees it.
else:
factor = self._tracks[self.parentView.parentMainWindow.currentTrackId]["patternLengthMultiplicator"]

6
qtgui/songeditor.py

@ -644,12 +644,14 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):
self._exportDictScore = exportDictScore
def callback_numberOfTracksChanged(self, exportDictList):
toDelete = set(self.tracks.keys())
self._cachedExportDictsInOrder = exportDictList
width = self.parentView.geometry().width()
for index, exportDict in enumerate(exportDictList):
if exportDict["id"] in self.tracks:
toDelete.remove(exportDict["id"])
@ -660,6 +662,7 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):
self.tracks[exportDict["id"]].setY(index * SIZE_UNIT + SIZE_TOP_OFFSET)
self.tracks[exportDict["id"]].update(exportDict)
#We had this tracks in the GUI but they are gone in the export. This is track delete.
for trackId in toDelete:
trackLabel = self.tracks[trackId]
@ -673,6 +676,7 @@ class TrackLabelEditor(QtWidgets.QGraphicsScene):
self.cachedCombinedTrackHeight = len(self.tracks) * SIZE_UNIT
self.setSceneRect(0,0,width-1,self.cachedCombinedTrackHeight + 3*SIZE_TOP_OFFSET)
def callback_patternLengthMultiplicatorChanged(self, exportDict):
self.tracks[exportDict["id"]].update(exportDict) #general update function that also covers our value
@ -909,7 +913,9 @@ class TrackLabel(QtWidgets.QGraphicsRectItem):
self.exportDict = exportDict
self.lineEdit.setText(exportDict["sequencerInterface"]["name"])
self.colorButton.setBrush(QtGui.QColor(exportDict["color"]))
self.lengthMultiplicatorSpinBox.spinBox.blockSignals(True)
self.lengthMultiplicatorSpinBox.spinBox.setValue(int(exportDict["patternLengthMultiplicator"]))
self.lengthMultiplicatorSpinBox.spinBox.blockSignals(False)
def mousePressEvent(self,event):
self.parentScene.parentView.parentMainWindow.chooseCurrentTrack(self.exportDict)

Loading…
Cancel
Save