Hi Pilots
I am trying to find ‘best’ practice approaches to live coding/sequencing rhythms, and I have found that using the spread function, and the good old pattern.look method really useful, and immediate. Having to work out each duration/sleep value on-the-fly for each note is a bit time consuming for live coding specifically. So, consider the rhythm “x - - x - - x -” in 4/4 (2 dotted quarter notes and one quarter note). I have tried using spread and pattern.look, without success. How would YOU approach this? The first loop uses the appropriate pitch/sleep values, but is it possible with spread or a .look please?
#trying for a 3 note syncopated maj arpeggio
notes = chord(:c3, :major)
use_synth :bass_foundation
live_loop :riff1 do
#stop
tick
play chord(:c3, :maj).look #if spread(3,8).look #doesn't work as expected
sleep knit(0.75,2, 0.5,1).look
end
ptn = "x--x--x-"
live_loop :riff2 do
stop
tick
play chord(:c3, :maj).look if ptn.look == "x"
sleep 0.25
end
/
rhythms are easier and quicker to live code via ptn.look and spread;
rather than working out each duration for sleep; does that make me lazy? :D
/
PD-Pi
Solution: The code needs a separate “tick(:a)” on the chord
ptn = "x--x--x-"
live_loop :riff2 do
# stop
tick
play chord(:c3, :maj).tick(:a) if ptn.look == "x"
sleep 0.25
end
1 Like
Separate ticks, of course! Thank you <3
1 Like
Other ways of coding the rhythm
#ptn = "x--x--x-"
live_loop :riff2 do
# stop
tick
#play chord(:c3, :maj).tick(:a) if ptn.look == "x"
play chord(:c3, :maj).tick(:a) if (spread(1,3)*2+spread(1,2)).look
# play chord(:c3, :maj).tick(:a) if bools(1,0,0,1,0,0,1,0).look
sleep 0.25
end
#ptn = "x--x--x-"
live_loop :riff2 do
# stop
tick
#play chord(:c3, :maj).tick(:a) if ptn.look == "x"
#play chord(:c3, :maj).tick(:a) if (spread(1,3)*2+spread(1,2)).look
play chord(:c3, :maj).tick(:a) if bools(1,0,0,1,0,0,1,0).look
sleep 0.25
end
define :s do |a,b|
spread(a,b)
end
live_loop :riff2 do
tick
play chord(:c3, :maj).tick(:a) if (s(1,3)*2+s(1,2)).look
sleep 0.25
end
Started to play a bit with this 
class SonicPi::Core::RingVector # r() only works on s() - doesnt work on an array like [].r()
def r(n)
self.rotate(n)
end
end
define :s do |a,b|
spread(a,b)
end
live_loop :riff2 do
tick
play chord(:c3, :maj).tick(:a) if (s(1,3)*2+s(1,2)).look
play chord(:c3, :maj).tick(:b)+12 if (s(1,3)*2+s(1,2)).r(1).look
sleep 0.25
end
1 Like
I knew the Master of the spread function would offer several solutions! I personally prefer spread(1,3)*2 + (1,2), it offers more immediate ‘flexibility’
1 Like
Why not just use spread(3,8)? It outputs this:
(ring true, false, false, true, false, false, true, false)
1 Like
It offers a little more flexibility over the distribution, one spread function can only have one outcome - unless we rotate, shuffle, push etc. For example, compare:
puts spread(6,8)
sleep 1
puts spread(4,6) + spread(2,2)
PD-Pi