class FontOptionsStructureV0(FileStructure): tag = "FONT_OPTIONS" startTag = "FONT_OPTIONS_START" endTag = "FONT_OPTIONS_END" targetClass = Data.FontOptions.FontOptions noteFont = StringField("NOTEFONT") noteFontSize = PositiveIntegerField("NOTEFONTSIZE") sectionFont = StringField("SECTIONFONT") sectionFontSize = PositiveIntegerField("SECTIONFONTSIZE") metadataFont = StringField("METADATAFONT") metadataFontSize = PositiveIntegerField("METADATAFONTSIZE")
class ScoreStructureV0(FileStructure): tag = None targetClass = Data.Score.Score autoMake = True scoreData = MetadataStructureV0() drumKit = DrumKitStructureV0() measures = MeasureStructureV0( singleton=False, getter=lambda score: list(score.iterMeasures()), setter=lambda score, msr: score.insertMeasureByIndex(0, measure=msr)) _sections = StringField("SECTION_TITLE", singleton=False) paperSize = StringField("PAPER_SIZE") lilysize = PositiveIntegerField("LILYSIZE") lilypages = NonNegativeIntegerField("LILYPAGES") lilyFill = conditionalWriteField(YesNoField("LILYFILL"), lambda score: score.lilyFill) lilyFormat = NonNegativeIntegerField("LILYFORMAT") defaultCount = MeasureCountStructureV0(singleton=True, startTag="DEFAULT_COUNT_INFO_START") systemSpacing = NonNegativeIntegerField("SYSTEM_SPACE") fontOptions = FontOptionsStructureV0() def postProcessObject(self, instance): instance.postReadProcessing() return instance
class MeasureStructureV0(FileStructure): tag = "BAR" targetClass = Data.Measure.Measure counter = MeasureCountStructureV0() startBarLine = BarlineFieldWriteV0(" STARTBARLINE", getter=startBarlineString) barlines = BarlineReadFieldV0("BARLINE") notes = NoteFieldV0("NOTE", getter=list, singleton=False) endBarLine = BarlineFieldWriteV0(" ENDBARLINE", getter=endBarlineString) beatLength = BeatLengthFieldV0("BEATLENGTH") repeatCount = conditionalWriteField( PositiveIntegerField("REPEAT_COUNT"), lambda measure: measure.repeatCount > 1) alternateText = StringField("ALTERNATE") def hasSimile(measure): return measure.simileDistance > 0 simileDistance = conditionalWriteField(NonNegativeIntegerField("SIMILE"), hasSimile) simileIndex = conditionalWriteField(NonNegativeIntegerField("SIMINDEX"), hasSimile) def makeObject(self, objectData): return self.targetClass(int(objectData)) def startTagData(self, source): return str(len(source))
class MetadataStructureV0(FileStructure): tag = "SCORE_METADATA" startTag = "SCORE_METADATA" targetClass = Data.ScoreMetaData.ScoreMetaData title = StringField("TITLE") artist = StringField("ARTIST") artistVisible = BooleanField("ARTISTVISIBLE") creator = StringField("CREATOR") creatorVisible = BooleanField("CREATORVISIBLE") bpm = PositiveIntegerField("BPM") bpmVisible = BooleanField("BPMVISIBLE") width = PositiveIntegerField("WIDTH") kitDataVisible = BooleanField("KITDATAVISIBLE") metadataVisible = BooleanField("METADATAVISIBLE") beatCountVisible = BooleanField("BEATCOUNTVISIBLE") emptyLinesVisible = BooleanField("EMPTYLINESVISIBLE") measureCountsVisible = BooleanField("MEASURECOUNTSVISIBLE")
class BeatStructureV1(FileStructure): tag = "BEAT" startTag = "BEAT_START" endTag = "BEAT_END" numTicks = PositiveIntegerField('NUM_TICKS') counter = dbfsv0.CounterFieldV0("COUNT") def postProcessObject(self, instance): return Data.Beat.Beat(instance["counter"], instance.get("numTicks"))
class BeatStructureV0(FileStructure): tag = "BEAT" startTag = "BEAT_START" endTag = "BEAT_END" numTicks = conditionalWriteField(PositiveIntegerField('NUM_TICKS'), lambda beat: beat.isPartial()) counter = CounterFieldV0("COUNT") def postProcessObject(self, instance): return Data.Beat.Beat(instance["counter"], instance.get("numTicks"))
class MeasureCountStructureV0(FileStructure): tag = "COUNT_INFO" startTag = "COUNT_INFO_START" endTag = "COUNT_INFO_END" repeat = conditionalWriteField(PositiveIntegerField('REPEAT_BEATS', getter = lambda count: count.numBeats()), lambda count: count.isSimpleCount()) beats = BeatStructureV0(singleton = False, getter = lambda count: ([count.beats[0]] if count.isSimpleCount() else count.beats)) def postProcessObject(self, instance): mCount = Data.MeasureCount.MeasureCount() if 'repeat' not in instance: instance["repeat"] = 1 mCount.beats = instance["beats"] * instance["repeat"] return mCount
class MeasureStructureV1(FileStructure): tag = "MEASURE" targetClass = Data.Measure.Measure counter = MeasureCountStructureV1() startBar = NonNegativeIntegerField("STARTBARLINE") notes = dbfsv0.NoteFieldV0("NOTE", getter = list, singleton = False) endBar = NonNegativeIntegerField("ENDBARLINE") repeatCount = PositiveIntegerField("REPEAT_COUNT") alternateText = StringField("ALTERNATE") simileDistance = conditionalWriteField(NonNegativeIntegerField("SIMILE"), lambda measure: measure.simileDistance > 0) simileIndex = conditionalWriteField(NonNegativeIntegerField("SIMINDEX"), lambda measure: measure.simileIndex > 0) showAbove = BooleanField("SHOWABOVE") aboveText = conditionalWriteField(Base64StringField("ABOVETEXT"), lambda measure: any(ch != " " for ch in measure.aboveText)) showBelow = BooleanField("SHOWBELOW") belowText = conditionalWriteField(Base64StringField("BELOWTEXT"), lambda measure: any(ch != " " for ch in measure.belowText)) newBpm = conditionalWriteField(NonNegativeIntegerField("NEWBPM"), lambda measure: measure.newBpm > 0)
class ScoreStructureV1(FileStructure): tag = "SCORE" targetClass = Data.Score.Score scoreData = dbfsv0.MetadataStructureV0() drumKit = DrumKitStructureV1() measures = MeasureStructureV1(singleton = False, getter = lambda score:list(score.iterMeasures()), setter = lambda score, msr: score.insertMeasureByIndex(0, measure = msr)) _sections = StringField("SECTION_TITLE", singleton = False) paperSize = StringField("PAPER_SIZE") lilysize = PositiveIntegerField("LILYSIZE") lilypages = NonNegativeIntegerField("LILYPAGES") lilyFill = BooleanField("LILYFILL") lilyFormat = NonNegativeIntegerField("LILYFORMAT") defaultCount = DefaultMeasureCountStructureV1() systemSpacing = NonNegativeIntegerField("SYSTEM_SPACE") fontOptions = dbfsv0.FontOptionsStructureV0() def postProcessObject(self, instance): instance.postReadProcessing() return instance