Oops! A couple of links were wrong. Now corrected.
Following on from the Covent Pi Jam, I have had a creative few days developing three further pieces of code for Sonic Pi 2.1 At Sam Aaron’s suggestion I now put these on sound.cloud.com and publish the code as a gist. This is quick and easy to do and I think makes everything very accessible. I won’t repeat the code or the sound tracks here, but I will say a little about each one, and give you the links to find them.
First Harmonised scales. This came about when I experimented with defining functions to produce the first and second inversions of given chords. Musically a C major triad for octave 4 consists of the notes :c4, :e4 and :g4
To produce the first inversion, you remove the bottom note :c4 and add it to the top of the chord making :e4, :g4 and :c5
To get the second inversion you repeat the process removing teh new bottom note :e4 and adding it an octave higher at the top of the chord to give :g4,:c5 and :e5
If you harmonise a scale of c you play the chords c major, d minor, e minor, f major,
g major, a minor, b diminished and back to c major in the next octave.
I played with this and came up with code to play a rising octave in the base with these chords and their two inversions played with each note, first up an octave then back down again. The whole thing was repeated with semitone increments 12 times, rather like the singing exercises done when warming up.
The link to sound cloud for HarmonisedScales is here and it contains a link to the gist code on that site.
The second example was to produce a percussion generator. I was looking for an efficient way to build up a rhythm track, and looked on the internet to find an article which described the use of a grid for this purpose.
I coded a similar technique into sonic pi, using two grids, one to signify when a particular instrument should be played, the other to specify one of three volumes for the instrument at each point. These were sorted in a hash array, together with the instrument sample names. I set up three different combinations, and then played these using a live_loop so that the track chosen could be switched to another one each time it finished.
The link to sound cloud for PercussionGenerator is here and it contains a link to the gist code on that site.
The third example uses an idea I used previously to generate the glass armonica sample based voice using the :ambi_glass_rubbed sample built in to Sonic Pi. This time I chose a range of sample from the Bass sounds family again built in to Sonic Pi. All of these bar one were sampled on the same note :c2, so by calculating the rates to play the samples to give other notes over a three octave range I could build up code which could use any of these voices to produce “notes” at the required pitch. I used similar code to the glass armonica project to define function to play a single sample note and to play arrays of notes and durations using the specified sample voice. One of the samples was discarded as the sound was too short to be used in a meaningful manner. With the others I wrote demo code to play a variety of scales using the different voices, and finished with 100 notes which played notes of random pitch, duration, sample voice and pan position.
The link to sound cloud for Bass Sounds Sample Voices is here and it contains a link to the gist code on that site.