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

Function get_interval

mingus/core/intervals.py:236–250  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

234
235
236def 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
253def measure(note1, note2):

Callers

nothing calls this directly

Calls 2

get_notesMethod · 0.80
diminishMethod · 0.45

Tested by

no test coverage detected