Пример #1
0
def sevenths(key):
    """Return all the sevenths chords in key in a list."""
    if _sevenths_cache.has_key(key):
        return _sevenths_cache[key]
    res = map(lambda x: seventh(x, key), keys.get_notes(key))
    _sevenths_cache[key] = res
    return res
Пример #2
0
def sevenths(key):
    """Return all the sevenths chords in key in a list."""
    if _sevenths_cache.has_key(key):
        return _sevenths_cache[key]
    res = map(lambda x: seventh(x, key), keys.get_notes(key))
    _sevenths_cache[key] = res
    return res
Пример #3
0
def triads(key):
    """Return all the triads in key.

    Implemented using a cache.
    """
    if _triads_cache.has_key(key):
        return _triads_cache[key]
    res = map(lambda x: triad(x, key), keys.get_notes(key))
    _triads_cache[key] = res
    return res
Пример #4
0
def triads(key):
    """Return all the triads in key.

    Implemented using a cache.
    """
    if _triads_cache.has_key(key):
        return _triads_cache[key]
    res = map(lambda x: triad(x, key), keys.get_notes(key))
    _triads_cache[key] = res
    return res
Пример #5
0
def interval(key, start_note, interval):
    """Return the note found at the interval starting from start_note in the
    given key.

    Raise a KeyError exception if start_note is not a valid note.

    Example:
    >>> interval('C', 'D', 1)
    'E'
    """
    if not notes.is_valid_note(start_note):
        raise KeyError("The start note '%s' is not a valid note" % start_note)
    notes_in_key = keys.get_notes(key)
    for n in notes_in_key:
        if n[0] == start_note[0]:
            index = notes_in_key.index(n)
    return notes_in_key[(index + interval) % 7]
Пример #6
0
def get_interval(note, interval, key='C'):
    """Return the note an interval (in half notes) away from the given note.

    This will produce mostly theoretical sound results, but you should use
    the minor and major functions to work around the corner cases.
    """
    intervals = map(lambda x: (notes.note_to_int(key) + x) % 12, [
        0,
        2,
        4,
        5,
        7,
        9,
        11,
    ])
    key_notes = keys.get_notes(key)
    for x in key_notes:
        if x[0] == note[0]:
            result = (intervals[key_notes.index(x)] + interval) % 12
    if result in intervals:
        return key_notes[intervals.index(result)] + note[1:]
    else:
        return notes.diminish(key_notes[intervals.index((result + 1) % 12)] +
                              note[1:])
Пример #7
0
def main():
    
    print(chords.from_shorthand("Cm/G"))
    print(keys.get_notes("C"))
Пример #8
0
def main():

    print(chords.from_shorthand("Cm/G"))
    print(keys.get_notes("C"))