Last active
February 1, 2025 21:22
-
-
Save MAKIO135/ccbb56ca7d4c6f9545fe9af326cd1df3 to your computer and use it in GitHub Desktop.
SonicPi In C
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
# 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 5 synths and 1 sample, 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 = 5 | |
players = [] | |
nb_players.times do | |
players.push(0) | |
end | |
# Phrases transcribed from 'In C' by Terry Riley | |
pulse_phrase = [[72,30,48],[72,15,48]] | |
live_loop :pulse do | |
pulse_phrase.each do |d| | |
sample :drum_cymbal_closed, amp: d[1]/100.0, release: d[2]/bpm | |
sleep d[2]/bpm | |
end | |
end | |
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 | |
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 | |
with_fx :pan, amp: 1, pan: 0 do | |
play_player(0) | |
end | |
end | |
live_loop :player1 do | |
use_synth :pretty_bell | |
with_fx :pan, amp: 1, pan: -0.3 do | |
play_player(1) | |
end | |
end | |
live_loop :player2 do | |
use_synth :pluck | |
with_fx :pan, amp: 1, pan: 0.3 do | |
play_player(2) | |
end | |
end | |
live_loop :player3 do | |
use_synth :kalimba | |
with_fx :pan, amp: 1, pan: 0.7 do | |
play_player(3) | |
end | |
end | |
live_loop :player4 do | |
use_synth :fm | |
with_fx :pan, amp: 0.5, pan: -0.8 do | |
play_player(4) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment