pyechonest - how to interpret "key" and "mode" attributes?

202 views Asked by At

I'm using pyechonest (v9.0.0) with Python (v2.7.9) on PC (Win 8.1) and having issues with interpreting the data returned with regard to the "key" and "mode" attributes. "Key" is supposed to return what musical key the Echonest believes a music track to be recorded in and "mode" will determine whether it's a major or minor key. However there are contradictory ways to interpret this when using the Track method...

In the pyechonest documentation indicates the "key" is an integer 0-11 with 0 representing the key of C and 11 the key of B flat. "Mode" is 0-1 with 0 indicating "major" and 1 indicating "minor": http://echonest.github.io/pyechonest/track.html

However the Echonest documentation contradicts this; key==0 is "C" and key==11 is "B" (not B flat as per pyechonest docs) and mode==0 is minor with mode==1 being major (the 0/1 major/minor relationship is switched): http://developer.echonest.com/docs/v4/song.html

Does anyone know which one is the real interpretation? Only way I can come up with to figure it out is to upload a music sample for which I know the key and mode and see what the Echonest returns.

1

There are 1 answers

2
jonrsharpe On BEST ANSWER

Clearly key == 11 corresponds to B, not Bb, because otherwise the numbers don't work:

0 1  2 3  4 5 6  7 8  9 10 11
C Db D Eb E F Gb G Ab A Bb B

For the mode, I can't tell without diving into the source which is correct; I suggest you raise an issue on pyechonest's GitHub repo asking the developers to review and clarify, but based on the other error I'd be inclined to trust the API docs first!