# Sustenance of complex sounds

**URL:** <https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888>\
**Category:** Support, Help & Resources\
**Created:** [May 20, 2020, 1:57pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888 "2020-05-20T13:57:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryan](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/bryan/32/1408_2.png) [@Bryan](https://in-thread.sonic-pi.net/u/Bryan)\
**Post date:** [May 20, 2020, 1:57pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/1 "2020-05-20T13:57:54Z")

</div>

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:

[http://sonic-pi.mehackit.org/exercises/en/11-templates/04-simple-slow-techno.html](http://sonic-pi.mehackit.org/exercises/en/11-templates/04-simple-slow-techno.html)

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.

---

<div class="post-metadata">

**Author:** ![Eli](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/eli/32/116_2.png) [@Eli](https://in-thread.sonic-pi.net/u/Eli)\
**Post date:** [May 20, 2020, 6:33pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/2 "2020-05-20T18:33:53Z")

</div>

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!

Eli…

---

<div class="post-metadata">

**Author:** ![hitsware](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@hitsware](https://in-thread.sonic-pi.net/u/hitsware)\
**Post date:** [May 20, 2020, 6:49pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/3 "2020-05-20T18:49:26Z")

</div>

As Eli noted …  
PLUS  
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 …

---

<div class="post-metadata">

**Author:** ![Eli](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/eli/32/116_2.png) [@Eli](https://in-thread.sonic-pi.net/u/Eli)\
**Post date:** [May 20, 2020, 7:02pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/4 "2020-05-20T19:02:54Z")

</div>

Hiya Hits,

If you change that final block to:

```ruby
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
  end
end

```

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

Eli…

---

<div class="post-metadata">

**Author:** ![hitsware](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@hitsware](https://in-thread.sonic-pi.net/u/hitsware)\
**Post date:** [May 20, 2020, 7:15pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/5 "2020-05-20T19:15:38Z")

</div>

> [@Eli](#):
>
> It should solve that problem…

You are oh so right !

---

<div class="post-metadata">

**Author:** ![Bryan](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/bryan/32/1408_2.png) [@Bryan](https://in-thread.sonic-pi.net/u/Bryan)\
**Post date:** [May 21, 2020, 10:37pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/6 "2020-05-21T22:37:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bryan](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/bryan/32/1408_2.png) [@Bryan](https://in-thread.sonic-pi.net/u/Bryan)\
**Post date:** [May 22, 2020, 12:58pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/7 "2020-05-22T12:58:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [May 22, 2020, 1:25pm UTC](https://in-thread.sonic-pi.net/t/sustenance-of-complex-sounds/3888/8 "2020-05-22T13:25:08Z")

</div>

Hey Bryan - I’ll jump in, since I’m around right now 🙂 The situation that @Eli was referring to is described in Sonic Pi’s tutorial - see [https://sonic-pi.net/tutorial#section-6-2](https://sonic-pi.net/tutorial#section-6-2) 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.
