newTrack=session.data.addTrack(name=track.sequencerInterface.name,scale=track.pattern.scale,color=track.color,noteNames=track.pattern.noteNames)#track name increments itself from "Track A" to "Track B" or "Track 1" -> "Track 2"
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"
@ -56,7 +56,7 @@ class Data(template.engine.sequencer.Score):
self.numberOfMeasures=64
self.measuresPerGroup=8# meta data, has no effect on playback.
self.subdivisions=1
self.lastUsedNotenames=noteNames["English"]#The default value for new tracks/patterns. Changed each time the user picks a new representation via api.setNoteNames . noteNames are saved with the patterns.
self.lastUsedNotenames=simpleNoteNames["English"]#The default value for new tracks/patterns. Changed each time the user picks a new representation via api.setNoteNames . noteNames are saved with the patterns.
self.addTrack(name="Melody A",color="#ffff00")
self.tracks[0].structure=set((0,))#Already have the first pattern activated, so 'play' after startup already produces sounding notes. This is less confusing for a new user.
@ -68,9 +68,9 @@ class Data(template.engine.sequencer.Score):
self.scale=scaleifscaleelse(72,71,69,67,65,64,62,60)#Scale needs to be set first because on init/load data already depends on it, at least the default scale. The scale is part of the track meta callback.
self.data=dataifdataelselist()#For content see docstring. this cannot be the default parameter because we would set the same list for all instances.
self.noteNames=noteNamesifnoteNameselseself.parentTrack.parentScore.lastUsedNotenames#This is mostly for the GUI or other kinds of representation instead midi notes
self.simpleNoteNames=simpleNoteNamesifsimpleNoteNameselseself.parentTrack.parentScore.lastUsedNotenames#This is mostly for the GUI or other kinds of representation instead midi notes
self._processAfterInit()
def_prepareBeforeInit(self):
@ -81,13 +81,13 @@ class Pattern(object):
self.createCachedTonalRange()
@property
defnoteNames(self):
returnself._noteNames
defsimpleNoteNames(self):
returnself._simpleNoteNames
@noteNames.setter
defnoteNames(self,value):
self._noteNames=tuple(value)#we keep it immutable, this is safer to avoid accidental linked structures when creating a clone.
self.parentTrack.parentScore.lastUsedNotenames=self._noteNames#new default for new tracks
@simpleNoteNames.setter
defsimpleNoteNames(self,value):
self._simpleNoteNames=tuple(value)#we keep it immutable, this is safer to avoid accidental linked structures when creating a clone.
self.parentTrack.parentScore.lastUsedNotenames=self._simpleNoteNames#new default for new tracks
deffill(self):
"""Create a 2 dimensional array"""
@ -221,7 +221,7 @@ class Pattern(object):
return{
"scale":self.scale,
"data":self.data,
"noteNames":self.noteNames,
"simpleNoteNames":self.simpleNoteNames,
}
@classmethod
@ -233,7 +233,7 @@ class Pattern(object):
#Use setters to trigger side effects like createCachedTonalRange()
self.scale=serializedData["scale"]#Scale needs to be set first because on init/load data already depends on it, at least the default scale. The scale is part of the track meta callback.
self.data=serializedData["data"]#For content see docstring.
self.noteNames=serializedData["noteNames"]#This is mostly for the GUI or other kinds of representation instead midi notes
self.simpleNoteNames=serializedData["simpleNoteNames"]#This is mostly for the GUI or other kinds of representation instead midi notes
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!!
self.whichPatternsAreHalftoneTransposed=whichPatternsAreHalftoneTransposedifwhichPatternsAreHalftoneTransposedelse{}#position:integers between -7 and 7. Reversed pitch, row based: -7 is higher than 7!!
@ -122,7 +121,7 @@ class Track(object): #injection at the bottom of this file!