[solved] Controlling parameters from inside another live_loop

Let’s say I have one live_loop that is playing a sample continuously:

live_loop :looper do
  sample :loop_amen
  sleep sample_duration :loop_amen
end

And I have another that is updating a variable via an LFO-like behaviour. In this case, a value between -1 and 1 for panning:

live_loop :lfo do
  pan_value = (range -1, 1, 0.1).mirror.tick
  sleep 0.1
end

How can I use the pan_value variable to change the pan: parameter of the sample in real-time? Like using the control command, for example.

I have tried using set: and get: to store and update the varible, but then the looper will only grab the current value whenever the live_loop restarts.

It would be okay if the :lfo live_loop lives inside the :looper live_loop, as in:

live_loop :looper do

  live_loop :lfo do
    pan = (range -1, 1, 0.1).mirror.tick
    # some way of updating the 'sample' parameters needs to go here!
    sleep 0.1
  end

  sample :loop_amen
  sleep sample_duration :loop_amen
end

How can I get that pan value updating the sample parameters in real-time? What I ultimately want to build several asynchronous lfos that are each mapped to different, real-time elements of the sample command.

I think I’ve got it! Thanks to the advice posted by @ethancrawford on this thread.

live_loop :beat do
  s = sample :loop_amen_full
  set(:s, s)
  sleep sample_duration :loop_amen_full
end

live_loop :lfo do
  use_real_time
  control get[:s], pan: (range -1, 1, inclusive:true, step: 0.1).mirror.tick
  sleep 0.1
end

I had to stick in use_real_time on the lfo section or I was getting timing warnings. Think this looks okay - although I’d welcome any feedback if I’m doing it a goofy or inefficient way!

Was just about to post this

LFO = line(0, 1, steps: 5).mirror

live_loop :test do
  play 60, pan: LFO.tick * 2 - 1
  sleep 0.5
end

But I may have missed what the core of your question was.

1 Like

I did misunderstand, oops

live_loop :depth do
  l = -1
  r = 0
  LFO = line(r, l, steps: 5).mirror
  sleep 0.1
end


live_loop :test do
  play 60, pan: LFO.tick
  sleep 0.5
end
1 Like

Thanks Brendan - after going down the rabbit-hole a bit here, it’s actually very helpful to see both of your examples for a more straightforward use case. They’re very clean!

I want to be able to tick the LFO independantly of the synth that’s making sounds, for 2 reasons: so I can use different sleep rates in the LFO loop to change the speed, and so I can change the parameters of an already-running note/sample.

Ah ok, so the steps: and sleep values in the :depth loop will give you some opaque control over the LFO parameters. I’ll have a tinker in the morning to see if there’s a more transparent method, it’s the kind of thing I could make use of too - like patching independently controllable synth modules.

Brendan

1 Like

Aha yes, that’s a nice analogy - a much cleaner way of describing it!

It takes a bit of head scratching on my part, because, raised as I was on AudioMulch, Max/PD and Supercollider, I often think of live loops as independent patchable unit generators. And they’re not, and I absolutely LOVE learning this different way of composing and performing music!

1 Like

Very much in the same boat here! But just learning that I can do something like this in one live loop:
s = sample :loop_amen

and then do this in a separate live loop:
control get[:s], amp: 0.5

is a bit of a game changer, connectivity-wise!