Cabbage Logo
Back to Cabbage Site

Coming over from Kontakt/KSP, Group type situation in cabbage?

Hey all. I’m diving in HARD with cabbage and so far I’m loving it.

I have an instrument I’ve built in Kontakt that I’m really proud of and I’m excited to try and make a VST/AU version for the heck of it…I tried some iterations in projucer, but cabbage just clicks way better for me.

My question is:

In my Kontakt instrument, I utilized groups as a pairing mechanism. So for example,
there are 3 instances of a sample playing any time a midi note is triggered. In Kontakt, that would be Group 1, Group 21, Group 41. (incremented for other banks - e.g. Group 2, 22, 42)

Then I implemented a 3 state switch that automated the volume of those groups depending on the state of the switch, so only one group was audible.
The user-end functionality is kind of like a pedal chain, with

position 0 of switch Group 1 audible, Group 21/41 volume = 0
position 1 of switch Group 21 audible, Group 1/41 volume = 0
position 2 of switch Group 41 audible, Group 1/21 volume = 0

Does anyone have any tips on how to best implement this sort of logic in cSound? I’m playing around with some ideas on my own but I’m sure someone with more experience than me has a better idea on how to achieve this!

Welcome to the forum!

Does this code help?

<Cabbage>
form caption("Group") size(400, 300), guiMode("queue") pluginId("def1")
rslider bounds(8, 10, 60, 60) channel("rslider1") text("Slider 1"), range(0, 1, 0.4, 1, 0.001)
rslider bounds(68, 10, 60, 60) channel("rslider2") text("Slider 2"), range(0, 1, 0.2, 1, 0.001)
rslider bounds(128, 10, 60, 60) channel("rslider3") text("Slider 3"), range(0, 1, 0.8, 1, 0.001)
rslider bounds(188, 10, 60, 60) channel("rslider4") text("Slider 4"), range(0, 1, 0.1, 1, 0.001)
button bounds(270, 10, 101, 25) channel("button1"), text("Group 1")
button bounds(270, 40, 101, 25) channel("button2"), text("Group 1")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1

    kGroup1, kGroup1Trig cabbageGetValue "button1"
    kGroup2, kGroup2Trig cabbageGetValue "button2"

    ;when user presses button1, mute slider 1 + 2
    cabbageSetValue "rslider1", 0, kGroup1Trig
    cabbageSetValue "rslider2", 0, kGroup1Trig

    ;when user presses button2, mute sliders 3 + 4    
    cabbageSetValue "rslider3", 0, kGroup2Trig
    cabbageSetValue "rslider4", 0, kGroup2Trig

endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 [60*60*24*7] 
</CsScore>
</CsoundSynthesizer>

test.csd (1.3 KB)

Group button1 controls the volume of sliders 1 and 2, while group button2 controls the volume of sliders 3 and 4. Any widget can control another, or multiple other widgets. Just give the design of it some thought as things can get messy pretty quickly :rofl:

Hi Rory! Thanks for your suggestion.

I was able to achieve the functionality by making bank ranges that all have their own volume params. eg banks 0-x have a volume control, banks x-30 have a volume control, etc. So depending on a switch position, its allowing a certain range of the banks to be at 100% volume while the other ranges switch to 0%. So far it seems to be working as intended.

My initial explanation was not very clear now that I’ve read it back.

I do have a question about sample-loop points! I’m using disk2 opcode to set filepaths and call samples.

From what i’ve read this is the ideal opcode for fetching SMPL loop points, however the samples are just looping from start to end, ignoring the loop-points set in the SMPL chunk. I’ve verified everything at this point in regards to the source files- being properly configured, called, etc.

Do you have any idea what the issue may be?

I didn’t think diskin could handle smpl points at all, but I could be wrong. In fact, I’m not sure if any opcodes are set up to read these values. The lposcil opcodes let users set the start and nd of loop points, but you’d need to get that info from the sample chunk data. Leave it with me I’ll do some rsearch. It should be relatively simple to get this data, but it would need to be done at the opcode level.

Btw, I’m glad you found a solution to the other issue. I also wasn’t quite sure I understood the problem :rofl:

Ok, Iooks like I was way off. The loscil family of opcodes can do this. :+1: