Ejemplo n.º 1
0
def parse_kern_note(note, accs):
    """Return a string representation of a note from the tokenizer representation.

    Humdrum represents flats as dashes ('-'); we replace them with 'b's:

    >>> parse_kern_note('cc', '--')
    'Cbb'
    """

    return note[0].upper() + utils.replace_flats("".join(accs))
Ejemplo n.º 2
0
def parse_key_signature(item):
    item = item[1:-1]
    split_item = [item[i] + item[i+1] for i in range(0, len(item), 2)]
    list_keys = [utils.replace_flats(x.lower().strip()) for x in split_item]
    size = len(list_keys)
    sharps = music.accidentals_table[size]
    flats = music.accidentals_table[-size]

    if list_keys == sharps:
        return score.Tandem("key-signature", size)
    elif list_keys == flats:
        return score.Tandem("key-signature", -size)
    else:
        return score.Tandem("key-signature", list_keys)
Ejemplo n.º 3
0
def test_replace_flats():
    assert utils.replace_flats("CC--") == "CCbb"
Ejemplo n.º 4
0
def parse_key(item):
    return score.Tandem("key", utils.replace_flats(item))