@ -273,9 +273,8 @@ class TrackState(object):
""" TrackState stays not the same for one track but gets recreated, at least in track.head().
""" TrackState stays not the same for one track but gets recreated, at least in track.head().
This means init is always position 0. """
This means init is always position 0. """
#in init these will get recreated all the time. This confuses cashing and hashing
defaultClef = Clef ( " treble " )
defaultClef = Clef ( " treble " )
defaultDynamicSignature = DynamicSignature ( " custom " )
defaultDynamicSignature = DynamicSignature ( " custom " ) #This is the start dynamic value like 'forte', not the DynamicSettingsSignature
defaultMetricalInstruction = MetricalInstruction ( tuple ( ) , isMetrical = False )
defaultMetricalInstruction = MetricalInstruction ( tuple ( ) , isMetrical = False )
defaultKeySignature = KeySignature ( 20 , [ 0 , 0 , 0 , 0 , 0 , 0 , 0 ] )
defaultKeySignature = KeySignature ( 20 , [ 0 , 0 , 0 , 0 , 0 , 0 , 0 ] )
@ -288,7 +287,8 @@ class TrackState(object):
self . barlines = [ ] #a list of ints/tickpositions. These are the non-editable, non-movable single barlines.
self . barlines = [ ] #a list of ints/tickpositions. These are the non-editable, non-movable single barlines.
#stacks. There is always one item left in the stack, the default:
#stacks. There is always one item left in the stack, the default:
self . keySignatures = [ self . defaultKeySignature ] #C Major
self . keySignatures = [ self . defaultKeySignature ] #C Major
self . clefs = [ self . defaultClef ]
#self.clefs = [self.defaultClef]
self . clefs = [ Clef ( track . initialClefKeyword ) ]
self . metricalInstructions = [ self . defaultMetricalInstruction ] #no barlines, no metrical information.
self . metricalInstructions = [ self . defaultMetricalInstruction ] #no barlines, no metrical information.
self . dynamicSignatures = [ self . defaultDynamicSignature ]
self . dynamicSignatures = [ self . defaultDynamicSignature ]
self . dynamicRamp = None #Not for cursor movement so it is not a stack.
self . dynamicRamp = None #Not for cursor movement so it is not a stack.
@ -398,6 +398,13 @@ class Track(object):
self . initialInstrumentName = " " #different than the track name. e.g. "Violin"
self . initialInstrumentName = " " #different than the track name. e.g. "Violin"
self . initialShortInstrumentName = " " # e.g. "vl"
self . initialShortInstrumentName = " " # e.g. "vl"
#Since version 2.1.0 the initial signature can be set by the user, mostly as a GUI convenience.
#These are used by the track-state init/head
self . initialClefKeyword : str = " treble " #it is much easier to handle the keyword with save/load and setting this value, so we are not using the item.Clef class
#self.initialMetricalInstruction = MetricalInstruction(tuple(), isMetrical = False)
#self.initialKeySignature = KeySignature(20, [0,0,0,0,0,0,0])
self . asMetronomeData = None #This track as metronome version. Is always up to date through export.
self . asMetronomeData = None #This track as metronome version. Is always up to date through export.
self . _processAfterInit ( )
self . _processAfterInit ( )
@ -842,6 +849,13 @@ class Track(object):
else :
else :
timeSig = " \\ once \\ override Staff.TimeSignature # ' stencil = ##f \\ cadenzaOn \n "
timeSig = " \\ once \\ override Staff.TimeSignature # ' stencil = ##f \\ cadenzaOn \n "
for item in self . blocks [ 0 ] . data [ : 4 ] :
if type ( item ) is Clef :
clef = " "
break
else :
clef = " \\ clef " + self . initialClefKeyword + " \n " #internal clef keywords are the same as lilypond
carryLilypondRanges = { } #handed from item to item for ranges such as tuplets. Can act like a stack or simply remember stuff.
carryLilypondRanges = { } #handed from item to item for ranges such as tuplets. Can act like a stack or simply remember stuff.
upbeatLy = " \\ partial {} " . format ( Duration . createByGuessing ( self . upbeatInTicks ) . lilypond ( carryLilypondRanges ) ) if self . upbeatInTicks else " "
upbeatLy = " \\ partial {} " . format ( Duration . createByGuessing ( self . upbeatInTicks ) . lilypond ( carryLilypondRanges ) ) if self . upbeatInTicks else " "
@ -897,7 +911,7 @@ class Track(object):
pass
pass
if lyData :
if lyData :
return timeSig + upbeatLy + lyData + " \n "
return clef + timeSig + upbeatLy + lyData + " \n "
else :
else :
return " " #Empty track
return " " #Empty track
@ -911,6 +925,7 @@ class Track(object):
" dynamicSettingsSignature " : self . dynamicSettingsSignature . serialize ( ) ,
" dynamicSettingsSignature " : self . dynamicSettingsSignature . serialize ( ) ,
" double " : self . double ,
" double " : self . double ,
" initialClefKeyword " : self . initialClefKeyword ,
" initialMidiChannel " : self . initialMidiChannel ,
" initialMidiChannel " : self . initialMidiChannel ,
" initialMidiProgram " : self . initialMidiProgram ,
" initialMidiProgram " : self . initialMidiProgram ,
" initialMidiBankMsb " : self . initialMidiBankMsb ,
" initialMidiBankMsb " : self . initialMidiBankMsb ,
@ -945,6 +960,12 @@ class Track(object):
self . initialInstrumentName = serializedData [ " initialInstrumentName " ]
self . initialInstrumentName = serializedData [ " initialInstrumentName " ]
self . initialShortInstrumentName = serializedData [ " initialShortInstrumentName " ]
self . initialShortInstrumentName = serializedData [ " initialShortInstrumentName " ]
#Version 2.1.0
if " initialClefKeyword " in serializedData :
self . initialClefKeyword = serializedData [ " initialClefKeyword " ]
else :
self . initialClefKeyword = " treble "
self . _processAfterInit ( )
self . _processAfterInit ( )
return self
return self
@ -977,6 +998,7 @@ class Track(object):
" upbeatInTicks " : int ( self . upbeatInTicks ) ,
" upbeatInTicks " : int ( self . upbeatInTicks ) ,
" double " : self . double ,
" double " : self . double ,
" audible " : self . sequencerInterface . enabled ,
" audible " : self . sequencerInterface . enabled ,
" initialClefKeyword " : self . initialClefKeyword ,
" initialMidiChannel " : self . initialMidiChannel ,
" initialMidiChannel " : self . initialMidiChannel ,
" initialMidiProgram " : self . initialMidiProgram ,
" initialMidiProgram " : self . initialMidiProgram ,
" initialMidiBankMsb " : self . initialMidiBankMsb ,
" initialMidiBankMsb " : self . initialMidiBankMsb ,
@ -1232,6 +1254,7 @@ class Track(object):
metaData [ " barlines " ] = barlines . keys ( )
metaData [ " barlines " ] = barlines . keys ( )
metaData [ " duration " ] = self . state . tickindex #tickindex is now at the end, so this is the end duration. This includes Blocks minimumDuration as well since it is included in left/right
metaData [ " duration " ] = self . state . tickindex #tickindex is now at the end, so this is the end duration. This includes Blocks minimumDuration as well since it is included in left/right
metaData [ " beams " ] = resultBeamGroups
metaData [ " beams " ] = resultBeamGroups
metaData [ " initialClef " ] = self . initialClefKeyword
#Notes
#Notes
t = ( midiNotesBinaryCboxData , 0 , self . state . tickindex )
t = ( midiNotesBinaryCboxData , 0 , self . state . tickindex )