This code brings in an external piano sample loop and restructures it into something glitch-tastic!
Since this code relies on an external sample, you will either need to supply a loop-able piano sample of your own, or grab the exact one I used for free over here. You will also have to change the sample’s path directory in the code to match the location in which your sample is found on your computer.
Check on Sonic Pi Scripts for more jumping-off points.
### Author: Shea Kennedy (Doffu)
### About: Takes in a piano sample loop and restructures it into something glitch-tastic.
use_bpm 88
use_random_seed 8
#LOAD IN SAMPLE LIBRARIES
#Change to your own sample folder path:
pianoSample = "C:/Users/sheam/Desktop/Sonic Pi/Samples/looperman-l-0672759-0327647-new-piano-vibes-88bpm.wav"
#LEVELS
#Set these to 0 if I want to mute a track and to 1 if you want it to play. Can also set in between for volume control.
inst0_lvl = 1
inst1_lvl = 1
inst2_lvl = 1
live_loop :pianoEcho do
if(inst0_lvl == 1)
with_fx :level, amp: inst0_lvl do
puts tick
with_fx :echo, mix: 0.8 do
sample pianoSample, 0, rate: (ring 8, 16).look, onset: (ring 3, 2, 2, 3, 7, 5, 3, 2).look, release: 0.01 if (spread 8, 16).look
end
end
end
sleep 1
end
live_loop :piano do
if(inst1_lvl == 1)
with_fx :level, amp: choose([inst1_lvl]) do
with_fx :bitcrusher do
puts tick
sample pianoSample, 0, rate: 0.5, beat_stretch: 16
end
end
end
sleep 32
end
live_loop :pianoGlitch do
puts tick
if(inst2_lvl == 1)
with_fx :level, amp: choose([0, inst2_lvl, inst2_lvl, inst2_lvl]) do
sample pianoSample, 0, rate: choose([2,4,8]), onset: (ring 1,0,0,2,6,4,5, 1,0,0,7,7,8,2,0).look, sustain: 0, release: 0.20 if (spread 12, 16).look
end
end
sleep 0.25
end