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)
| 36 | |
| 37 | |
| 38 | def 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 | |
| 57 | def unison(note, key=None): |