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.
(note, interval, key="C")
| 234 | |
| 235 | |
| 236 | def get_interval(note, interval, key="C"): |
| 237 | """Return the note an interval (in half notes) away from the given note. |
| 238 | |
| 239 | This will produce mostly theoretical sound results, but you should use |
| 240 | the minor and major functions to work around the corner cases. |
| 241 | """ |
| 242 | intervals = [(notes.note_to_int(key) + x) % 12 for x in [0, 2, 4, 5, 7, 9, 11,]] |
| 243 | key_notes = keys.get_notes(key) |
| 244 | for x in key_notes: |
| 245 | if x[0] == note[0]: |
| 246 | result = (intervals[key_notes.index(x)] + interval) % 12 |
| 247 | if result in intervals: |
| 248 | return key_notes[intervals.index(result)] + note[1:] |
| 249 | else: |
| 250 | return notes.diminish(key_notes[intervals.index((result + 1) % 12)] + note[1:]) |
| 251 | |
| 252 | |
| 253 | def measure(note1, note2): |