Deriving Keys from Chords in Music

  • This post shows that some very simplistic algorithms can’t unambiguously determine a key. But I don’t think it establishes that a more sophisticated algorithm could not. Key center is not just based on chords and notes in a scale. It’s based on the note/chord that seems like the place where the music is at rest, or at home. Many songs have non-diatonic chords, but it’s still fairly obvious what key they are in.

    That said, there are examples where they key is ambiguous even to humans (e.g. Hey Joe [C G D A E], or Sweet Home Alabama [D C G] but disputed whether it’s in G or in D).

  • Related: When I was off work in December I used graph theory to find chord paths through keys:

    http://signalsandsorcery.com/

    You can see from the graph that chords exist in multiple keys and you can move from one key to another via these shared chords known as 'pivot chords'

  • Talking about this stuff without saying what kind of music you mean seems a little silly. There is a reference to "one popular song", and it seems the author is thinking of pop music. But it seems most things that can be said about keys/chords in one genre/tradition/style, don't apply to others. And even within genres, things naturally evolve so that old rules no longer apply.

  • > A song could reasonably have a chord progression such as {Am, G, D, Am, G, Dm}, and the inclusion of both {D} and {Dm} would cause conflicts. Given that music theorists cannot agree on this stuff, there doesn't seem to be anything a computer can do that is better.

    Whilst I'm no expert, I'm pretty sure we have hundreds of years of examples of borrowed chords [1] for music theorists to agree upon, so yes plenty of things a computer could do better (as per other comments).

    [1] https://en.wikipedia.org/wiki/Borrowed_chord

  • One useful heuristic (at least, the one I usually go to first if I'm not sure what key a song is in) is that root of the final chord of the song is often the same as the root of the key. I suppose that probably works better for some music traditions than others. Also I believe some songs in a minor key sometimes end by converting the root chord to major.

  • In college I built a project that could reasonably well predict the key of a given piece based on the distribution of note usage. For example, most pieces written in a major key would have the highest usage of the root, and the dominant of a key.

    This obviously has a number flaws, but worked remarkably well for western music written between 1600 and 1900.

  • Is the first example with C and Am correct? It says the first chord of Am scale is A, shouldn't it be Am?

  • I had never thought about a key of a song being ‘variable’ but being set in stone. Interesting to have a mindset challenge.

  • If you can't tell the difference, perhaps the answer is both.

  • I definitely thought this was going in a cryptography direction from the title. I actually kind of like the idea of composing music to generate a secret key :)

  • Awesome. So what key is Revelation Song by Phillips Craig and Dean in?

  • That's easy, just pick the last chord in the piece.

  • I am no musician. I heard quite a few musicians, with or without innate perfect pitch, can tell the keys in a chord, though maybe not to the 100% accuracy. For example, something like what the kid is doing in this video [1]. I am a bit surprised that this can't be done programmatically.

    [1] https://www.youtube.com/watch?v=vXivZlPu0ms&t=175s