Skip to content

Instantly share code, notes, and snippets.

@ddimtirov
Created August 31, 2021 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddimtirov/6dd7f3147462f713daf249ef4222c7aa to your computer and use it in GitHub Desktop.
Save ddimtirov/6dd7f3147462f713daf249ef4222c7aa to your computer and use it in GitHub Desktop.
Sonic PI Aug 2021
use_bpm 480
define :roll do |trigs, offset=0, duration=1, &block|
return sleep(duration) if trigs==0
roll_tick = duration.to_f / trigs
sleep roll_tick * offset if offset>0 && offset<1
trigs.times do
block.call
sleep roll_tick
end
end
live_loop :bd do
sync "/live_loop/hh"
sample :bd_haus
sleep 2
sample :drum_snare_soft
case dice(5)
when 1 ; roll 1, 0.5, 2 do sample :bd_haus end
when 2..3; roll 2, 0, 2 do sample :bd_haus end
else ; roll 1, 0, 2 do sample :bd_haus end
end
end
live_loop :hh do
sample :drum_cymbal_closed
sleep 1
roll choose([0, 0, 0, 1, 1, 2, 2, 4, 3]) do
sample :drum_cymbal_closed
end
end
live_loop :midi_note do
use_synth :prophet
note, velocity = sync "/midi:nanopad2_0:1/note_on"
set :midi_note, note
play_chord chord(note, :minor), attack: 0.1, decay: 0.9, sustain: 0.5, release: 10
end
live_loop :midi_control do
param_mapping = { 1 => :midi_x, 2 => :midi_y }
param, val = sync "/midi:nanopad2_0:1/control_change"
set param_mapping[param], val
end
set :midi_note, :C - 12
set :midi_x, 70
set :midi_y, 90
bass_scales=(ring :minor_pentatonic, :major_pentatonic, :minor, :hex_sus)
bass_scale=bass_scales[0]
live_loop :bass do
use_synth :hoover
use_bpm 480
sync "/live_loop/hh"
use_transpose -12
case dice(10)
when 1; bass_scale=bass_scales.tick
when 2; bass_scale=choose(scale_names)
end
case dice(6)
when 0; use_transpose +5
when 1; use_transpose -12
when 2; use_transpose -7
when 3; use_transpose 0
when 4; use_synth :growl
end
rhytm=[1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2]
3.times do
if one_in(3)
merge_idx = dice(rhytm.length-1)
rhytm[merge_idx]=rhytm[merge_idx+1]
rhytm[merge_idx+1]=nil
end
end
rhytm.select! { |note| note }
tune=scale(bass_scale).repeat(3).shuffle().take(rhytm.length) #.sort()
play_pattern_timed tune, rhytm.ring, decay: 0.5, sustain: 0.3, pitch: get[:midi_note],
cutoff: get[:midi_x], res: get[:midi_y]/127.0
end
drone = (ring :C3, :G3)
live_loop :background do
use_synth :dark_ambience
sync "/live_loop/hh"
b = play drone.tick, release: 3, amp: 8, ring: choose([0.2, 0.3, 0.5]),
detune1: choose([10, 12, 25]), detune1_slide: 1,
detune2: choose([10, 25, 25, 30]), detune2_slide: 1
sleep choose([1, 2])
control b, ring: 0.2
if one_in(10)
sleep 5
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment