Cabbage Logo
Back to Cabbage Site

Would it be easy to trim samples with Cabbage/Csound?

Hi,

I’m new here, thanks @rorywalsh for the amazing work on Cabbage and the support. :slight_smile:

I am currently working on a VST and trying to implement all my ideas. I’m still struggling with several algorithms but I feel like combining Csound opcodes can produce great results!

However, I don’t know if one of the idea is feasible: would it possible to load a sample, display it with a soundfiler, and then have the ability to trim the beginning and the end of the sample, so the user can decide to delay the start of the sample or shorten it?

There is this feature in the FL Studio sampler: with the in/out knobs you can adjust the start and end of the samples.

This questions can be decomposed in two problems:

  • Do we need to re-load the file (with the diskin opcode) each time the sample is trimmed? Or is there any other way to do that?
  • How could we indicate visually to the user how the sample is trimmed? Two vertical bars on top of the soundfiler could work but I don’t know if you can customize that much

Also, would it be possible to display a progress bar on the soundfiler when the sample is triggered?

I already did some research but I did not find any examples or documentation.

Thanks!

Hi @nymano, welcome to the forum. Yes this is possible, but you should probably load the audio into a function table, and then read back from point a to point b using one of the table opcodes. I think it will give you more versatility. Have you looked at the file player examples that ship with Cabbage? They use a variety of different opcodes for reading audio. If you can’t get something going I can throw together a basic example when I get a chance :+1:

Thanks @rorywalsh, I will try to make a minimal example when I have some time!

This example should help me: https://github.com/rorywalsh/cabbage/blob/develop/Examples/FilePlayers/FileStretcher.csd

I’ll let you know, thanks :slight_smile:

I just tried myself to build a simple example, and I found a bug that prevents it from working as I would like. I’ll fix this tomorrow and send you the example. Note that the file playing examples that ship with Cabbage are using an older UI update system. It still works fine, but the newer system is more performant. Anyhow, you can still learn a lot from those examples :+1:

I couldn’t let that go until tomorrow :rofl: I’ve just pushed a fix. You can find the latest beta builds here:

https://dev.azure.com/rorywalsh/Cabbage/_build?view=runs

And here is a simple example customSampleLength.csd (1.9 KB)

Thanks @rorywalsh! I will try it tomorrow :slight_smile:

By the way it’s the first time I see Azure DevOps pipelines in action. At work we use Gitab CI and imo it’s a bit messier haha, I like the clean Azure dashboard

I think that might be the first time I’ve heard someone singing the praises of DevOps :rofl: I was tempted to switch to Github actions, but once I got it up and running I’ve rarely had any issues with it. I think I’ll leave well enough alone. They are a pain to configure at the best of times.

Hi @rorywalsh,

Thanks it’s working perfectly :slight_smile:
And the code is elegant!

Thanks again, it helps me a lot for my project.

1 Like