# Problems with external samples and external synth

**URL:** <https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049>\
**Category:** Support, Help & Resources\
**Created:** [October 16, 2021, 1:00pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049 "2021-10-16T13:00:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://in-thread.sonic-pi.net/u/Matt)\
**Post date:** [October 16, 2021, 1:00pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/1 "2021-10-16T13:00:29Z")

</div>

Hi, I have problems with external samples, when I use them in a live\_loop. The samples work good at the beginning and the sound quality is fine, but after a few tens of seconds the sound seems like distorted. It’s like the samples “overlap” each other at every repetition of the loop, till the complete saturation of the sound. The same thing happens with external synth developed in Supercollider.

Here you have an example of the code:

> live\_loop :kettle do  
> with\_fx :echo do  
> sample samples, 1, rate: 1.5, amp: 0.15, decay: 20  
> sync :tick  
> sleep 1.0  
> end  
> end

Does anyone have the same problem? Can you help me to find a solution? Thanks a lot in advance.

---

<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:** [October 16, 2021, 1:22pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/2 "2021-10-16T13:22:57Z")

</div>

One thing that pops out: if the `:tick` cue is sent fairly quickly, then every time the loop repeats, a new `:echo` fx is probably being created before the old one has time to fade away. (The default `decay:` value of an echo fx is 2 beats). That may or may not build up enough to become a noticeable problem.

One alternative to reducing that issue is to wrap the echo fx around the entire live\_loop - this will create a single fx that does not get constantly replaced every time the loop inside repeats, and thus not be overlapped by new instances.

Maybe this is helpful for you? 🤞

Oh, also just spotted that you tell Sonic Pi that the sample has a decay phase of 20 beats. Is your sample indeed about that long? Note that beside the `sync :tick`, you only sleep for 1 beat - so if the `:tick` cue that releases the sync is usually more frequent than every 19 seconds, the loop will repeat before the current sample has finished playing, thus triggering another sample to overlap it. Does that sound about right for what’s happening here?

(Just to clarify, I’m not sure, but this also might be a misunderstanding over how the things like attack/decay/sustain/release opts work. Pardon me if you were already aware, but if not, Sonic Pi does not wait for synths and samples to finish playing before moving on to the next piece of code - it triggers the samples, and then immediately moves on to the next pieces of code. Attack, decay et al only tell Sonic Pi how long the sound plays, not how long to wait before doing the next thing 🙂)

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://in-thread.sonic-pi.net/u/Matt)\
**Post date:** [October 16, 2021, 2:47pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/3 "2021-10-16T14:47:42Z")

</div>

Thanks a lot, Ethan! 🙂

Your explanation is very helpful. But I’ve tried to think about what you’ve said, and to find a good balance between the tick speed and the decay/echo, and the problem still persists.

In this case, I’ve eliminated the decay setting and I’ve set the tick’s pause at 4 seconds, but after 30/40 seconds I have the same saturation of the sound:

```ruby
at live_loop :tick do
  sleep 4
end

live_loop :kettle do
  with_fx :echo do
    sample samples, 1, rate: 1.5, amp: 0.15
    sync :tick
  end
end

```

The same problem comes out with samples that have no echo:

```ruby
live_loop :snare do  
    sample samples, 4, rate: 18, amp: 1
    sync :tick
end

```

And the same thing happens when I connect a midi controller to play the piano synth…

I really don’t know what this could be…

---

<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:** [October 16, 2021, 2:54pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/4 "2021-10-16T14:54:33Z")

</div>

Just a quick note: I’ve taken the liberty of formatting your code blocks 🙂  
To do this, there’s no need to use block quotes. You can place three back ticks ``` on a line before and after your code, and it highlights the code nicely 🙂

With your above example, did you mean to write `at live_loop` ? this is most likely not want you want.

Also, not necessarily related to the sound saturation you’re experiencing, but I’d avoid using `sync` inside a live\_loop unless you really need to. If you are just trying to make sure that the samples happen every 4 beats but stay in time with other live\_loops as well, then I’d remove the syncs inside the loops and use the other alternative: `live_loop :kettle, sync: :tick do` … much more information about that elsewhere on the forum though - here’s a few pages:

> [@Using :sync with live\_loops](https://in-thread.sonic-pi.net/t/using-sync-with-live-loops/172):
>
> I’m curious to see what people’s thoughts are on the best way to use :sync with multiple threads. I have seen it used outside the block of code, following the name of a live\_loop, inside the block of code as well as using cue :tick inside a block of code and then syncing with :tick. The differences seem to be in when you start the program, certain threads have to run before others sync up with it and also the length of time it takes for a change to happen in a thread that has been synced with a…

> [@Live loops Sync questions slight\_smile](http://in-thread.sonic-pi.net/t/live-loops-sync-questions/1172):
>
> Hi everybody, I always have troubles with sync in sonic pi… if somebody can explain why this following code do run as it runs, it would be kind ! use\_bpm 120 beats\_per\_bar = 4 ############################### TOOLS ############################### live\_loop :metronome do use\_synth :beep play :a4, release: 0.5 sleep 1 end live\_loop :\_1\_bar do use\_synth :beep play :as5, release: 0.5 sleep beats\_per\_bar # the cue is sent ONLY NOW /frowning so sad no ? end live\_loop :\_4\_bars do sleep b…

You mention the problem still persists in the above examples - how long are those samples exactly?

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://in-thread.sonic-pi.net/u/Matt)\
**Post date:** [October 17, 2021, 8:13am UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/5 "2021-10-17T08:13:08Z")

</div>

Thanks a lot again for your explanation, “at” was a typing error, sorry.

The sample “kettle” is 27 seconds, probably too long?

The sample snare is 2 seconds, but still creates the same problem. As I said, the same thing happens when I connect a midi controller to play the piano synth, and also when I launch a synth made in SC. I really don’t know what’s the reason of all this…I’m a bit lost!

---

<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:** [October 17, 2021, 9:38am UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/6 "2021-10-17T09:38:02Z")

</div>

> [@Matt](#):
>
> The sample “kettle” is 27 seconds, probably too long?

For that particular use case, yes. If the effective duration of the loop is shorter than the sample, then you will have overlaps. The more the durations are different, the more significant the potential problem. (This goes for the echo and similarly resource intensive fx also)

As far as the other sample, or MIDI/custom synths are concerned - not sure either. It could well be a quirk of your particular system. What platform/OS/hardware are you using?

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://in-thread.sonic-pi.net/u/Matt)\
**Post date:** [October 17, 2021, 1:24pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/7 "2021-10-17T13:24:50Z")

</div>

Thanks a lot. I use MacOs High Sierra, and a Native Instruments Komplete control A 49 controller.

I’ve also realised that things are getting worst since I’ve installed the 3.3.1 release…I don’t know if this can help.

---

<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:** [October 17, 2021, 1:51pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/8 "2021-10-17T13:51:11Z")

</div>

Unfortunately I personally don’t have many more ideas at this point - the code in your snare loop looks fine. As for 3.3.1 - I would doubt that it’s a problem with that version, but you never know. Did you observe the same script working in an earlier version? You could always try [v3.2.2](https://github.com/sonic-pi-net/sonic-pi/releases/tag/v3.2.2) just to see…

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://in-thread.sonic-pi.net/u/Matt)\
**Post date:** [October 17, 2021, 1:52pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/9 "2021-10-17T13:52:49Z")

</div>

Ok, I will try to do it. Thanks a lot in any case for your help!

---

<div class="post-metadata">

**Author:** ![Hussein](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/hussein/32/1972_2.png) [@Hussein](https://in-thread.sonic-pi.net/u/Hussein)\
**Post date:** [October 17, 2021, 2:49pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/10 "2021-10-17T14:49:54Z")

</div>

I tried your code but just using the samples shipped with SPi and don’t seem to experience the issues you describe. Could you swap out your samples for the ones with the library and see if you experience the same behaviour?

In terms of controllers, I occasionally notice additional midi info being sent by Ableton into SPi when I have them working together, that I have not sequenced. Perhaps NI’s controller might be sending continuous status messages.

As @ethancrawford has said, perhaps a different version, even if this is doubtful, is worth trying. But as you get similar results using the built in synth, it could be a midi loop/echo setting on the NI Controller.

Hope you get to a solution.

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://in-thread.sonic-pi.net/u/Matt)\
**Post date:** [October 17, 2021, 9:41pm UTC](https://in-thread.sonic-pi.net/t/problems-with-external-samples-and-external-synth/6049/11 "2021-10-17T21:41:35Z")

</div>

So, really thanks a lot to all for your advices and support! I moved to the 3.1.0 version and all seems to work good! The problem was probably due to the incompatibility of my pc (which is an old machine) with the recent versions of Sonic-pi.
