More sharing from my Sonic Pi archive of experiments and ideas…
This one concerns “voice leading” which is a musical technique for making chord sequences sound nice(er).
To give a brief explanation, it helps to think about some notes on a piano. If you’re changing chords between C major and F major there are a couple of ways to do it (imagine each note is a “voice” like a singer in a choir)
C -> F
E -> A
G -> C
This is ok and gets used in a lot of rock and pop (think the first two chords of “Louie Louie”).
But if you want your music to sound like butter melting on a stack of freshly cooked pancakes, then this is better:
C -> C
E -> F
G -> A
Same set of notes on the right and the left but they’re now reordered slightly on the right to make sure that each voice moves as little as possible. This is voice leading in a nutshell and it’s a great thing to bear in mind when working with chords.
Now, is there an algorithm that can help us with this? Yes! It’s called the taxi cab metric and I stole it from the book “The Geometry of Music” by Dmitri Tymoczko. It’s in this gist here with an example https://gist.github.com/xavriley/1ea12a3d319dfcf86152
It looks pretty complicated but it’s not too bad really. That code is pretty scrappy though and I’m sure it could be more elegant. The reason I haven’t pushed for this to be in Sonic Pi proper yet is because I don’t know what it should look like.
Essentially it needs two arguments - a starting chord and a sequence (array) of chords to move to. It should probably yield an enumerator of nicely voice led chords as an output. If anyone has more ideas about how they’d like this to work then lets discuss…