Cabbage Logo
Back to Cabbage Site

Preset and Soundfiler issues

I’m trying to add finishing touches to a sampler i’m working on but I’m running into two issues that I can’t figure out no matter how much I try fix things. The first issue is to do with preset saving, whenever I try save a new preset, my Reverb Button gets immediately set to off and will stay off whenever the preset is selected even if it was previously on. The logic for my Reverb button is the exact same as the Distortion and Flanger yet doesn’t work the same way.
The other issue is to do with my soundfiler, whenever I load in a sample from the combobox, it doesn’t load the waveform even if it is loaded into the file attribute of the soundfiler. This is also super strange to me as the logic seems to be the same as if a sample is being dropped in and it works as intended if i drag in an audio file.
I’m simply stumped and can’t figure out why either of these things are happening. Below I have attached the csd file as well as zip containing samples I was using.

any help would be appreciated

SAMPLER.csd (11.5 KB)

You have two reverb channels defined. I suspect your ‘reverb’ label is overriding your button.

This is a little less obvious. Your first mistake is this:

SFile = gSSamplesArray[kSample-1]

String assignments like this are i-rate. So that won’t ever be updated. Things work in your drag and drop code because you are accessing the string at k-time using an opcode. The other issue is that you are passing relative paths instead of absolute paths. ‘samples/BackBreak.wav’ is not an absolute file path, therefore Cabbage won’t be able to display it, even if Csound can find it. The solution is this:

if kSampleSelectTrig == 1 then
    SFilePath sprintfk "%s/%s", chnget:S("CSD_PATH"), gSSamplesArray[kSample-1] 
    printf "%s", kSampleSelectTrig,SFilePath
    cabbageSet kSampleSelectTrig, "sfiler", "file", SFilePath
    chnset SFilePath, SFileChannel
endif

You’ll see how I’m using the k-rate version of sprintf to construct an absolute path to your file using the CSD_PATH value. I’m printing this value out for debug purposes, but you can remove that. The key thing is that although Csound might be able to find files from relative strings, you should always provide absolute paths to be sure because you never know when a DAW might change the current working directory. If it does at some point, all of your relative paths will be broken. And not even Csound will be able to fix them.

Nice instrument btw :slight_smile:

All the fixes work great! Thanks a lot, gonna be working on making the fx toggle-able through midi now…. should be interesting