newTrack=session.data.addTrack(name=track.sequencerInterface.name,scale=track.pattern.scale,color=track.color,simpleNoteNames=track.pattern.simpleNoteNames)#track name increments itself from "Track A" to "Track B" or "Track 1" -> "Track 2"
self.data=dataifdataelselist()#For content see docstring. this cannot be the default parameter because we would set the same list for all instances.
self.simpleNoteNames=simpleNoteNamesifsimpleNoteNameselseself.parentTrack.parentData.lastUsedNotenames[:]#This is mostly for the GUI or other kinds of representation instead midi notes
assertself.simpleNoteNames
#2.0 Pitch
#Explanation: Why don't we just do 12 steps per ocatve and then leave steps blank to create a scale?
#We still want the: User set steps, not pitch idiom.
#self.stepsPerOctave = 7 # This is not supposed to go below 7! e.g. Pentatonic scales are done by leaving steps out with self.blankSteps.
#self.nrOfSteps = 8 # Needs to be >= stepsPerOctave. stepsPerOctave+1 will, by default, result in a full scale plus its octave. That can of course later be changed.
#self.blankSteps = [] # Finally, some of the steps, relative to the octave, will be left blank and mute. This should create a visible gap in the GUI. Use this for pentatonic.
self._processAfterInit()
def_prepareBeforeInit(self):
self._cachedTransposedScale={}
@ -239,7 +250,7 @@ class Pattern(object):
self.exportCache=[]#only used by parentTrack.export()
forpatternin(pforpinself.dataifp["index"]<self.parentTrack.parentData.howManyUnits):# < and not <= because index counts from 0 but howManyUnits counts from 1
forpatternin(pforpinself.dataifp["index"]<self.parentTrack.parentData.howManyUnits*self.parentTrack.patternLengthMultiplicator):# < and not <= because index counts from 0 but howManyUnits counts from 1
oneMeasureInTicks/=subdivisions#subdivisions is 1 by default. bigger values mean shorter values, which is compensated by the user setting bigger howManyUnits manually.
oneMeasureInTicks=int(oneMeasureInTicks)
oneMeasureInTicks/=subdivisions#subdivisions is 1 by default. bigger values mean shorter durations, which is compensated by the user setting bigger howManyUnits manually.
self.color=colorifcolorelse"#00FFFF"# "#rrggbb" in hex. no alpha. a convenience slot for the GUI to save a color.
#2.0
#The distinction between Track and Pattern in our code is artificial, it is the same thing,
#we take inspiration from the GUI that presents the Track on its own.
#The following setting is most likely to be found in the track sub-window:
self.patternLengthMultiplicator=1#int. >= 1 the multiplicator is added after all other calculations, like subdivions. We can't integrate this into howManyUnits because that is the global score value
self.structure=structureifstructureelseset()#see buildTrack(). This is the main track data structure besides the pattern. Just integers (starts at 0) as switches which are positions where to play the patterns. In between are automatic rests.
self.whichPatternsAreScaleTransposed=whichPatternsAreScaleTransposedifwhichPatternsAreScaleTransposedelse{}#position:integers between -7 and 7. Reversed pitch, row based: -7 is higher than 7!!
@ -62,13 +69,15 @@ class Track(object): #injection at the bottom of this file!
defbuildTrack(self):
"""The goal is to create a cbox-track, consisting of cbox-clips which hold cbox-pattern,
oneMeasureInTicks=(self.parentData.howManyUnits*self.parentData.whatTypeOfUnit)/self.parentData.subdivisions#subdivisions is 1 by default. bigger values mean shorter values, which is compensated by the user setting bigger howManyUnits manually.
self.callback_trackMetaDataChanged(exportDict,force=True)#we need the color when setting pattern changed. This needs to be called before patternChanged
self.callback_patternChanged(exportDict,force=True)#needs to be called after trackMetaDataChanged for the color.
#Deal with measures that stretch multiple base measures
switch.stretch(factor)
switch.setPos(position*SIZE_UNIT*factor,self.y())
ifnotpositioninstructure:
switch.hide()#Not delete because this may be just a temporary reduction of measures
switch.scaleTransposeOff()
elifposition>requestAmountOfMeasures:#switch end is out of bounds. For factor 1 this is the same as not in the score-area
switch.hide()
switch.scaleTransposeOff()
else:
switch.show()
ifpositioninwhichPatternsAreScaleTransposed:
switch.setScaleTranspose(-1*whichPatternsAreScaleTransposed[position])#we flip the polarity from "makes sense" to row based "lower is higher" here. The opposite, sending, flip is done in switch hover leave event
@ -290,7 +353,9 @@ class TrackStructure(QtWidgets.QGraphicsRectItem):
switch.halftoneTransposeOff()
defscenePos2switchPosition(self,x):
returnint(x/SIZE_UNIT)
"""Map scene coordinates to counted switch engine position"""