Making a synth play infinitely long but still control it

Hi there,

as a (slightly boring, but anyway doable) form of intro for some live coding, I’d like to have a synth play a single note for a looong time.

With a large value for release or sustain, this is easily doable of course:
synth :prophet, note: :e1, sustain: 10000

However, I’d like to be able to control this synth somehow, after it’s been started mostly so I can turn it off at some point. Easy, in theory, with control.
But if I start the synth and don’t want to restart it the time I reevaluate my code, I need to put it in a live_loop, right? And at that moment I need the live_loop to sleep.
Of course I can set the value for sleep to a high value too, but then the loop is not restarted for the amount of the sleep and I therefore my code changes with which I want to control the synth are not applied.

I tried putting the control node into the time state and get it out in a different loop, but even though the value was defined, controlling it didn’t change the sound.

live_loop :sing do
  n = play 40, sustain: 10000
  set :n, n
  sleep 10000

live_loop :sing_control do
  sleep 10
  n = get[:n]
  co = ring 70, 90
  20.times do
    control n, cutoff: co.tick, cutoff_slide: 2
    sleep 2

Anyone got any other ideas or hints?

1 Like

How about instead of sleeping for a long time to pause your live loop, you instead sync on a yet-to-be-sent cue message? Then you can call cue at some later point to get it started again…


This article might help


Thank you so much. This works beautifully and is exactly what I was looking for!

live_loop :sing do
  sync :startstuff
  n = play 60, sustain: 1000000
  sync :stopstuff
  control n, amp: 0, amp_slide: 3

live_loop :control do
  sleep 2
  cue :startstuff
  sleep 10
  cue :stopstuff

Wasn’t aware from the docs, that syncing on a cue that hasn’t been sent yet, is basically waiting for that sync. Which of course makes total sense, so my bad :slight_smile:.