예제 #1
0
def metadataToString(music21Metadata, returnBrailleUnicode=False):
    '''
    >>> from music21.braille import translate
    >>> corelli = corpus.parse('monteverdi/madrigal.3.1.rntxt')
    >>> mdObject = corelli.getElementsByClass('Metadata')[0]
    >>> mdObject.__class__
    <class 'music21.metadata.Metadata'>
    >>> print(translate.metadataToString(mdObject))
    Alternative Title: 3.1
    Title: La Giovinetta Pianta

    >>> print(translate.metadataToString(mdObject, returnBrailleUnicode=True))
    ⠠⠁⠇⠞⠑⠗⠝⠁⠞⠊⠧⠑⠀⠠⠞⠊⠞⠇⠑⠒⠀⠼⠉⠲⠁
    ⠠⠞⠊⠞⠇⠑⠒⠀⠠⠇⠁⠀⠠⠛⠊⠕⠧⠊⠝⠑⠞⠞⠁⠀⠠⠏⠊⠁⠝⠞⠁
    '''
    allBrailleLines = []
    for key in music21Metadata._workIds:
        value = music21Metadata._workIds[key]
        if value is not None:
            n = ' '.join(re.findall(r'([A-Z]*[a-z]+)', key))
            outString = '{0}: {1}'.format(n.title(), value)
            if returnBrailleUnicode:
                outTemp = []
                for word in outString.split():
                    outTemp.append(wordToBraille(word))
                outString = alphabet[' '].join(outTemp)
            allBrailleLines.append(outString)
    return '\n'.join(sorted(allBrailleLines))
예제 #2
0
def metadataToString(music21Metadata, returnBrailleUnicode=False):
    """
    >>> from music21.braille import translate
    >>> corelli = corpus.parse("monteverdi/madrigal.3.1.rntxt")
    >>> mdObject = corelli.getElementsByClass('Metadata')[0]
    >>> mdObject.__class__
    <class 'music21.metadata.Metadata'>
    >>> print(translate.metadataToString(mdObject))
    Alternative Title: 3.1
    Title: La Giovinetta Pianta

    >>> print(translate.metadataToString(mdObject, returnBrailleUnicode=True))
    ⠠⠁⠇⠞⠑⠗⠝⠁⠞⠊⠧⠑⠀⠠⠞⠊⠞⠇⠑⠒⠀⠼⠉⠲⠁
    ⠠⠞⠊⠞⠇⠑⠒⠀⠠⠇⠁⠀⠠⠛⠊⠕⠧⠊⠝⠑⠞⠞⠁⠀⠠⠏⠊⠁⠝⠞⠁
    """
    allBrailleLines = []
    for key in music21Metadata._workIds:
        value = music21Metadata._workIds[key]
        if value is not None:
            n = " ".join(re.findall(r"([A-Z]*[a-z]+)", key))
            outString = "{0}: {1}".format(n.title(), value)
            if returnBrailleUnicode:
                outTemp = []
                for word in outString.split():
                    outTemp.append(wordToBraille(word))
                outString = alphabet[' '].join(outTemp)
            allBrailleLines.append(outString)
    return '\n'.join(sorted(allBrailleLines))