music.invert

music.invert(notes, degree=0, octaves=1)[source]

Move one note of a chord by whole octaves.

The article: “Inversions and open positions can be obtained with the addition of +/- 12 to the selected note.”

Parameters:
notestuple of integers

The chord.

degreeinteger

Which note to move, indexed from the bottom.

octavesinteger

How many octaves, and which way. Positive moves it up.

Returns:
tuple of integers

The chord with that note moved, sorted again so the result reads from the bottom up.

Raises:
IndexError

If degree is not a note of notes.

Parameters:
Return type:

tuple[int, …]

Examples

>>> invert(chord('major'), degree=0)
(4, 7, 12)
>>> invert(chord('major'), degree=2, octaves=-1)
(-5, 0, 4)
>>> invert(chord('major'), degree=2, octaves=1)  # an open position
(0, 4, 19)