MCPcopy Create free account
hub / github.com/bspaans/python-mingus / interval

Function interval

mingus/core/intervals.py:38–54  ·  view source on GitHub ↗

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'

(key, start_note, interval)

Source from the content-addressed store, hash-verified

36
37
38def interval(key, start_note, interval):
39 """Return the note found at the interval starting from start_note in the
40 given key.
41
42 Raise a KeyError exception if start_note is not a valid note.
43
44 Example:
45 >>> interval('C', 'D', 1)
46 'E'
47 """
48 if not notes.is_valid_note(start_note):
49 raise KeyError("The start note '%s' is not a valid note" % start_note)
50 notes_in_key = keys.get_notes(key)
51 for n in notes_in_key:
52 if n[0] == start_note[0]:
53 index = notes_in_key.index(n)
54 return notes_in_key[(index + interval) % 7]
55
56
57def unison(note, key=None):

Callers 7

unisonFunction · 0.85
secondFunction · 0.85
thirdFunction · 0.85
fourthFunction · 0.85
fifthFunction · 0.85
sixthFunction · 0.85
seventhFunction · 0.85

Calls 2

KeyErrorClass · 0.85
get_notesMethod · 0.80

Tested by

no test coverage detected