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
Does anyone have the same problem? Can you help me to find a solution? Thanks a lot in advance.
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 )
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:
You mention the problem still persists in the above examples - how long are those samples exactly?
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!
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?
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 just to see…
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.
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.