Can I 'tick' a 'with_fx' that is outside of a live_loop?

I often code my live_loop so the FX are inside of the live_loop like this:

# AUTOMATION
lfo0 = (line 70, 100, inclusive: true, steps: 16).mirror

live_loop :bass do
  puts tick
  with_fx :lpf, cutoff: lfo0.look do
    use_synth :chipbass
    play (octs :e1, 3).look
  end
  sleep 0.5
end

Note: This allows me to keep incrementing the ‘tick’ and imitate an LFO-like effect on FX.

But I’ve recently heard that ‘with_fx’ should not be put inside the live_loop as it creates multiple instances of it and is not efficient. I do notice slowdowns, so I would like to understand if there is a better way to do this…

So, how can I rewrite this to have the ‘with_fx’ on the outside of the live_loop while still maintaining the ticking LFO effect? Is there a way to create a global tick loop method that can be applied to all my other live_loops?

I tried this but it doesn’t work because the tick only gets called once. But if I put it in it’s own live_loop it will become local to that loop and also ineffective.

# AUTOMATION
lfo0 = (line 70, 100, inclusive: true, steps: 16).mirror

puts tick
with_fx :lpf, cutoff: lfo0.look do
  live_loop :bass do
    use_synth :chipbass
    play (octs :e1, 3)
    sleep 0.5
  end
end
1 Like
lfo0 = (line 70, 100, inclusive: true, steps: 16).mirror

with_fx :lpf do |lpf|
  live_loop :bass do
    control lpf, cutoff: lfo0.look
    puts tick
    
    use_synth :chipbass
    play (octs :e1, 3).look
    
    sleep 0.5
  end
  
end

would also work as:


lfo0 = (line 70, 100, inclusive: true, steps: 16).mirror

with_fx :lpf do |lpf|
  live_loop :bass do
    control lpf, cutoff: lfo0.tick
    puts look
    
    use_synth :chipbass
    play (octs :e1, 3).look
    
    sleep 0.5
  end
  
end

I think it’s also better to put your FX outside the loop - that way your computer won’t re-load the whole effect with every iteration (from what I’ve read).

:slight_smile:

Also – your question is somewhat relevant to what I’m messing around with (which I mentioned in a comment to you elsewhere just a moment ago):

use_debug false

#varz
n=knit(:e1,8, :gs1,4, :a1,4)

live_loop :lvlset do
  clvl = [40,50,60,70,80,90,100].choose
  set :c, clvl
  puts clvl
  sleep 4
end

#roxtedy
live_loop :bdwon do
  sample :bd_tek
  sleep knit(0.5,2, 1,3).tick
end

live_loop :beedeetoo, sync: :bdwon do
  sample :bd_haus, cutoff: 95
  sleep knit(1,2, 0.75,1, 0.25,5).tick
end

sleep 8

#movers, shakers.
with_fx :reverb do
  with_fx :rlpf do |f|
    with_fx :eq, high: -0.75 do
      
      live_loop :octobass do
        
        6.times do
          play ring(:e1, :gs1, :a1).look,
            sustain: 2, pan: -1
          4.times do
            use_synth :chipbass
            play octs(n.tick,3).choose,
              pan: [1,-1].look
            
          sleep 0.25 end
        end
        control f, cutoff: get[:c],
          cutoff_slide: 5
        cue :dingy
    end end
end end

with_fx :distortion do |d|
  with_fx :rhpf do |hpf|
    with_fx :ping_pong do
      
      live_loop :dingy do
        
        wait :octobass
        
        9.times do
          use_synth knit(:pretty_bell,33, :dull_bell,14).tick
          use_synth_defaults amp: 0.5
          
          control d, distort: dice(9)*0.1,
            distort_slide: 0.5
          play [:e4,:cs3].choose, amp: 0.2,
            pan: [-1,1].look
          
          density 1+look%4 do
            play octs(:cs1,5).pick(2)
            sleep 0.2
            play octs(n.look,3).pick(3)
          sleep [0.3,0.45,0.8].choose end
        end
        
        sleep 12
        control hpf, cutoff: get[:c]+dice(15), cutoff_slide: 6
        
      end
  end end
end

with_fx :tremolo do
  with_fx :slicer, phase: 0.125 do |sl|
    with_fx :echo, mix: 0.25 do
      sleep 6
      
      live_loop :ch, sync: :beedeetoo do
        control sl, wave: [1,2,3,0].look
        use_synth knit(:prophet,3,
                       :growl,3,
                       :organ_tonewheel,3,
                       :blade, 3).shuffle.tick
        
        use_synth_defaults release: 4, decay: 12, amp: 0.6
        
        3.times do
          control sl, phase: get[:c]*0.0125, phase_slide: 5
          play scale(:e1, :phrygian, num_octaves: 5).pick(4, skip: 2)
        sleep 6 end
        
        sleep 9
      end
      
end end end

Notice in here that the first live loop is actually just iterating through a line of cutoff levels, and I use the global variable for a slicer as well. The way the math works out, as the cutoff drops, the slicer gets spaced further apart. When the cutoff is high, the slices are smaller, sorta reflecting the frequency of the other waves. Due to the staggered timing of the gets, sometimes the change in chords’ slicephase is leading another instrument’s filter, and sometimes following. It’s a fun effect, and I can actually just let this loop drone on for quite a while without starting to get annoyed, haha.

1 Like

Oh nice, that’s a smart way to do it. I’ll start doing it that way going forward.

Also I like that code you sent over, especially how it gives off an accelerando/decelerando-like effect.

thanks! I wanna get it tuned a little better and experiment with some other scales, probably narrow down the chord synths a bit too.

Also – adding accelerando/decelerando to my music vocab, haha.

also shoutout to mr bomb & this video for the start on this concept

1 Like

Yeah Mister Bomb has been an invaluable resource. That’s the exact video I used as a starting point to kickstart this bit of experimentation. I like how everyone in the community is exploring very different aspects of Sonic Pi and teaching their findings. It feels to me that if an in_thread member makes progress, it benefits me, and in return I feel an obligation to share my own work so that others may benefit from me in sort of a positive cycle. It’s something I haven’t experienced in any other music community and it’s great.

1 Like