Browse Source

Dead code :(

master
Nils 2 years ago
parent
commit
6601405cdf
  1. 4
      engine/block.py
  2. 8
      engine/resources/lilypondTemplates/default.ly
  3. 56
      engine/track.py

4
engine/block.py

@ -358,4 +358,6 @@ class Block(object):
else:
skipstring = ""
return "\n % Block: " + self.name + "\n " + " ".join(item.lilypond(carryLilypondRanges) for item in self.data) + skipstring + "\n"
#Format: Block name as comment, followed by a music expression { block data }
#The music expression doesn't hurt, but is useful for repeats
return "\n % Block: " + self.name + "\n { " + " ".join(item.lilypond(carryLilypondRanges) for item in self.data) + skipstring + " } \n"

8
engine/resources/lilypondTemplates/default.ly

@ -70,9 +70,9 @@ correctFraction = #(lambda (grob)
\remove "Note_heads_engraver"
\consists "Completion_heads_engraver"
\remove "Rest_engraver"
\consists "Completion_rest_engraver"
\consists "Completion_rest_engraver"
tieWaitForNote = ##t
}
\context { \Staff
\RemoveEmptyStaves
@ -84,6 +84,8 @@ correctFraction = #(lambda (grob)
%\consists "Default_bar_line_engraver"
\override NoteHead #'style = #'baroque %breve and longa are squared.
}
}
@ -94,6 +96,7 @@ tempoStaff = { %$$TEMPOSTAFF$$ }
%$$VOICES$$
\score{
<<
%How the definitions are arranged. Only staffgroups (staff prefix) and staffs, merged as voices.
\accidentalStyle Score.neo-modern-voice
@ -105,4 +108,3 @@ tempoStaff = { %$$TEMPOSTAFF$$ }
%$$SUBTEXT$$
%}
}

56
engine/track.py

@ -840,12 +840,60 @@ class Track(object):
upbeatLy = "\\partial {} ".format(Duration.createByGuessing(self.upbeatInTicks).lilypond(carryLilypondRanges)) if self.upbeatInTicks else ""
#Find sequential content-linked blocks to convert them into lilypond voltas
last = set()
currentFirstBlockInARow = None
repeatCounter = 0
blockRepeatIndex = {} #block : int
blockRepeatTotal = {} #first block : int. This is not the same as len(set(block.linkedContentBlocksInScore())) because the latter is all links in total, while we only want the consecutive count. Only the first block of a row is in here.
#TODO: Contentlink -> Volta conversion is currently deactivated for multi-track. Too many lilypond problems
#As long as blockRepeatTotal exists and is empty export will treat each block as standalone, so everything works
#The commented-out code does not show the number of repeats, and more importantly, places the same repeats in all staffs, even if they do not exist there.
#This is not compatible with real-life music where one instrument plays the same part twice, but the second one has a different version the 2nd time.
#If we ever find a lilypond way to only set synchronized repeats this can get activated for more tracks.
codeActivated = len(self.parentData.tracks) == 1
codeActivated = False #TODO: NO! Too fragile
for block in self.blocks: #in order
links = set(block.linkedContentBlocksInScore()) #it's a generator
if links:
if codeActivated and links == last:
#This is not the first one in a row.
repeatCounter += 1
blockRepeatTotal[currentFirstBlockInARow] += 1
else:
#This is the first one in a row. Reset.
repeatCounter = 0
currentFirstBlockInARow = block
blockRepeatTotal[currentFirstBlockInARow] = 1
last = links
blockRepeatIndex[block] = repeatCounter #0 for standalone blocks. Each block one entry
#Another round through the blocks to generate data
lyData = ""
for block in self.blocks:
if block in blockRepeatTotal:
l = blockRepeatTotal[block]
if l > 1:
assert blockRepeatIndex[block] == 0
lyData += f"\n \\repeat volta {l}" + block.lilypond(carryLilypondRanges) #the lilypond block includes music expression { }
else:
#No voltas. We could do \repeat volta 1 but that would be ugly lilypond.
lyData += block.lilypond(carryLilypondRanges)
else:
# A linked block in a row.
# do NOT export any content linked block that is not the first in a row.
# they are included as voltas above.
pass
data = " ".join(block.lilypond(carryLilypondRanges) for block in self.blocks)
if data:
return timeSig + upbeatLy + data + "\n"
if lyData:
return timeSig + upbeatLy + lyData + "\n"
else:
return ""
return "" #Empty track
def serialize(self)->dict:

Loading…
Cancel
Save