Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.10.2.

librosa.key_to_degrees

librosa.key_to_degrees(key)[source]

Construct the diatonic scale degrees for a given key.

Parameters:
keystr

Must be in the form TONIC:key. Tonic must be upper case (CDEFGAB), key must be lower-case (maj or min).

Single accidentals (b!♭ for flat, or #♯ for sharp) are supported.

Examples: C:maj, Db:min, A♭:min.

Returns:
degreesnp.ndarray

An array containing the semitone numbers (0=C, 1=C#, … 11=B) for each of the seven scale degrees in the given key, starting from the tonic.

See also

key_to_notes

Examples

>>> librosa.key_to_degrees('C:maj')
array([ 0,  2,  4,  5,  7,  9, 11])
>>> librosa.key_to_degrees('C#:maj')
array([ 1,  3,  5,  6,  8, 10,  0])
>>> librosa.key_to_degrees('A:min')
array([ 9, 11,  0,  2,  4,  5,  7])