Sustenance of complex sounds

Hello! There’s one thing I need to understand about Sonic Pi.

It works okay as long as I keep it simple with sounds, for instance playing one line of sample. But as soon as I put more elaborate and complex sounds, the application starts to lag, the sound falls behind in timing, a a thread death results from this somewhere, and Sonic Pi doesn’t play even the simplest sound if I stop the sound. I press the “Run”, but nothing starts. Moreover, the app’s sound starts to run on its own, taking out of the sound some of the commands on the buffer (e.g. leaving only percussions, drums or the :bd-haus sample), slowing the tempo. When I stop the sound, Sonic Pi doesn’t even run the simplest sound, I press “Run” but the program stays silent.

I took the complex sounds from one of the tutorials that can be found in this forum, which I leave below:

For your information, I have the portable version of Sonic Pi on my computer and my laptop’s system runs on Windows and I have around 60 tabs in Google open. This might help you figure out what’s wrong, let me know if you need further details.

Can anyone help me? I’d be grateful for that. I hope my explanation of the issue is clear enough. Thank you in advance to anyone who will lend a hand. Have a nice day.

1 Like

Hi Bryan,

Running SP on your PC uses up resources, as you probably realise.

However, if those resources are already in use… SP can quickly
become bogged down if using complex code. Soooo…

  1. Ditch all the open Google tags.

  2. Dont use the portable version… install it, and give SP a chance.

  3. If you can only use the portable version, put the following as the
    very first line of your code…

use_sched_ahead_time 2

This gives SP a little breathing time when it is running.

Good luck!


1 Like

As Eli noted …
I had the same problem with your code
until I turned the reverb in the last loop
off . Reverb is notorious for sucking up
resources …

1 Like

Hiya Hits,

If you change that final block to:

with_fx :reverb, amp: 1, mix: 0.25 do
  live_loop :pulputus do
    use_synth :tb303
    nuotti = (chord :C2, :minor).choose
    play nuotti, cutoff: rrand(10, 130), release: 0.1, amp: 0.7, release: 0.1
    sleep 0.25

It should solve that problem… the old block called the FX every
time the block was run, which is a horrible resource waster!


1 Like

You are oh so right !

1 Like

Sorry for not replying. I took time off Sonic Pi today. I’ll see tomorrow how your suggestions will help me. Hope everything’s cool.

So what is the FX command, the line of code that I should avoid in my buffer?

Hey Bryan - I’ll jump in, since I’m around right now :slight_smile: The situation that @Eli was referring to is described in Sonic Pi’s tutorial - see for example.
It’s not always so much as what line should you avoid, as what order you might need to write some things in.
Several of Sonic Pi’s FX can be quite resource intensive if used in certain ways, with :reverb being a common one. As such, we often want to avoid putting a :reverb FX inside a live_loop (or normal loop for that matter) if the loop has a small time span, such as in your example, since a new reverb is created every time around the loop.
It’s described in more detail in the tutorial linked above, but one of the most common solutions is instead to wrap the live_loop in the FX, instead of the other way around.