Last active
July 25, 2020 12:18
-
-
Save Enkerli/0b61753984bfaebbfa34 to your computer and use it in GitHub Desktop.
Scripts d’exemples pour Sonic Pi dans le cadre d’un cours du programme de médias interactifs au Cégep André-Laurendeau, le 29 mars 2016.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Intro | |
# https://rbnrpi.wordpress.com/2015/04/06/musical-fireworks-with-sonic-pi-and-minecraft/ | |
# Ex 1: Notes | |
## # Ex 1a: Play | |
play 60 | |
## # Ex 1b: Play 2 | |
play 60 | |
play 56 | |
## # Ex 1c: Sleep | |
play 60 | |
sleep 1 | |
play 56 | |
## # Ex 1d: Loop | |
loop do | |
play 60 | |
sleep 1 | |
play 56 | |
end | |
## # Ex 1e: Loop Sleep | |
loop do | |
play 60 | |
sleep 1 | |
play 56 | |
sleep 1 | |
end | |
# Ex 2: Motifs | |
## # Ex 2a: Pattern | |
play_pattern [60, 56] | |
## # Ex 2b: Pattern 3 | |
play_pattern [60, 56, 63] | |
## # Ex 2c: Tempo | |
play_pattern_timed [60,56,63],[0.6, 0.3] | |
## # Ex 2d: Tempo 5 | |
play_pattern_timed [60,56,63,56,60],[0.6, 0.3] | |
# Ex 3: Classique (Menuet en sol de Bach) | |
## # Ex 3a: Bach Minuet in G | |
# | |
# Coded by Robin Newman | |
use_bpm 60 | |
use_synth_defaults release: 0.5, amp: 0.7, cutoff: 90 | |
use_synth :beep | |
## Each section of the minuet is repeated | |
2.times do | |
## First start a thread for the first 8 bars of the bass left hand part | |
in_thread do | |
play_chord [55,59]#b1 | |
sleep 1 | |
play_pattern_timed [57],[0.5] | |
play_pattern_timed [59],[1.5] #b2 | |
play_pattern_timed [60],[1.5] #b3 | |
play_pattern_timed [59],[1.5] #b4 | |
play_pattern_timed [57],[1.5] #b5 | |
play_pattern_timed [55],[1.5] #b6 | |
play_pattern_timed [62,59,55],[0.5] #b7 | |
play_pattern_timed [62],[0.5] #b8 | |
play_pattern_timed [50,60,59,57],[0.25] | |
end | |
## Play concurrently the first 8 bars of the right hand part | |
play_pattern_timed [74],[0.5]#b1 | |
play_pattern_timed [67,69,71,72],[0.25] | |
play_pattern_timed [74,67,67],[0.5]#b2 | |
play_pattern_timed [76],[0.5]#b3 | |
play_pattern_timed [72,74,76,78],[0.25] | |
play_pattern_timed [79,67,67],[0.5]#b4 | |
play_pattern_timed [72],[0.5] #b5 | |
play_pattern_timed [74,72,71,69],[0.25] | |
play_pattern_timed [71],[0.5] #b6 | |
play_pattern_timed [72,71,69,67],[0.25] | |
play_pattern_timed [66],[0.5] #b7 | |
play_pattern_timed [67,69,71,67],[0.25] | |
play_pattern_timed [71,69],[0.5,1] #b8 | |
## Start a new thread for bars 9-16 of the left hand part | |
in_thread do | |
play_chord [55,59]#b9=b1 | |
sleep 1 | |
play 57 | |
sleep 0.5 | |
play_pattern_timed [55,59,55],[0.5] #b10 | |
play_pattern_timed [60],[1.5] #b11=b3 | |
play_pattern_timed [59,60,59,57,5],[0.5,0.25,0.25,0.25,0.25] #b12=b4] | |
play_pattern_timed [57,54],[1,0.5] #b13 | |
play_pattern_timed [55,59],[1,0.5] #b14 | |
play_pattern_timed [60,62,50],[0.5] #b15 | |
play_pattern_timed [55,43],[1,0.5] #b16 | |
end | |
## Play concurrently bars 9-16 of the right hand part the first six | |
## bars repeat bars 1-6 | |
play_pattern_timed [74],[0.5]#b9 = b1 | |
play_pattern_timed [67,69,71,72],[0.25] | |
play_pattern_timed [74,67,67],[0.5]#b10=b2 | |
play_pattern_timed [76],[0.5]#b11=b3 | |
play_pattern_timed [72,74,76,78],[0.25] | |
play_pattern_timed [79,67,67],[0.5]#b12=b4 | |
play_pattern_timed [72],[0.5] #b13=b5 | |
play_pattern_timed [74,72,71,69],[0.25] | |
play_pattern_timed [71],[0.5] #b14=b6 | |
play_pattern_timed [72,71,69,67],[0.25] | |
play_pattern_timed [69],[0.5] #b15 | |
play_pattern_timed [71,69,67,66],[0.25] | |
play_pattern_timed [67],[1.5] #b16 | |
end | |
## ==========second section starts here====== | |
## The second section is also repeated | |
2.times do | |
## Start a thread for bars 17-24 of the left hand part | |
in_thread do | |
play_pattern_timed [55],[1.5] #b17 | |
play_pattern_timed [54],[1.5] #b18 | |
play_pattern_timed [52,54,52],[0.5] #b19 | |
play_pattern_timed [57,45],[1,0.5] #b20 | |
play_pattern_timed [57],[1.5] #b21 | |
play_pattern_timed [59,62,61],[0.5] #b22 | |
play_pattern_timed [62,54,57],[0.5] #b23 | |
play_pattern_timed [62,50,60],[0.5] #b24 | |
end | |
## Play bars 17 to 24 of the right hand concurrently with the left | |
## hand thread | |
play_pattern_timed [83],[0.5] #b17 | |
play_pattern_timed [79,81,83,79],[0.25] | |
play_pattern_timed [81],[0.5] #b18 | |
play_pattern_timed [74,76,78,74],[0.25] | |
play_pattern_timed [79],[0.5] #b19 | |
play_pattern_timed [76,78,79,74],[0.25] | |
play_pattern_timed [73,71,73,69],[0.5,0.25,0.25,0.5] #b20 | |
play_pattern_timed [69,71,73,74,76,78],[0.25] #b21 | |
play_pattern_timed [79,78,76],[0.5] #b22 | |
play_pattern_timed [78,69,73],[0.5] #b23 | |
play 74 #b24 | |
sleep 1.5 | |
## Start a new thread for bars 25-32 of the left hand part | |
in_thread do | |
play_pattern_timed [59,62,59],[0.5] #b25 | |
play_pattern_timed [60,64,60],[0.5] #b26 | |
play_pattern_timed [59,57,55],[0.5] #b27 | |
play 62 #b28 | |
sleep 1.5 #includes a rest | |
play_pattern_timed [50,54],[1,0.5] #b29 | |
play_pattern_timed [52,55,54],[0.5] #b30 | |
play_pattern_timed [55,47,50],[0.5] #b31 | |
play_pattern_timed [55,50,43],[0.5] #b32 | |
end | |
## Play bars 25-32 of the right hand part concurrently with the left | |
## hand thread | |
play_pattern_timed [74,67,66,67],[0.5,0.25,0.25,0.5] #b25 | |
play_pattern_timed [76,67,66,67],[0.5,0.25,0.25,0.5] #b26 | |
play_pattern_timed [74,72,71],[0.5] #b27 | |
play_pattern_timed [69,67,66,67,69],[0.25,0.25,0.25,0.25,0.5] #b28 | |
play_pattern_timed [62,64,66,67,69,71],[0.25] #b29 | |
play_pattern_timed [72,71,69],[0.5] #b30 | |
play_pattern_timed [71,74,67,66],[0.25,0.25,0.5,0.5] #b31 | |
play_chord [67,59] #b32 | |
sleep 1.5 | |
end | |
## # Ex 3b: Bach Bell | |
# Bach Minuet in G | |
# | |
# Coded by Robin Newman | |
use_bpm 60 | |
use_synth_defaults release: 0.5, amp: 0.7, cutoff: 90 | |
use_synth :pretty_bell | |
## Each section of the minuet is repeated | |
2.times do | |
## First start a thread for the first 8 bars of the bass left hand part | |
in_thread do | |
play_chord [55,59]#b1 | |
sleep 1 | |
play_pattern_timed [57],[0.5] | |
play_pattern_timed [59],[1.5] #b2 | |
play_pattern_timed [60],[1.5] #b3 | |
play_pattern_timed [59],[1.5] #b4 | |
play_pattern_timed [57],[1.5] #b5 | |
play_pattern_timed [55],[1.5] #b6 | |
play_pattern_timed [62,59,55],[0.5] #b7 | |
play_pattern_timed [62],[0.5] #b8 | |
play_pattern_timed [50,60,59,57],[0.25] | |
end | |
## Play concurrently the first 8 bars of the right hand part | |
play_pattern_timed [74],[0.5]#b1 | |
play_pattern_timed [67,69,71,72],[0.25] | |
play_pattern_timed [74,67,67],[0.5]#b2 | |
play_pattern_timed [76],[0.5]#b3 | |
play_pattern_timed [72,74,76,78],[0.25] | |
play_pattern_timed [79,67,67],[0.5]#b4 | |
play_pattern_timed [72],[0.5] #b5 | |
play_pattern_timed [74,72,71,69],[0.25] | |
play_pattern_timed [71],[0.5] #b6 | |
play_pattern_timed [72,71,69,67],[0.25] | |
play_pattern_timed [66],[0.5] #b7 | |
play_pattern_timed [67,69,71,67],[0.25] | |
play_pattern_timed [71,69],[0.5,1] #b8 | |
## Start a new thread for bars 9-16 of the left hand part | |
in_thread do | |
play_chord [55,59]#b9=b1 | |
sleep 1 | |
play 57 | |
sleep 0.5 | |
play_pattern_timed [55,59,55],[0.5] #b10 | |
play_pattern_timed [60],[1.5] #b11=b3 | |
play_pattern_timed [59,60,59,57,5],[0.5,0.25,0.25,0.25,0.25] #b12=b4] | |
play_pattern_timed [57,54],[1,0.5] #b13 | |
play_pattern_timed [55,59],[1,0.5] #b14 | |
play_pattern_timed [60,62,50],[0.5] #b15 | |
play_pattern_timed [55,43],[1,0.5] #b16 | |
end | |
## Play concurrently bars 9-16 of the right hand part the first six | |
## bars repeat bars 1-6 | |
play_pattern_timed [74],[0.5]#b9 = b1 | |
play_pattern_timed [67,69,71,72],[0.25] | |
play_pattern_timed [74,67,67],[0.5]#b10=b2 | |
play_pattern_timed [76],[0.5]#b11=b3 | |
play_pattern_timed [72,74,76,78],[0.25] | |
play_pattern_timed [79,67,67],[0.5]#b12=b4 | |
play_pattern_timed [72],[0.5] #b13=b5 | |
play_pattern_timed [74,72,71,69],[0.25] | |
play_pattern_timed [71],[0.5] #b14=b6 | |
play_pattern_timed [72,71,69,67],[0.25] | |
play_pattern_timed [69],[0.5] #b15 | |
play_pattern_timed [71,69,67,66],[0.25] | |
play_pattern_timed [67],[1.5] #b16 | |
end | |
## ==========second section starts here====== | |
## The second section is also repeated | |
2.times do | |
## Start a thread for bars 17-24 of the left hand part | |
in_thread do | |
play_pattern_timed [55],[1.5] #b17 | |
play_pattern_timed [54],[1.5] #b18 | |
play_pattern_timed [52,54,52],[0.5] #b19 | |
play_pattern_timed [57,45],[1,0.5] #b20 | |
play_pattern_timed [57],[1.5] #b21 | |
play_pattern_timed [59,62,61],[0.5] #b22 | |
play_pattern_timed [62,54,57],[0.5] #b23 | |
play_pattern_timed [62,50,60],[0.5] #b24 | |
end | |
## Play bars 17 to 24 of the right hand concurrently with the left | |
## hand thread | |
play_pattern_timed [83],[0.5] #b17 | |
play_pattern_timed [79,81,83,79],[0.25] | |
play_pattern_timed [81],[0.5] #b18 | |
play_pattern_timed [74,76,78,74],[0.25] | |
play_pattern_timed [79],[0.5] #b19 | |
play_pattern_timed [76,78,79,74],[0.25] | |
play_pattern_timed [73,71,73,69],[0.5,0.25,0.25,0.5] #b20 | |
play_pattern_timed [69,71,73,74,76,78],[0.25] #b21 | |
play_pattern_timed [79,78,76],[0.5] #b22 | |
play_pattern_timed [78,69,73],[0.5] #b23 | |
play 74 #b24 | |
sleep 1.5 | |
## Start a new thread for bars 25-32 of the left hand part | |
in_thread do | |
play_pattern_timed [59,62,59],[0.5] #b25 | |
play_pattern_timed [60,64,60],[0.5] #b26 | |
play_pattern_timed [59,57,55],[0.5] #b27 | |
play 62 #b28 | |
sleep 1.5 #includes a rest | |
play_pattern_timed [50,54],[1,0.5] #b29 | |
play_pattern_timed [52,55,54],[0.5] #b30 | |
play_pattern_timed [55,47,50],[0.5] #b31 | |
play_pattern_timed [55,50,43],[0.5] #b32 | |
end | |
## Play bars 25-32 of the right hand part concurrently with the left | |
## hand thread | |
play_pattern_timed [74,67,66,67],[0.5,0.25,0.25,0.5] #b25 | |
play_pattern_timed [76,67,66,67],[0.5,0.25,0.25,0.5] #b26 | |
play_pattern_timed [74,72,71],[0.5] #b27 | |
play_pattern_timed [69,67,66,67,69],[0.25,0.25,0.25,0.25,0.5] #b28 | |
play_pattern_timed [62,64,66,67,69,71],[0.25] #b29 | |
play_pattern_timed [72,71,69],[0.5] #b30 | |
play_pattern_timed [71,74,67,66],[0.25,0.25,0.5,0.5] #b31 | |
play_chord [67,59] #b32 | |
sleep 1.5 | |
end | |
# Ex 4: Synthés | |
play 50 | |
sleep 1 | |
use_synth :mod_sine | |
play 50 | |
# Ex 5: Ambient Experiment | |
# Coded by Darin Wilson | |
# | |
# The piece consists of three long loops, each of which | |
# plays one of two randomly selected pitches. Each note | |
# has different attack, release and sleep values, so that | |
# they move in and out of phase with each other. This can | |
# play for quite awhile without repeating itself :) | |
use_synth :hollow | |
with_fx :reverb, mix: 0.7 do | |
live_loop :note1 do | |
play choose([:D4,:E4]), attack: 6, release: 6 | |
sleep 8 | |
end | |
live_loop :note2 do | |
play choose([:Fs4,:G4]), attack: 4, release: 5 | |
sleep 10 | |
end | |
live_loop :note3 do | |
play choose([:A4, :Cs5]), attack: 5, release: 5 | |
sleep 11 | |
end | |
end | |
# Ex 6: Échantillons | |
## # Ex 6a: Sample | |
sample :loop_garzul | |
## # Ex 6b: Amen Break | |
# https://en.wikipedia.org/wiki/Amen_break | |
# https://www.youtube.com/watch?v=5SaFTm2bcac | |
# https://www.youtube.com/watch?v=TMZi25Pq3T8 | |
sample :loop_amen_full | |
## # Ex 6c: Amen | |
sample :loop_amen | |
## # Ex 6d: Loop | |
loop do | |
sample :loop_amen | |
sleep 1 | |
end | |
## # Ex 6e: Loop Duration | |
loop do | |
sample :loop_amen | |
sleep sample_duration(:loop_amen) | |
end | |
## # Ex 6f: Sample BPM | |
loop do | |
use_sample_bpm :loop_amen | |
sample :loop_amen | |
sleep 1 | |
end | |
## # Ex 6g: Live Loop | |
live_loop :amen do | |
use_sample_bpm :loop_amen | |
sample :loop_amen | |
sleep 1 | |
end | |
## # Ex 6h: Cutoff | |
live_loop :amen do | |
use_sample_bpm :loop_amen | |
sample :loop_amen, cutoff: 70 | |
sleep 1 | |
end | |
## # Ex 6i: Rate | |
live_loop :amen do | |
use_sample_bpm :loop_amen | |
sample :loop_amen, cutoff: 70, rate: 1.2 | |
sleep 1 | |
end | |
## # Ex 6j: Rate Duration | |
live_loop :amen do | |
use_sample_bpm :loop_amen | |
sample :loop_amen, cutoff: 70, rate: 1.2 | |
sleep 1/1.2 | |
end | |
## # Ex 6k: Variable | |
live_loop :amen do | |
debit=0.6 | |
use_sample_bpm :loop_amen | |
sample :loop_amen, cutoff: 70, rate: debit | |
sleep 1/debit | |
end | |
## # Ex 6l: Start/Finish | |
live_loop :amen do | |
debit=0.6 | |
use_sample_bpm :loop_amen | |
sample :loop_amen, cutoff: 70, rate: debit, start: 0.1, finish: 0.9 | |
sleep 1/debit | |
end | |
## # Ex 6m: Hit | |
live_loop :amen do | |
sample :loop_amen, start: 0.3, finish: 0.4 | |
sleep 0.3 | |
end | |
## # Ex 6n: Reverb | |
live_loop :amen do | |
with_fx :reverb do | |
sample :loop_amen, start: 0.3, finish: 0.4 | |
sleep 0.3 | |
end | |
end | |
## # Ex 6o: Ixi Techno | |
live_loop :amen do | |
with_fx :ixi_techno do | |
sample :loop_amen, start: 0.3, finish: 0.4 | |
sleep 0.3 | |
end | |
end | |
# Ex 7: Filtered Dnb | |
# Coded by Sam Aaron | |
use_sample_bpm :loop_amen | |
with_fx :rlpf, cutoff: 10, cutoff_slide: 4 do |c| | |
live_loop :dnb do | |
sample :bass_dnb_f, amp: 5 | |
sample :loop_amen, amp: 5 | |
sleep 1 | |
control c, cutoff: rrand(40, 120), cutoff_slide: rrand(1, 4) | |
end | |
end | |
# Ex 8: Time Machine | |
## # Ex 8a: Time Machine | |
# Coded by Sam Aaron | |
use_debug false | |
live_loop :time do | |
synth :tb303, release: 8, note: :e1, cutoff: (range 90, 60, -10).tick | |
sleep 8 | |
end | |
live_loop :machine do | |
sample :loop_garzul, rate: (knit 1, 3, -1, 1).tick | |
sleep 8 | |
end | |
live_loop :vortex, auto_cue: false do | |
use_synth [:pulse, :beep].choose | |
sleep 0.125 / 2 | |
play scale(:e1, :minor_pentatonic).tick, attack: 0.125, release: 0, amp: 2, cutoff: (ring 70, 90, 100, 130).look | |
sleep 0.125 / 2 | |
end | |
live_loop :moon_bass, auto_cue: false do | |
sample :bd_haus, amp: 1.5 | |
sleep 0.5 | |
end | |
## # Ex 8b: Time Machine Stop | |
# Time Machine | |
# Coded by Sam Aaron | |
use_debug false | |
live_loop :time do | |
stop | |
synth :tb303, release: 8, note: :e1, cutoff: (range 90, 60, -10).tick | |
sleep 8 | |
end | |
live_loop :machine do | |
stop | |
sample :loop_garzul, rate: (knit 1, 3, -1, 1).tick | |
sleep 8 | |
end | |
live_loop :vortex, auto_cue: true do | |
stop | |
use_synth [:pulse, :beep].choose | |
sleep 0.125 / 2 | |
play scale(:e1, :minor_pentatonic).tick, attack: 0.125, release: 0, amp: 2, cutoff: (ring 70, 90, 100, 130).look | |
sleep 0.125 / 2 | |
end | |
live_loop :moon_bass, auto_cue: true do | |
# stop | |
sample :bd_haus, amp: 1.5 | |
sleep 0.5 | |
end | |
# Ex 9: Explorer des motifs | |
## # Ex 9a: “Lix Explorer” | |
# Coded by Alex Enkerli, March 20, 2016 | |
def play_lick(lick, root, scale, time) | |
spark lick | |
lick.each{|note| play((degree_to_note note, root, scale)) ; sleep time } | |
end | |
DEGREES = {:i => 0, | |
:ii => 1, | |
:iii => 2, | |
:iv => 3, | |
:v => 4, | |
:vi => 5, | |
:vii => 6, | |
:viii => 7, | |
:ix => 8, | |
:x => 9, | |
:xi => 10, | |
:xii => 11, | |
:r => 999 | |
} | |
def degree_to_note(degree, tonic, scale) | |
local_scale = Scale.new(tonic, scale) | |
if degree.is_a?(Numeric) && degree==0 | |
return 0 | |
elsif idx = DEGREES[degree] | |
index=idx | |
elsif degree.is_a? Numeric | |
index=degree - 1 | |
else | |
raise InvalidDegreeError, "Invalid scale degree #{degree.inspect}, expecting #{DEGREES.keys.join ','} or a number" | |
end | |
local_scale.notes[index] | |
end | |
## # Ex 9b: Sparking Lix | |
lix=(ring | |
[1, 0, 4, 0, 2, 0, 3, 0, 5, 0, 6, 0], | |
# ▄▁▆▁▅▁▅▁▆▁▇▁ | |
[1, 4, 0, 0, 2, 0, 3, 5, 0, 0, 6, 0], | |
# ▄▆▁▁▅▁▅▆▁▁▇▁ | |
[1, 0, 4, 2, 0, 0, 3, 0, 5, 6, 0], | |
# ▄▁▆▅▁▁▅▁▆▇▁ | |
[1, 0, 4, 0, 2, 3, 0, 5, 0, 6, 0], | |
# ▄▁▆▁▅▅▁▆▁▇▁ | |
[1, 4, 2, 3, 5, 6], | |
# ▁▅▃▄▆▇ | |
[1, 0, 4, 2, 0], | |
# ▅▁▇▆▁ | |
[1, 0, 0, 2, 0, 0, 0, 0], | |
# ▆▁▁▇▁▁▁▁ | |
[1, 0, 5, 4, 2, 0, 1, 0, 0], | |
# ▄▁▇▆▅▁▄▁▁ | |
[4, 5, 2, 0, 0, 1, 0, 0], | |
# ▆▇▅▁▁▄▁▁ | |
[1, 0, 4, 0, 0, 2, 5, 2, 0, 0, 0], | |
# ▄▁▆▁▁▅▇▅▁▁▁ | |
[1, 0, 2, 4, 9], | |
# ▅▁▆▇▁ | |
[1, 0, 0, 2, 0, 0, 0, 0], | |
# ▆▁▁▇▁▁▁▁ | |
[1, 0, 5, 4, 2, 0, 1, 0, 0], | |
# ▄▁▇▆▅▁▄▁▁ | |
[1, 0, 4, 2, 5, 3, 0, 0, 0], | |
# ▄▁▆▅▇▆▁▁▁ | |
[1, 2, 4, 0], | |
# ▅▆▇▁ | |
[1, 0, 2, 0, 0, 5, 4, 6, 0, 0, 0], | |
# ▄▁▅▁▁▆▆▇▁▁▁ | |
[4, 0, 1, 0, 0], | |
# ▇▁▅▁▁ | |
[1, 2, 4, 3, 5, 0, 0], | |
# ▄▅▆▆▇▁▁ | |
[1, 4, 2, 3, 5, 0, 0], | |
# ▄▆▅▆▇▁▁ | |
[6, 0, 0, 0], | |
# ▇▁▁▁ | |
) | |
root=52 | |
scale=:minor_pentatonic | |
use_tuning :just, root+1 | |
use_synth :pretty_bell | |
live_loop :lixy do | |
play_lick(lix[tick],root, scale, 0.1) | |
sleep 0.45 | |
end | |
## # Ex 9c Lix Exploration | |
root=52 | |
use_tuning :just, root+1 | |
use_synth :pretty_bell | |
live_loop :licking do | |
a=tick | |
scale=:minor | |
play_lick((ring a-7, :r, 5, 1), root, scale, 0.1) | |
sleep 0.45 | |
end | |
## # Ex 9d: Lix Exploration Stretched | |
root=52 | |
use_tuning :just, root+1 | |
use_synth :pretty_bell | |
live_loop :licking do | |
a=tick | |
scale=:minor | |
play_lick((ring a-7, :r, 5, 1).stretch(3), root, scale, 0.1) | |
sleep 0.45 | |
end | |
## # Ex 9e: Concurrent Lix | |
use_random_seed 10 | |
root=50 | |
use_tuning :just, root+1 | |
lick=(ring 3, :r, 5, 1, :r, 4) | |
scale=([:major, :whole_tone, :minor, :diminished, :lydian, :phrygian]).choose | |
live_loop :licking do | |
use_synth :blade | |
use_synth_defaults release: 0.1 | |
play_lick(lick.stretch(2).shuffle.reflect.drop(4).mirror, root, scale, rrand(0.09, 0.29)) | |
sleep 0.45 | |
end | |
live_loop :beed do | |
sample :bd_haus | |
sleep 1.15 | |
end | |
live_loop :bs do | |
use_synth :fm | |
use_synth_defaults release: 0.3 | |
route=40 | |
play_lick(lick.shuffle.drop(4).mirror, route, scale, 0.6) | |
sleep 1.65 | |
end | |
# Ex 10: Sonic Dreams | |
# rand-seed-ver 32 | |
# | |
# Coded by Sam Aaron | |
# | |
# Video: https://vimeo.com/110416910 | |
use_debug false | |
load_samples [:bd_haus, :elec_blip, :ambi_lunar_land] | |
define :ocean do |num, amp_mul=1| | |
num.times do | |
s = synth [:bnoise, :cnoise, :gnoise].choose, amp: rrand(0.5, 1.5) * amp_mul, attack: rrand(0, 1), sustain: rrand(0, 2), release: rrand(0, 5) + 0.5, cutoff_slide: rrand(0, 5), cutoff: rrand(60, 100), pan: rrand(-1, 1), pan_slide: 1 | |
control s, pan: rrand(-1, 1), cutoff: rrand(60, 110) | |
sleep rrand(0.5, 4) | |
end | |
end | |
define :echoes do |num, tonics, co=100, res=0.9, amp=1| | |
num.times do | |
play chord(tonics.choose, :minor).choose, res: res, cutoff: rrand(co - 20, co + 20), amp: 0.5 * amp, attack: 0, release: rrand(0.5, 1.5), pan: rrand(-0.7, 0.7) | |
sleep [0.25, 0.5, 0.5, 0.5, 1, 1].choose | |
end | |
end | |
define :bd do | |
cue :in_relentless_cycles | |
16.times do | |
sample :bd_haus, amp: 4, cutoff: 120 | |
sleep 0.5 | |
end | |
cue :winding_everywhichway | |
2.times do | |
2.times do | |
sample :bd_haus, amp: 4, cutoff: 120 | |
sleep 0.25 | |
end | |
sample :ambi_lunar_land | |
sleep 0.25 | |
end | |
end | |
define :drums do |level, b_level=1, rand_cf=false| | |
synth :fm, note: :e2, release: 0.1, amp: b_level * 3, cutoff: 130 | |
co = rand_cf ? rrand(110, 130) : 130 | |
a = rand_cf ? rrand(0.3, 0.5) : 0.6 | |
n = rand_cf ? :bnoise : :noise | |
synth :noise, release: 0.05, cutoff: co, res: 0.95, amp: a if level > 0 | |
sample :elec_blip, amp: 2, rate: 2, pan: rrand(-0.8, 0.8) if level > 1 | |
sleep 1 | |
end | |
define :synths do |s_name, co, n=:e2| | |
use_synth s_name | |
use_transpose 0 | |
use_synth_defaults detune: [12,24].choose, amp: 1, pan: lambda{rrand(-1, 1)}, cutoff: co, pulse_width: 0.12, attack: rrand(0.2, 0.5), release: 0.5 , mod_phase: 0.25, mod_invert_wave: 1 | |
play :e1, mod_range: [7, 12].choose | |
sleep 0.125 | |
play :e3, mod_range: [7, 12].choose | |
sleep [0.25, 0.5].choose | |
play n, mod_range: 12 | |
sleep 0.5 | |
play chord(:e2, :minor).choose, mod_range: 12 | |
sleep 0.25 | |
end | |
define :play_synths do | |
with_fx :reverb do |r| | |
with_fx :echo, phase: 0.25 do |e| | |
synths = [:mod_pulse, :mod_saw, :mod_dsaw, :mod_dsaw, :mod_dsaw, :mod_dsaw] | |
cutoffs = [108, 78, 88, 98] | |
synth = synths.rotate!.first | |
4.times do |t| | |
puts shuffle("0" * (30 - t) + ("1" * t)) unless t == 0 | |
co = cutoffs.rotate!.first + (t * 2) | |
7.times do | |
n = chord([:e2, :e3, :e4, :e5][t], :minor).choose | |
synths(synth, co, n) | |
end | |
sleep 2 | |
end | |
sleep 1 | |
cue :within | |
end | |
end | |
end | |
define :binary_celebration do |n=1, st=1| | |
in_thread do | |
n.times do | |
puts (0..30).map{|_| ["0", "1"].choose}.join | |
sleep st | |
end | |
end | |
end | |
puts 'Introduction' | |
puts 'The Curved Ebb of Carpentry' | |
sleep 2 | |
cue :oceans | |
at [7, 12], [:crash, :within_oceans] do |m| | |
cue m | |
end | |
uncomment do | |
use_random_seed 1000 | |
with_bpm 45 do | |
with_fx :reverb do | |
with_fx(:echo, delay: 0.5, decay: 4) do | |
in_thread do | |
use_random_seed 2 | |
ocean 5 | |
ocean 1, 0.5 | |
ocean 1, 0.25 | |
end | |
sleep 10 | |
use_random_seed 1200 | |
echoes(5, [:b1, :b2, :e1, :e2, :b3, :e3]) | |
cue :a_distant_object | |
echoes(5, [:b1, :e1, :e2, :e3]) | |
cue :breathes_time | |
in_thread do | |
echoes(5, [:e1, :e2, :e3]) | |
end | |
use_synth :tb303 | |
echoes(1, [:e1, :e2, :e3], 60, 0.9, 0.5) | |
echoes(1, [:e1, :e2, :e3], 62) | |
echoes(1, [:e1, :e2, :e3], 64, 0.97) | |
echoes(1, [:e1, :e2, :e3], 66) | |
echoes(1, [:e1, :e2, :e3], 68) | |
cue :liminality_holds_fast | |
echoes(4, [:b1, :e1, :e2, :b3, :e3], 80) | |
echoes(1, [:b1, :b2, :e1, :e2, :b3, :e3], 85, 0.98) | |
cue :within_reach | |
echoes(5, [:e1, :b2], 90) | |
cue :as_it_unfolds | |
in_thread do | |
echoes(5, [:e1], 90) | |
end | |
end | |
end | |
end | |
end | |
in_thread(name: :bassdrums) do | |
use_random_seed 0 | |
sleep 22 | |
3.times do | |
bd | |
end | |
sleep 28 | |
live_loop :bd do | |
bd | |
end | |
end | |
in_thread(name: :drums) do | |
use_random_seed 0 | |
level = -1 | |
with_fx :echo do |e| | |
sleep 2 | |
drums -1, 0.1 | |
drums -1, 0.2 | |
drums -1, 0.4 | |
drums -1, 0.7 | |
puts "Part 2" | |
puts "Inside the Machine" | |
3.times do | |
8.times do | |
drums level, 0.8 | |
end | |
6.times do | |
drums(level) | |
end | |
sleep 1 | |
level += 1 | |
end | |
sleep 4 | |
cue :dreams | |
8.times do | |
drums 1, 1, true | |
end | |
10.times do | |
m = choose [shuffle(:within_dreams), :within_dreams, :dreams_within] | |
cue m | |
drums 2, 1, true | |
end | |
6.times do | |
m = choose [shuffle("within") + "_dreams", :within_dreams.shuffle, "dreams_" + shuffle("within")] | |
cue m | |
drums 2 | |
end | |
live_loop :drums do | |
8.times do |i| | |
drums 1 | |
end | |
16.times do |i| | |
cue " " * rand_i(32) | |
at 1 do | |
cue " " * i | |
end | |
drums 2 | |
end | |
end | |
end | |
end | |
in_thread name: :synths do | |
use_random_seed 0 | |
sleep 12 | |
cue :the_flow_of_logic | |
play_synths | |
end | |
in_thread do | |
use_random_seed 0 | |
sync :within | |
puts "Part 3" | |
puts "Reality A" | |
sleep 12 | |
use_synth_defaults phase: 0.5, res: 0.5, cutoff: 80, release: 3.3, wave: 1 | |
2.times do | |
[80, 90, 100, 110].each do |cf| | |
use_merged_synth_defaults cutoff: cf | |
puts "1" * 30 | |
synth :zawa, note: :e2, phase: 0.25 | |
synth :zawa, note: :a1 | |
sleep 3 | |
end | |
4.times do |t| | |
binary_celebration(6, 0.5) | |
synth :zawa, note: :e2, phase: 0.25, res: rrand(0.8, 0.9), cutoff: [100, 105, 110, 115][t] | |
sleep 3 | |
end | |
end | |
puts 'Part n' | |
puts 'The Observer becomes the Observed' | |
# Your turn... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment