Пример #1
0
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))
Пример #2
0
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
Пример #3
0
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"))
Пример #4
0
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)
Пример #5
0
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