@ -273,9 +273,8 @@ class TrackState(object):
""" TrackState stays not the same for one track but gets recreated, at least in track.head().
This means init is always position 0. """
#in init these will get recreated all the time. This confuses cashing and hashing
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 )
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.
#stacks. There is always one item left in the stack, the default:
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 . dynamicSignatures = [ self . defaultDynamicSignature ]
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 . 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 . _processAfterInit ( )
@ -842,6 +849,13 @@ class Track(object):
else :
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.
upbeatLy = " \\ partial {} " . format ( Duration . createByGuessing ( self . upbeatInTicks ) . lilypond ( carryLilypondRanges ) ) if self . upbeatInTicks else " "
@ -897,7 +911,7 @@ class Track(object):
pass
if lyData :
return timeSig + upbeatLy + lyData + " \n "
return clef + timeSig + upbeatLy + lyData + " \n "
else :
return " " #Empty track
@ -911,6 +925,7 @@ class Track(object):
" dynamicSettingsSignature " : self . dynamicSettingsSignature . serialize ( ) ,
" double " : self . double ,
" initialClefKeyword " : self . initialClefKeyword ,
" initialMidiChannel " : self . initialMidiChannel ,
" initialMidiProgram " : self . initialMidiProgram ,
" initialMidiBankMsb " : self . initialMidiBankMsb ,
@ -945,6 +960,12 @@ class Track(object):
self . initialInstrumentName = serializedData [ " initialInstrumentName " ]
self . initialShortInstrumentName = serializedData [ " initialShortInstrumentName " ]
#Version 2.1.0
if " initialClefKeyword " in serializedData :
self . initialClefKeyword = serializedData [ " initialClefKeyword " ]
else :
self . initialClefKeyword = " treble "
self . _processAfterInit ( )
return self
@ -977,6 +998,7 @@ class Track(object):
" upbeatInTicks " : int ( self . upbeatInTicks ) ,
" double " : self . double ,
" audible " : self . sequencerInterface . enabled ,
" initialClefKeyword " : self . initialClefKeyword ,
" initialMidiChannel " : self . initialMidiChannel ,
" initialMidiProgram " : self . initialMidiProgram ,
" initialMidiBankMsb " : self . initialMidiBankMsb ,
@ -1232,6 +1254,7 @@ class Track(object):
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 [ " beams " ] = resultBeamGroups
metaData [ " initialClef " ] = self . initialClefKeyword
#Notes
t = ( midiNotesBinaryCboxData , 0 , self . state . tickindex )