I will do a workshop with schoolkids in may, making music with Sonic Pi. The teacher suggested the material should have a connection to classical music so I decided to build a “Polyphony Machine” - a code that generates a fabric of different yet related voices familiar from classical compositions. This is not an elaborate emulation of a specific period style but a demonstration of different techniques used to derive diverse voices from limited melodic and rhythmic material.
Also, this is not the starting point, but rather the perspective of the workshop, I guess I will introduce all the included techniques isolated for clarity.
One inspiration for this approach was the fugue machine app: https://alexandernaut.com/fuguemachine/
I will probably try to combine this with with @amiika´s great stuff on self-similar melodies:
Any ideas and comments are very welcome!
#Polyphony Machine with comments Bpm = 80 #tempo of the music in beats per minute; change it! #First we define the basic structures, which are used by the "live_loop"s to generate #the music Tonleiter = scale(:e4, :harmonic_minor, num_octaves: 2) #Scale - e harmonic minor; #Try major (":major" or ":ionian"), or, for really different results: #":major_pentatonic" or ":messiaen1" Akkord = (ring 0, 2, 4) #Defines the basic chord structure, which may result #in a major or minor chord, depending on the position in the scale Rhythmus_arp = (ring 0.25) #Defines the rhythm of the arpeggiated chords, #in this case continuous sixteenth notes Melodie = (ring 0, 4, 2, 3, 0, 1) #Defines the six notes of the melody, "0" being the first #in the scale, and so on #Try changing them but make sure it´s six of them Rhythmus_mel = (ring 0.5, 0.5, 0.25, 0.25, 0.25, 0.25) #Defines the rhythm of the melody. #In traditional notation these could be two eight notes and four sixteenth notes #The transposition moves the chord and the melody to different positions within the scale live_loop :Transposition do 4.times do Transposition = (ring 0, 5, 1, 4).tick #Try changing the transpositions! #If you use a different number than four, for example eight, make sure that #"8.times do" is in the line above, otherwise not all transpositions will be #activated sleep 3 #Defines the time to wait until the next transposition end tick_reset end live_loop :Spieler_Melodie do #In this "live_loop" the melody that was defined above #is actually played use_synth :piano #Defines the sound in use for this "live_loop" #if you want to change it, look in the help section for "synths" use_bpm Bpm #References to the tempo defined above 6.times do #Six repeats to play each of the six melody notes play Tonleiter[1 * Melodie.tick + Transposition], amp: 1.3, decay: 0.8, sustain: 0.5, release: 0.3 #"play" plays the "Melodie"-pattern; "amp" = amplification, #"decay", "sustain" & "release" define the sound envelope - try other values! #turning "amp:" to zero makes this "live_loop" silent sleep Rhythmus_mel.look * 4 #Here the rhythm is actually exercised; #By multiplying with four the eights and sixteenth notes become whole and half notes end tick_reset end live_loop :Spieler_Sequenz do #Plays the notes of the "Melodie" in a faster fashion use_synth :piano use_bpm Bpm 12.times do # The number of repeats is doubled because the melody is played faster and #longer due to the use of ".reflect " ".mirror" play Tonleiter[1 * Melodie.reflect.tick + Transposition] + 12, amp: 0.4, decay: 0.2, sustain: 0.2, release: 0.2 #"+ 12" transposes the Sequence one octave higher sleep Rhythmus_mel.mirror.look * 1 #By inserting ".reflect" the backwarts variant is added to the melody, #".mirror" does this to the rhythm in a slightly different way. #Delete these or interchange them for differing results! end tick_reset end live_loop :Spieler_Arpeggio do #This "live_loop" plays the chord changes use_synth :piano use_bpm Bpm 8.times do #Eight repeats result in a specific arpeggio pattern, try other repeats! play Tonleiter[Akkord.tick + Transposition], amp: 0.5, decay: 0.3, sustain: 0, release: 0.3 sleep Rhythmus_arp.look * 1 end tick_reset end live_loop :Spieler_Bass do #Playing the bass, transposed an octave lower by "- 12" #durch "- 12" use_synth :piano use_bpm Bpm 6.times do play Tonleiter[1 * Melodie.tick + Transposition] - 12, amp: 0.8, decay: 0.2, sustain: 0.2, release: 0.2 sleep Rhythmus_mel.look * 2 #By multiplying with two eight and sixteenth notes become half and quarter notes end tick_reset end