Skip to content

Instantly share code, notes, and snippets.

@MAKIO135
Created June 25, 2019 20:08
Show Gist options
  • Save MAKIO135/ccbb56ca7d4c6f9545fe9af326cd1df3 to your computer and use it in GitHub Desktop.
Save MAKIO135/ccbb56ca7d4c6f9545fe9af326cd1df3 to your computer and use it in GitHub Desktop.
SonicPi In C
# Discovered In C a few years ago thanks to Tero Parviainen (@teropa) 's great article: Terry Riley's "In C", A Journey Through a Musical Possibility Space
# http://teropa.info/blog/2017/01/23/terry-rileys-in-c.html
# Here is a Sonic Pi version with 3 synths and 1 smaple, based on Jim Bumgardner's Chuck implementation.
# http://electro-music.com/forum/viewtopic.php?t=14237&sid=dbb3ada88a20169e90ee4ce45d79f10
# A generated result can be heard here: https://soundcloud.com/makio135/sonic-pi-in-c
use_debug false
bpm = 100.0
use_bpm bpm
use_random_seed 10300
nb_players = 3
players = []
nb_players.times do
players.push(50)
end
# Phrases transcribed from 'In C' by Terry Riley
pulse_phrase = [[72,50,48],[72,50,48],[72,50,48],[72,50,48],[72,50,48],[72,50,48],[72,50,48],[72,50,48]]
phrases = [
[[0,63,96]],
[[60,63,6],[64,63,90],[60,63,6],[64,63,90],[60,63,6],[64,63,90]],
[[60,63,6],[64,63,42],[65,63,48],[64,63,96]],
[[0,63,48],[64,63,48],[65,63,48],[64,63,48]],
[[0,63,48],[64,63,48],[65,63,48],[67,63,48]],
[[64,63,48],[65,63,48],[67,63,48],[0,63,48]],
[[72,63,768]],
[[0,63,336],[60,63,24],[60,63,24],[60,63,48],[0,63,432]],
[[67,63,576],[65,63,768]],
[[71,63,24],[67,63,24],[0,63,336]],
[[71,48,24],[67,48,24]],
[[65,48,24],[67,48,24],[71,48,24],[67,48,24],[71,48,24],[67,48,24]],
[[65,63,48],[67,63,48],[71,63,384],[72,63,96]],
[[71,63,24],[67,63,72],[67,63,24],[65,63,24],[67,63,48],[0,63,72],[67,63,312]],
[[72,63,384],[71,63,384],[67,63,384],[66,63,384]],
[[67,63,24],[0,63,360]],
[[67,48,24],[71,48,24],[72,48,24],[71,48,24]],
[[71,48,24],[72,48,24],[71,48,24],[72,48,24],[71,48,24],[0,48,24]],
[[64,48,24],[66,48,24],[64,48,24],[66,48,24],[64,48,72],[64,48,24]],
[[0,63,144],[67,63,144]],
[[64,48,24],[66,48,24],[64,48,24],[66,48,24],[55,48,72],[64,48,24],[66,48,24],[64,48,24],[66,48,24],[64,48,24]],
[[66,63,288]],
[[64,63,144],[64,63,144],[64,63,144],[64,63,144],[64,63,144],[66,63,144],[67,63,144],[69,63,144],[71,63,48]],
[[64,63,48],[66,63,144],[66,63,144],[66,63,144],[66,63,144],[66,63,144],[67,63,144],[69,63,144],[71,63,96]],
[[64,63,48],[66,63,48],[67,63,144],[67,63,144],[67,63,144],[67,63,144],[67,63,144],[69,63,144],[71,63,48]],
[[64,63,48],[66,63,48],[67,63,48],[69,63,144],[69,63,144],[69,63,144],[69,63,144],[69,63,144],[71,63,144]],
[[64,63,48],[66,63,48],[67,63,48],[69,63,48],[71,63,144],[71,63,144],[71,63,144],[71,63,144],[71,63,144]],
[[64,48,24],[66,48,24],[64,48,24],[66,48,24],[67,48,48],[64,48,24],[67,48,24],[66,48,24],[64,48,24],[66,48,24],[64,48,24]],
[[64,48,24],[66,48,24],[64,48,24],[66,48,24],[64,48,72],[64,48,24]],
[[64,63,288],[67,63,288],[72,63,288]],
[[72,63,576]],
[[67,48,24],[65,48,24],[67,48,24],[71,48,24],[67,48,24],[71,48,24]],
[[65,48,24],[67,48,24],[65,48,24],[67,48,24],[71,48,24],[65,48,312],[67,48,144]],
[[67,63,24],[65,63,24],[0,63,48]],
[[67,48,24],[65,48,24]],
[[65,48,24],[67,48,24],[71,48,24],[67,48,24],[71,48,24],[67,48,24],[71,48,24],[67,48,24],[71,48,24],[67,48,24],[0,48,336],[70,63,96],[79,63,288],[81,63,48],[79,63,96],[83,63,48],[81,63,144],[79,63,48],[76,63,288],[79,63,48],[78,63,336],[0,63,240],[76,63,240],[77,63,576]],
[[65,48,24],[67,48,24],[71,48,24],[67,48,24],[71,48,24],[67,48,24]],
[[65,48,24],[67,48,24]],
[[65,48,24],[67,48,24],[71,48,24]],
[[71,48,24],[67,48,24],[65,48,24],[67,48,24],[71,48,24],[72,48,24]],
[[71,48,24],[65,48,24]],
[[71,48,24],[67,48,24]],
[[72,63,384],[71,63,384],[69,63,384],[72,63,384]],
[[65,48,96],[64,48,96],[65,48,96],[64,48,96],[64,48,48],[64,48,48],[64,48,48],[65,48,24],[64,48,24]],
[[77,63,48],[76,63,96],[76,63,48],[72,63,96]],
[[74,63,96],[74,63,96],[67,63,96]],
[[67,48,24],[74,48,24],[76,48,24],[74,48,24],[0,48,48],[67,48,48],[0,48,48],[67,48,48],[0,48,48],[67,48,48],[67,48,24],[74,48,24],[76,48,24],[74,48,24]],
[[74,63,24],[76,63,24],[74,63,48]],
[[67,63,576],[67,63,384],[65,63,480]],
[[65,48,24],[67,48,24],[70,48,24],[67,48,24],[70,48,24],[67,48,24]],
[[65,48,24],[67,48,24]],
[[65,48,24],[67,48,24],[70,48,24]],
[[67,48,24],[70,48,24]],
[[70,48,24],[67,48,24]]
]
define :play_phrase do |p, n|
p.each do |d|
if d[0] != 0
play d[0], amp: d[1]/100.0, release: d[2]/bpm
# can also be played with midi instruments:
# midi d[0], amp: d[1]/100.0, sustain: d[2]/bpm, channel: n
end
sleep d[2]/bpm
end
end
live_loop :pulse do
pulse_phrase.each do |d|
if d[0] != 0
sample :drum_cymbal_closed, amp: d[1]/100.0, release: d[2]/bpm
end
sleep d[2]/bpm
end
end
define :play_player do |n|
o = players[n]
if o < phrases.length - 1
play_phrase(phrases[o], n)
if one_in(6)
can_update = true
for q in players
if o - q >= 3 # players can not move further than 3 patterns from the least advanced
can_update = false
end
end
if can_update
players[n] = o + 1
print players
end
end
else
sleep 1
end
end
live_loop :player0 do
use_synth :piano
play_player(0)
end
live_loop :player1 do
use_synth :pretty_bell
play_player(1)
end
live_loop :player2 do
use_synth :pluck
play_player(2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment