INNER CODE UNIT · Python

chord_list_

microsoft/muzic · musicagent/auxiliary/muzic/roc/main.py:45

    chord_list_ = chord_list_[chord_ptr:] + chord_list_[:chord_ptr]
    re_str = ''

    if not is_last_sentence:
        key = ''
    else:
        if is_maj:
            key = ' C:'
        else:
            key = ' A:m'

    # For the given chord progression, we generate a regex like:
    # A:m F: G: C: -> ^A:m( A:m)*( F:)+( G:)+( C:)*$|^A:m( A:m)*( F:)+( G:)*$|^A:m( A:m)*( F:)*$|^A:m( A:m)*$
    # Given the regex, we find matched pieces.
    # We design the regex like this because alternations in regular expressions are evaluated from left to right,
    # the piece with the most various chords will be selected, if there's any.
    for j in range(len(chord_list_), 0, -1):
        re_str += '^({}( {})*'.format(chord_list_[0], chord_list_[0])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…