Cabbage Logo
Back to Cabbage Site

How to read to a buffer and mess with it live?

Say I want to read to a buffer, and I want to slow the rate at which the buffer plays. This will give me some room to chop the buffer around and stuff like that, but I have no idea where to start. What opcode do I need to look at in order to be able to read into a buffer and manipulate the buffer live? Think grossbeat, Shaperbox time shaper. I wanna have a go at that using csound.

There is a lack of buffer based effects like this in the open source space.

Function tables can be used to buffer live audio. In the following simple example I continuously write to a table, and then access the samples one by one as needed, depending on the ‘mode’ I’m in. Feel free to take it and hack it to pieces. I wrote this 10 years ago, but if I was doing this from scratch again today, I would probably use the same approach. Tables and table reading/writing opcodes are key. Note that I put his into a UDO because I wanted to set ksmps to 1 so I can use k-rate variables at a-rate speeds. Finally, you’ll see that when in bypass mode, it simple outputs the live signal.


liveSplicer.csd (3.3 KB)

Awesome, thank you!

(kindx+kpos)<=0 ? ftlen(itbl)-kpos : kindx-1

I wonder what this syntax means? While kindx+kpos <=0, kindx = ftlen(itbl)-kpos, otherwise kindx = kindx -1? Is that correct?

It’s more if kindx…

As far as I know it’s called a conditional ternary operator. just in case you want to look it up. It saves you from having to type a few extra lines of code :slight_smile:

Okay, I see! thank you. How do I go about clearing the buffer when IS_PLAYING == 0?

Figured out a solution, I use loopseg instead of phasor.

1 Like