示例#1
0
def test_HumdrumLine_data():
    line = HumdrumLine('4f]\t.\t2D\t(1cc\t.')
    line.createTokensFromLine()
    CheckHumdrumLine(line, expectedLine = '4f]\t.\t2D\t(1cc\t.',
                           expectedLineNumber = 0,
                           expectedType = LINETYPE_DATA,
                           expectedTokenCount = 5,
                           expectedIsExclusiveInterpretation = False,
                           expectedIsManipulator = False,
                           expectedTokens = ['4f]', '.', '2D', '(1cc', '.'])
示例#2
0
def test_HumdrumLine_barline():
    line = HumdrumLine('=1\t=1\t=1')
    line.createTokensFromLine()
    CheckHumdrumLine(line, expectedLine = '=1\t=1\t=1',
                           expectedLineNumber = 0,
                           expectedType = LINETYPE_BARLINE,
                           expectedTokenCount = 3,
                           expectedIsExclusiveInterpretation = False,
                           expectedIsManipulator = False,
                           expectedTokens = ['=1', '=1', '=1'])
示例#3
0
def test_HumdrumLine_manipulators():
    line = HumdrumLine('*\t*^\t*-\t*')
    line.createTokensFromLine()
    CheckHumdrumLine(line, expectedLine = '*\t*^\t*-\t*',
                           expectedLineNumber = 0,
                           expectedType = LINETYPE_INTERPRETATION,
                           expectedTokenCount = 4,
                           expectedIsExclusiveInterpretation = False,
                           expectedIsManipulator = True,
                           expectedTokens = ['*', '*^', '*-', '*'])
示例#4
0
def test_HumdrumLine_single_exinterp():
    line = HumdrumLine('**kern')
    line.createTokensFromLine()
    CheckHumdrumLine(line, expectedLine = '**kern',
                           expectedLineNumber = 0,
                           expectedType = LINETYPE_INTERPRETATION,
                           expectedTokenCount = 1,
                           expectedIsExclusiveInterpretation = True,
                           expectedIsManipulator = True,
                           expectedTokens = ['**kern'])
示例#5
0
    def transferTokens(self, outFile: HumdrumFile, recip: bool):
        line: HumdrumLine = HumdrumLine()
        voice: GridVoice = None
        emptyStr: str = '.'

        if self.isMeasureSlice:
            if len(self.parts) > 0:
                if len(self.parts[0].staves[0].voices) > 0:
                    voice = self.parts[0].staves[0].voices[0]
                    if voice.token is not None:
                        emptyStr = voice.token.text
                    else:
                        emptyStr = '=YYYYYY'
                else:
                    emptyStr = '=YYYYYY'
        elif self.isInterpretationSlice:
            emptyStr = '*'
        elif self.isLocalLayoutSlice:
            emptyStr = '!'
        elif not self.hasSpines:
            emptyStr = '???'

        if recip:
            token: HumdrumToken = None

            if self.isNoteSlice:
                token = self._createRecipTokenFromDuration(self.duration)
            elif self.isClefSlice:
                token = HumdrumToken('*')
                emptyStr = '*'
            elif self.isMeasureSlice:
                if len(self.parts[0].staves[0]) > 0:
                    voice = self.parts[0].staves[0].voices[0]
                    token = HumdrumToken(voice.token.text)
                else:
                    token = HumdrumToken('=XXXXX')
                emptyStr = token.text
            elif self.isInterpretationSlice:
                token = HumdrumToken('*')
                emptyStr = '*'
            elif self.isGraceSlice:
                token = HumdrumToken('q')
                emptyStr = '.'
            elif self.hasSpines:
                token = HumdrumToken('55')
                emptyStr = '!'

            if token is not None:
                if self.hasSpines:
                    line.appendToken(token)
                else:
                    token = None

        # extract the Tokens from each part/staff
        for p in range(len(self.parts) - 1, -1, -1):
            part = self.parts[p]
            if not self.hasSpines and p != 0:
                continue
            for s in range(len(part.staves) - 1, -1, -1):
                staff = part.staves[s]
                if not self.hasSpines and s != 0:
                    continue
                if len(staff.voices) == 0:
                    # 888: fix this later.  For now if there are no notes
                    # 888: ... on the staff, add a null token.  Fix so that
                    # 888: ... all open voices are given null tokens.
                    line.appendToken(HumdrumToken(emptyStr))
                else:
                    for voice in staff.voices:  # NOT reversed (voices different from parts/staves)
                        if voice is not None and voice.token is not None:
                            line.appendToken(voice.token)
                        else:
                            line.appendToken(HumdrumToken(emptyStr))

                if not self.hasSpines:
                    # Don't add sides to non-spined lines
                    continue

                maxxcount: int = self.getXmlIdCount(p, s)
                maxdcount: int = self.getDynamicsCount(p, s)
                maxvcount: int = self.getVerseCount(p, s)
                self.transferSidesFromStaff(line, staff, emptyStr, maxxcount,
                                            maxdcount, maxvcount)

            if not self.hasSpines:
                # Don't add sides to non-spined lines
                continue

            maxhcount: int = self.getHarmonyCount(p)
            maxfcount: int = self.getFiguredBassCount(p)
            self.transferSidesFromPart(line, part, emptyStr, maxhcount,
                                       maxfcount)

        outFile.appendLine(line)
示例#6
0
def test_HumdrumLine_default_init():
    line = HumdrumLine()
    line.createTokensFromLine()
    CheckHumdrumLine(line)