Problem with use_synth in live_loops not changing synth until next iteration

Hiya all!

I’ve been tryinig to make a TouchOSC interface with easy access for disabled people to enjoy playing music. My problem is that trying to change the synth used in the play live_loop with a push button, it takes two activations of the play live_loop for the sound to change. Same thing when moved all the attributes for the play from end of each string to use_synth_defaults, they too won’t change until the second time the loop is activated.

Is this because of the way live_loops work? Is there any way to change the behaviour so that the changes would be immediate?

Here’s an example:

co = 10
use_synth :blade

live_loop :cutoff_chg do
  co_sync = sync "/osc/3/rotary3"
  co = co_sync[0]
end

live_loop :play do
  use_synth_defaults cutoff: co
  note, velocity = sync "/midi/*/*/*/note_on"
  play_chord [(60),(64)]
end

Jouni

When you say “second time the loop is activated”, do you mean that it won’t change during the loop, or that the loop runs once with the old setting before changing to the new one? Every time you play something using a synth, you instantiate a new thread using that synth, which can’t be changed once it starts playing. You can, however, change the parameters, such as cutoff, after the synth starts playing by saving the synth in a variable and using the control function.

There’s a bit in the built-in tutorial on how to do this. When I’m doing OSC, I tend to use the get command instead of sync while looping reasonably fast after the synth starts playing. get doesn’t hold up the thread, it simply polls the OSC device and gets the current value. Something like this

live_loop :changer do
  s = synth :beep, sustain: 8
  
  32.times do
    sig = get "/path/to/osc"
    control s, cutoff = sig[0]
    sleep 0.25
  end
end

Hi,

Thanks for your reply. I meant that the loop runs once with the old setting before changing to new one. Don’t really care about changing the sound cutoff value on the fly (during sound), for I’m not trying to make so complicated input atleast yet. Would just hope that when new settings are set via osc, sound played thereafter would reflect those settings straight away, and not the once before. When I had the cutoff value connected to play (play_chord [(60),(64)], cutoff: co) it changed as soon as. However I don’t quite know how to use the synth the same way connected to the actual play command. (And further more, it would be cleaner to use the synth_defaults, as there are quite a rows for now… maybe some refactoring is due.)

Jouni

Switch the order of the sync and use_synth_defaults:

note, velocity = sync "/midi/*/*/*/note_on"
use_synth_defaults cutoff: co

As-is, you first set the cutoff (to whatever co is at that moment) and then wait for a midi note to come in. From this point on, any co changes just change the co variable but do not affect cutoff as it’s been set already. Then when sync triggers, it plays the chord with the “old” cutoff.

Crap. Thanks. I’ll get my coat. :smile: cheers, happy days!

Jouni