Answer to a query on sonic pi github site

An “issue” has just been posted Play and Sleep Function · Discussion #2616 · sonic-pi-net/sonic-pi · GitHub
Rather than answer it there a possible solution is below.

use_bpm 120
use_synth :pulse
define :pl do |nl,dl|
  nl.length.times do
    play nl.tick,sustain: 0.9*dl.look,release: 0.1*dl.look
    sleep dl.look
  end
end


notes=[:gs5,:gs5,:gs5,:gs5,:gs5,:gs5,
       :fs5,:fs5,:fs5,:b4,:cs5,:ds5,
       :ds5,:ds5,:ds5,:ds5,
       :cs5,:cs5,:cs5,:ds5,:fs5,:gs5]
durations = [1,1,0.5,0.5,0.5,0.5,
             0.5,1,1,0.5,0.5,1.5,
             1,1,0.5,0.5,
             0.5,1,1,0.5,0.5,0.5]

notes2=[[:e3,:fs3,:b3],[:e3,:fs3,:b3],[:e3,:fs3,:b3],
        [:e3,:fs3,:b3],[:e3,:fs3,:b3],[:e3,:fs3,:b3],
        [:ds3,:fs3,:b3],[:ds3,:fs3,:b3],[:ds3,:fs3,:b3],
        [:fs3,:b3,:cs4],[:fs3,:b3,:cs4],[:fs3,:b3,:cs4]]
durations2=[1.5,1.5,1,
            1.5,1.5,1,
            1.5,1.5,1,
            1.5,1.5,1]
in_thread do
  pl notes,durations
end
in_thread do
  pl notes2,durations2
end
1 Like

Thanks for your answer Robin!