# 231123 0027 exploring define with spread
# Saved 231123 0027
# https://youtu.be/USOvqXtbcnA
# https://in-thread.sonic-pi.net/t/exploring-define-with-spread-sonicpi/8387
set_volume! 2
use_bpm 180
define :myspread do |n1,n2,a,b,c|
play n1 if spread(a,b).look
play n2 if spread(a,b+c).look
end
#define :myspreadsample do |n1,n2,a,b,c| # not used
#sample n1, amp: 0.7, cutoff: 86 if spread(a,b).look
#sample n2 if spread(a,b+c).look
#end
live_loop :a1 do
tick
/ bass /
kn = 16
use_synth_defaults release: [0.15,0.25,0.35].choose, cutoff: [70,80,90,100].look+line(-40,20,steps: 128).look
use_synth :saw
n3 = :c2
myspread(n3,n3+24,5,8,1)
/ kick /
sample :bd_fat, amp: 1 if spread(1,16).look
sample :bd_fat, amp: 2.5 if spread(1,16).rotate(2).look
/ chords /
with_fx :level, amp: 0.75 do
with_fx :reverb,room: 0.4 do
with_fx :ping_pong, mix: [0,1].choose do
sample :sn_dolf,amp: 1, finish: 0.045 if spread([1,2,1,3].choose,8).rotate(4).look and one_in(2)
use_synth :saw
mel =knit(0,16,1,16,2,16,3,16,4,16,1,16).look
note = :c5-0
case mel
when 0
when 1
play [note]
when 2
play [note,note+7]
when 3
play [note,note+3]
when 4
play [note-2,note+5]
end
end
end
end
sleep 0.5
end
This is pretty sick
I tried to run but I get timing errors on windows, even with loop delay
and set_sched_ahead_time! 5
Tried with a 15 second delay… and it doesn’t fall over as quick, but I hear it struggling a bit… then it dies.
Will ASIO help? Any other workarounds? Are you using a powerful machine ? Mac/linux?
I found advice from Ethan on timing errors here and tried commenting out the reverb and seems okay on first run (sched_ahead and loop delay 30!)
I then took a punt and removed the delays, and broke my sp, restart required!
reattempt post restart, for me I seem to need a delay of ~10, but think even then I’m merely prolonging the inevitable…
previously I seemed to fix my own timing issues by reducing output (puts) , but this doesn’t appear to be an option here!
I have a decent machine, but the process is only using ~1% of one core, this should run fine on most computers.
What does the Task Manager say about CPU & Memory?
To improve performance, I would probably move the reverb outside the loop. At 180BPM this is creating six new delays and reverbs per second (might lead to a memory problem).