Turbo, Maths and Music

I have already written about some of the creative aspects of Turbo, the piece of music I am currently working on here https://edvirtual440.wordpress.com/2019/07/22/turbo/, but following interest from a number of people here is a bit of a deeper dive into the mathematics of the piece.

Under the gloss and shine of the main body of the work there is a continuous recording of a Ferrari 412 T2 F1 car. The recording starts played back very slowly; gradually getting quicker until it is at normal (breakneck!) speed at the end.
Artistically this was done to draw the listener in, there is a slow but impending inexorability about it but I wanted it to work creatively as more than just a cheap trick.

The playback speed is modelled on a golden spiral (i.e. a logarithmic spiral whose growth factor is φ the golden ratio) a design found not only in some engine turbos but also the humble snail from which the component took its name.

A golden spiral with initial radius 1 has the following polar equation:

\ r = \varphi^{\theta\frac{2}{\pi}}\,

If one were to travel inwards on such a spiral at a constant speed the time it would take to describe a full rotation around the centre decreases. While your speed would stay the same, in terms of RPM you would be accelerating. The manipulated Ferrari recording follows this pattern making 3 full rotations of the spiral appearing to get faster towards the epicentre at the end of the piece.

At a simple level digital audio works a lot like animation. A snapshot of a soundwave is taken numerous times a second (44100 for CD quality) and these snapshots are essentially then played back in order to create a close likeness to the original continuous sound. Just like animation and flip-books you can change how fast you leaf through the individual ‘pages’, and thus gain mastery of speeding up, slowing down or even appearing to reverse time.

The piece of music was to be 8 mins 39 seconds long. I wanted the Ferrari to be at normal playback speed at 8:38. Hence it was a task of mapping the sample rate to time or its equivalent distance along the spiral. Looking at it backwards I was aiming for a sampling rate of 44100 Hz at 8:38 with that rate decreasing by the proportions of the golden spiral as the time elapsed from the beginning of the piece of music trended to 0. 

Several cups of tea later I came up with the following which gives sample rate (Hz) relative to time (s). This is copied from the code which I had left deliberately un-simplified so that I could still almost see what I was doing!

Sample rate =44100(1/(pow(((1+sqrt(5))/2),((LOG(1-((1-pow((1+sqrt(5))/2,(12)))/(1-(1+sqrt(5))/2)-TIME)+(((1+sqrt(5))/2)*((1-pow((1+sqrt(5))/2,(12)))/(1-(1+sqrt(5))/2)-TIME))))/(log((1+sqrt(5))/2)))-1)))

This resulted in a gradual and inevitable winding up of speed but was still very ugly not to mention the processing power it drew before even handling audio. It turns out that trying to feed a digital-analogue converter floating values for sample rate (as opposed to integers) is not a great idea and leads to clicks and glitches. This brought down my need for fine grained resolution by a significant factor. In addition the difference of +/- of half sample is inaudible when 44100 are going past in a second! 

This meant that rather than calculate it all on the fly I stuck the formula into and excel spreadsheet and told it to calculate relative to the rows while rounding to the nearest integer; hence an instant lookup table with a revised sample rate for every second. Incidentally it started off *really* slowly at 221 samples in the first second!

I then cooked up a simple playback and record program (it has had 2 incarnations, being initially built in MAX/Msp and later Supercollider due to cross platform issues). It takes the excel table and looks at the values over time, interpolating between the 1 second breakpoints and applies this to the playback speed of the audio while simultaneously recording the output to disk. 

The net result is a lookup table and a bit of ramping between values; far more computationally efficient than the junk equation above! Sonically if produces a seamless transition from inaudible, through rumbling sub-bass, murmuring rumbles up to urgent build and finally a howling drive-by.

Turbo is due for release in October on Spotify, iTunes, Bandcamp etc. (click the links to go direct to the artist page). For more info see www.virtual440.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s