# Crossfading buffers, or stopping single buffers

**URL:** <https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691>\
**Category:** \[P\] Patreon Support\
**Created:** [January 31, 2018, 3:05pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691 "2018-01-31T15:05:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![csantin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/csantin/32/400_2.png) [@csantin](https://in-thread.sonic-pi.net/u/csantin)\
**Post date:** [January 31, 2018, 3:05pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/1 "2018-01-31T15:05:08Z")

</div>

Hi all

Is there any way to stop single buffers or, even better, crossfading between them? Is it so obvious that I’ve not seen it? 🙂

This would be a must for me playing it live

Or is there any alternative workflow to, let’s say, change scenes?

Great stuff however, thanks!

---

<div class="post-metadata">

**Author:** ![JorshTheHacker](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@JorshTheHacker](https://in-thread.sonic-pi.net/u/JorshTheHacker)\
**Post date:** [January 31, 2018, 3:24pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/2 "2018-01-31T15:24:37Z")

</div>

I would add the `stop` statement to the end of each thread (or `live_loop`) in the buffer, and add a `sleep` line to the BEGINNING of that buffer (at 60 bpm, `sleep 5` should be more than enough). Then run the buffer, switch to the next buffer, and run THAT buffer. The first buffer will stop after 5 beats. I suggest adding a `sleep 3` line to the beginning of the second buffer before running it, to provide a better fading effect.

---

<div class="post-metadata">

**Author:** ![csantin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/csantin/32/400_2.png) [@csantin](https://in-thread.sonic-pi.net/u/csantin)\
**Post date:** [January 31, 2018, 3:50pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/3 "2018-01-31T15:50:39Z")

</div>

Thanks for the answer

But this means that the loop has to have a pre-defined length, and that I only can switch to the next buffer when the stop statement is reached… right?

My setup aims more to improvisation, therefore having fixed lengths of loops is not suitable for me ☹

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [January 31, 2018, 4:43pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/4 "2018-01-31T16:43:34Z")

</div>

you can use cues in one buffer to switch to code in another one. Uase a correspnding sync command in the second buffer (You have to run the destination buffer first so that it is waiting for the cue). Does that help?

---

<div class="post-metadata">

**Author:** ![SubitusNex](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/subitusnex/32/392_2.png) [@SubitusNex](https://in-thread.sonic-pi.net/u/SubitusNex)\
**Post date:** [January 31, 2018, 4:54pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/5 "2018-01-31T16:54:56Z")

</div>

Hmmm, I guess you could have OSC messages between buffers and wait for the messages to run functions that fade and/or stop.

---

<div class="post-metadata">

**Author:** ![csantin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/csantin/32/400_2.png) [@csantin](https://in-thread.sonic-pi.net/u/csantin)\
**Post date:** [January 31, 2018, 5:01pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/6 "2018-01-31T17:01:20Z")

</div>

Hi all

I was asking for something more “Ableton-ish” and embedded in the UI.

But I’ll try your options for sure

thanks to all!

---

<div class="post-metadata">

**Author:** ![SubitusNex](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/subitusnex/32/392_2.png) [@SubitusNex](https://in-thread.sonic-pi.net/u/SubitusNex)\
**Post date:** [January 31, 2018, 5:08pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/7 "2018-01-31T17:08:32Z")

</div>

Sorry I couldn’t help more.

Btw, you probably can use MIDI messages as well (instead of OSC) and if you want, you can use MIDI control software to generate those or hardware, like a MIDI controller. (same with OSC)

There’s a plethora of options there, and that’s what those have been for even in DAWs.

Cheers, hope that helps a bit.

PS: Cues are also an option, but within Sonic Pi code itself.

---

<div class="post-metadata">

**Author:** ![csantin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/csantin/32/400_2.png) [@csantin](https://in-thread.sonic-pi.net/u/csantin)\
**Post date:** [January 31, 2018, 5:16pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/8 "2018-01-31T17:16:52Z")

</div>

Sorry if my questions are too obvious, but it is my first day with Sonic Pi and I definitively need to check deeper the documentation

Just a final might-be-stupid question: Is it possible to play/stop single buffers through OSC or MIDI?

---

<div class="post-metadata">

**Author:** ![JorshTheHacker](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@JorshTheHacker](https://in-thread.sonic-pi.net/u/JorshTheHacker)\
**Post date:** [January 31, 2018, 5:32pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/9 "2018-01-31T17:32:14Z")

</div>

you can add/run the `stop` lines whenever you feel like ending it. You could also use a die roller or something (randomization).

---

<div class="post-metadata">

**Author:** ![SubitusNex](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/subitusnex/32/392_2.png) [@SubitusNex](https://in-thread.sonic-pi.net/u/SubitusNex)\
**Post date:** [January 31, 2018, 5:36pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/10 "2018-01-31T17:36:20Z")

</div>

It’s not a stupid question at all, because it’s more complex than it might seem.

As sam once wrote at: [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/sonic-pi/AyR4mPgMmv4)

> Hi there,
> 
> buffers currently don’t do anything special other than house text. However, I have plans to change that and make buffers something you can start, stop, and mix…
> 
> Sam

So stopping a buffer really means stopping all threads generated in a buffer. (at least from what I can tell)

PS: @csantin I’m new at this too 🙂

---

<div class="post-metadata">

**Author:** ![csantin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/csantin/32/400_2.png) [@csantin](https://in-thread.sonic-pi.net/u/csantin)\
**Post date:** [January 31, 2018, 5:45pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/11 "2018-01-31T17:45:43Z")

</div>

Ahh, a buffer mixer, I was looking exactly for that minutes ago

Good to know that there are future implementation plans

Thanks to all for the help

---

<div class="post-metadata">

**Author:** ![csantin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/csantin/32/400_2.png) [@csantin](https://in-thread.sonic-pi.net/u/csantin)\
**Post date:** [January 31, 2018, 5:47pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/12 "2018-01-31T17:47:36Z")

</div>

So I just replace the whole buffer content with a stop statement, now I get it

Although such a workflow is not exactly intuitive

Thx!

---

<div class="post-metadata">

**Author:** ![SubitusNex](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/subitusnex/32/392_2.png) [@SubitusNex](https://in-thread.sonic-pi.net/u/SubitusNex)\
**Post date:** [January 31, 2018, 5:57pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/13 "2018-01-31T17:57:29Z")

</div>

Actually put a “stop” on each “thread” - loops included. Replacing everything for a “stop” wont stop already running threads.

---

<div class="post-metadata">

**Author:** ![JorshTheHacker](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@JorshTheHacker](https://in-thread.sonic-pi.net/u/JorshTheHacker)\
**Post date:** [January 31, 2018, 6:07pm UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/14 "2018-01-31T18:07:13Z")

</div>

Not the whole buffer – `stop` stops the current thread. Just add it somewhere in the individual loops.

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [February 1, 2018, 12:11am UTC](https://in-thread.sonic-pi.net/t/crossfading-buffers-or-stopping-single-buffers/691/15 "2018-02-01T00:11:21Z")

</div>

> [@csantin](#):
>
> Is there any way to stop single buffers or, even better, crossfading between them? Is it so obvious that I’ve not seen it? 🙂

Currently there’s nothing like this - although I have planned stuff like this for a while now. Hopefully if I’m able to keep on hacking on Sonic Pi this is something I’m able to work on.

> [@csantin](#):
>
> This would be a must for me playing it live

It’s definitely possible to play good quality live sets without this functionality. Using Robin’s advice of taking advantage of `sync` and `cue` across buffers is one way of ensuring the code in two buffers is working in time together. Then it’s just a matter of live coding the live loops to create a transition. This is the kind of thing I hope to make clearer in the video tutorials I have planned 🙂
