Esempio n. 1
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
Esempio n. 2
0
class NoteHeadStructureV1(FileStructure):
    tag = "NOTEHEAD"
    targetClass = Data.Drum.HeadData

    midiNote = NonNegativeIntegerField("MIDINOTE")
    midiVolume = NonNegativeIntegerField("MIDIVOLUME")
    effect = StringField("EFFECT")
    notationHead = StringField("NOTATIONHEAD")
    notationLine = IntegerField("NOTATIONLINE")
    notationEffect = StringField("NOTATIONEFFECT")
    stemDirection = IntegerField("STEM")
    shortcut = StringField("SHORTCUT")
Esempio n. 3
0
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")
Esempio n. 4
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))
Esempio n. 5
0
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")
Esempio n. 6
0
class DrumStructureV1(FileStructure):
    tag = "DRUM"

    name = StringField("NAME")
    abbr = StringField("ABBR")
    head = StringField("DEFAULT_HEAD")
    locked = BooleanField("LOCKED")
    headlist = StringField("HEADLIST",
                           getter = lambda drum: "".join(list(drum)))
    noteheads = NoteHeadStructureV1(singleton = False,
                                    getter = lambda drum: [drum.headData(head) for head in drum])

    def postProcessObject(self, instance):
        drum = Data.Drum.Drum(instance["name"],
                              instance["abbr"],
                              instance["head"],
                              instance["locked"])
        for head, headData in zip(instance["headlist"], instance["noteheads"]):
            drum.addNoteHead(head, headData)
        return drum
Esempio n. 7
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
Esempio n. 8
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)