How to code this

Hi @nlb,

well, if you want a construction which somehow matches the timeline in Ableton I would think you could go with something like this and skip the live_loops alltogether:

use_bpm 120

define :drums do
  in_thread do
    sample :drum_bass_hard
    sleep 1
    sample :drum_snare_soft
    sleep 1
    sample :drum_bass_hard
    sleep 0.5
    sample :drum_bass_hard
    sleep 0.5
    sample :drum_snare_soft
    sleep 1
  end
end

define :hats do
  in_thread do
    6.times do
      sample :drum_cymbal_soft, amp:0.5 , rate: 1, compress:1
      sleep 0.5
    end
    sample :drum_cymbal_open, amp:0.5 , rate: 2
    sleep 0.5
    sample :drum_cymbal_open, amp:0.5 , rate: 2
    sleep 0.5
  end
end

define :bass do
  in_thread do
    use_synth :saw
    use_synth_defaults attack: 0.1, delay: 0.1, sustain: 0.1, cutoff: 90, amp: 0.5
    play_pattern_timed [:c2, :c3, :e3, :e3],[1,1,1,1]
  end
end

define :riff do
  riff_01 = (ring
             :c2,:e3,:e2,:e2,:r,:c3,:r,:c3,
             :c2,:e3,:e2,:e2,:r,:r,:g3,:f3)
  in_thread do
    use_synth :pluck
    use_synth_defaults amp: 0.8, attack_level: 0.5, sustain: 0.8, release: 0.25, cutoff: 80
    play_pattern_timed riff_01, 0.5
  end
end

# play the tune
#loop do # of course, you could loop this...
  bass
  drums
  sleep 4
  
  bass
  sleep 4
  
  bass
  drums
  riff
  sleep 4
  
  bass
  drums
  sleep 4
#end

For the purpose of teaching (thought I do teach students and not (yet) children) I think the in_thread construct much more resembles something which comes close to tracks and a timeline as you can find these in contemporary DAWs (and also Ableton). I do visualise live_loops more like a bunch of rotating circles (rather than tracks following a timeline while playing), which might be interconnected by cue/sync.

Nevertheless I see the challange of being able to control musical events while working with live_loops and I am still experimenting and looking for different ways to do that (e. g. with fading independant of the runtime of a loop.). I do think similar as @Eli : you will have to figure out what works best for you.

[spoken aside] I don’t know Ableton enougth to go into detail but it might be quite difficult to try and apply the concept of live_loops to it. So I think we do have a different paradigm here and I might be tempted to think it is a bit like comparing apples and pears, when you comparing Sonic Pi with Ableton. Neverthess I do admit both are fruits and you can eat them… :wink: But seriously: I do e. g. encourage my students to compare what they know (which often is Ableton) with Sonic Pi because being clear about the differences - I think - also might give you new insights about what music is, how it works and how it can be done in different ways. But that’s more of a philosophical than a practical question whith respect to your original question.[/spoken aside]