Hey, everyone. I use a lot the loop function (not just live_loop or N.times). It is a musical tool I think I would implement as soon as possible if I could because it is one of the first things we learn at Sonic Pi to structure repetition. I could help the transition from Pi to Tau more friendly as well.
Hi there, I currently have no plans to implement loop. Out of interest, what do you see the benefits over live_loop? Loops are only in Sonic Pi due to historical reasons and the Ruby roots.
It does work now ![]()
Thanks so much for pointing this out. It was an issue with the compiler reusing slots across functions rather than keeping them isolated. Should now be fixed ![]()
Would look forward to control and slide opts, if youâre thinking of adding those too eventually Sam ![]()
![]()
I found an issue with .tick - it doesnât track of individual ticks like Sonic Pi does
live_loop :example do
a = (ring 0 1 2 3 4 5 6 7).tick(:foo)
b = (ring 0 1 2 3 4 5 6 7).tick(:bar)
c = (ring 0 1 2 3 4 5 6 7).tick(:baz)
print a
print b
print c
sleep 1
end
Hi, Sam. thanks for your comment! I will answer from two perspectives here: as a user who has no formal training in programming and as a music teacher.
First, as a musician with no prior background in programming.
I started learning p5.js and some music live coding languages one year ago. What made me turn to computer music was my desire to create experimental and contemporary music on the fly. So, loop is a tool to experiment non-stardand coding for me, like the following patch (I was trying to make Sonic Pi behave more random-y):
use_synth :dsaw
loop do
with_fx :reverb, mix: 0.5, room: 0.65 do
with_fx :ring_mod, amp: 0.75, mix: 1, freq: 110, mod_amp: 1 do
use_random_seed choose(rrand(0, 37129872198732))
8.times do
with_fx :vowel, vowel_sound: rrand_i(1,5) do
play choose(scale(:E2, :karcigar, num_octaves: 4 )), sustain: 0.3 , release: 0.05, cutoff: rrand(60, 120)
sleep 0.25
end
end
end
end
end
My workflow not always progresses towards multiple live_loops, so itâs nice to have the option to code with less characters (as I will explain more in detail). Also, the more I study coding, the more I learn is good to have more ways to code the same things especially when we are prototyping.
As a teacher in Brazil, I have to deal with non-English speakers who mostly will not code on computers to learn live coding. So, we have to think what makes easier to teens with regular mobiles to type fast in a language which is not theirs. I checked the examples at the Lang session and found two examples which, to me, as an experienced musician and adult capable of (some) self-learning, maybe will suffice as models:
live_loop :melody do
play [60, 62, 64, 67].tick
sleep 0.25
end
notes = [60, 64, 67, 72]
amps = [1, 0.5, 0.7, 0.3]
live_loop :multi do
play notes.tick, amp: amps.look
sleep 0.25
end
But I have to think as my students. I put myself in their heads. I imagine myself using their phones. I can see them asking me: âThiago, âtickâ is written with double kk?â. I see they making mistakes with underscores and hifens. So the loop function is really necessary not only to fast prototyping, but also when I take in account technological, linguistic, pedagogical and economic issues which are not being seeing in the countries of global North. Itâs not about programming, itâs about being equally accessible over the world. Small screens and keyboards also make it harders to type more and faster. So, to code on mobiles, I suggest: 1) implementing the loop function as it runs on Sonic Pi; or 2) making it availabe as an alias to live_loop, which would also be of great help.
Anyway, Iâm really excited to see whatâs coming next!
Whatâs missing for you right now?
Using control and some slide opts to smoothly slide opts. Itâs helpful to set a parameter changing while you go off and start writing something else for example.
Can you share an example that works in Sonic Pi that doesnât in Sonic Tau?
Sure, hereâs an example:
live_loop :test do
s1 = synth :dsaw, note: 50, release: 2, cutoff: 30
control s1, cutoff_slide: 2, cutoff: 120
sleep 2
end
Seems like it doesnât support nested arrays, they would be useful:

At least literal nested arrays anyway. Perhaps not as helpful, but this seems to be fine:
x = [:c, :d]
a = [:a, :b, x]
Ha. Well, printing it produces 309.525 [69, 71, heap(1204)] - so perhaps not quite there still.
The issue was the interaction between these two lines. control and synth slides have been implemented fine - but SuperColliderâs scsynth server canât control a synth that itâs triggering in the same time slot. In Sonic Pi I fudged this by adding a cheeky hidden sleep time between the two. However, now I have control over SuperSonic - I can fix it at the source directly ![]()
Try again now!
Nested lists feel a bit out of scope right now. What do you use/need them for?
I needed to test in a private browsing window to see it work, but seems good! Thanks.
Knowing it was available from the documentation would have been handy, would you consider adding them there? I know youâre in a heavy development phase right now but itâs much easier for folks to help you test or spread awareness of the system if theyâre interested in a feature they can see is already implemented.
Nested lists feel a bit out of scope right now. What do you use/need them for?
I wanted to tick over an array of notes, but have some of them be intervals/chords instead of single notes. But I understand there might be other priorities, so I can always work around it.
Are there keyboard shortcuts for run and stop?
Iâve found cmd-/to toggle commented lines
Really appreciate the work youâre doing Sam ![]()
Ha, worked it out. cmd-enter to play cmd-. to stop ![]()