Exemplo n.º 1
0
def sevenths(key):
	"""Returns 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), diatonic.get_notes(key))
	_sevenths_cache[key] = res
	return res
Exemplo n.º 2
0
def sevenths(key):
    """Returns 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), diatonic.get_notes(key))
    _sevenths_cache[key] = res
    return res
Exemplo n.º 3
0
def triads(key):
	"""Returns 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), diatonic.get_notes(key))
	_triads_cache[key] = res
	return res
Exemplo n.º 4
0
def diatonic(note):
	"""Returns the diatonic scale starting on note.
	Example:
{{{
>>> diatonic("C")
["C", "D", "E", "F", "G", "A", "B"]
}}}"""
	return get_notes(note)
Exemplo n.º 5
0
def triads(key):
    """Returns 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), diatonic.get_notes(key))
    _triads_cache[key] = res
    return res
Exemplo n.º 6
0
def diatonic(note):
    """Returns the diatonic scale starting on note.
    Example:
{{{
>>> diatonic(\"C\")
[\"C\", \"D\", \"E\", \"F\", \"G\", \"A\", \"B\"]
}}}"""

    return get_notes(note)
Exemplo n.º 7
0
def natural_minor(note):
	"""Returns the natural minor scale starting on note.
	Example:
{{{
>>> natural_minor("A")
["A", "B", "C", "D", "E", "F", "G"]
}}}"""
	s = get_notes(notes.to_major(note))
	return s[5:] + s[:5]
Exemplo n.º 8
0
def diatonic(note):
    """Returns the diatonic scale starting on note.
    Example:
{{{
>>> diatonic(\"C\")
[\"C\", \"D\", \"E\", \"F\", \"G\", \"A\", \"B\"]
}}}"""

    return get_notes(note)
Exemplo n.º 9
0
def natural_minor(note):
    """Returns the natural minor scale starting on note.
    Example:
{{{
>>> natural_minor(\"A\")
[\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]
}}}"""

    s = get_notes(notes.to_major(note))
    return s[5:] + s[:5]
Exemplo n.º 10
0
def natural_minor(note):
    """Returns the natural minor scale starting on note.
    Example:
{{{
>>> natural_minor(\"A\")
[\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]
}}}"""

    s = get_notes(notes.to_major(note))
    return s[5:] + s[:5]
Exemplo n.º 11
0
def get_interval(note, interval, key = 'C'):
	"""Gets 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 = diatonic.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:])
Exemplo n.º 12
0
def get_interval(note, interval, key='C'):
    """Gets 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 = diatonic.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:])