You should set the inputs and outputs separately, nchls/nchnls_i
. And I’m afraid they should always be grouped in pairs. Check out this post. Here is a simple sidechain compressor example that @Gerbo and I used to test this feature a few years back. Hopefully it still works
(I see some of the identifiers need updating to camelCase, but it should still work Ok).
<Cabbage>
#define SLIDER_APPEARANCE trackercolour("DarkSlateGrey"), textcolour("black")
form caption("Sidecomp") size(440,530), pluginid("FSR0") style("legacy"), sidechain(2)
image bounds(0, 0, 440, 228), outlinethickness(6), , colour(128, 128, 128, 255) filmstrip("", 0, "vertical")
rslider bounds( 80, 10, 70, 70), channel("att"), text("Attack"), range(0,1,0.01,0.5), $SLIDER_APPEARANCE
rslider bounds(150, 10, 70, 70), channel("rel"), text("Release"), range(0,1,0.05,0.5), $SLIDER_APPEARANCE
rslider bounds(220, 10, 70, 70), channel("ratio"), text("Ratio"), range(1,300,10000,0.5), $SLIDER_APPEARANCE
rslider bounds(290, 10, 70, 70), channel("look"), text("Lookahead"), range(0,1,0.01,0.5), $SLIDER_APPEARANCE
rslider bounds(360, 10, 70, 70), channel("gain"), text("Gain"), range(-36,36,0), $SLIDER_APPEARANCE
rslider bounds(82, 88, 70, 70), channel("LowKnee"), text("LowKnee"), range(0, 120, 60, 0.5, 0.001), $SLIDER_APPEARANCE textcolour(0, 0, 0, 255) trackercolour(47, 79, 79, 255)
rslider bounds(220, 88, 70, 70), channel("HighKnee"), text("HighKnee"), range(0, 120, 60, 0.5, 0.001), $SLIDER_APPEARANCE textcolour(0, 0, 0, 255) trackercolour(47, 79, 79, 255)
label bounds(-24, 146, 420, 13), text("Soft Knee"), fontcolour(0, 0, 0, 255)
csoundoutput bounds(2, 230, 432, 295)
checkbox bounds(198, 174, 213, 40), channel("bypass"), text("Send sidechain to output")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n
</CsOptions>
<CsInstruments>
nchnls = 2
nchnls_i = 4 ;main inputs(chan 1, chan 2) and sidechain(chan 3, chan4)
ksmps = 32
0dbfs = 1
instr 1
print nchnls
print nchnls_i
a1 inch 1 ;main in left
a2 inch 2 ;main in right or sidechain input if logic is running in dual mono
a3, a4 init 0 ;declare variables for sidechain inputs
if nchnls_i == 3 then
a3 inch 3 ;sidechain left
endif
if nchnls_i == 4 then
a3 inch 3
a4 inch 4 ;sidechain right
endif
kthresh = -1000000000
kLowKnee chnget "LowKnee"
kHighKnee chnget "HighKnee"
katt chnget "att"
krel chnget "rel"
kratio chnget "ratio"
kgain chnget "gain"
klook = 0.00
klook init 0.00
if changed(klook)==1 then
reinit REINIT
endif
REINIT:
if nchnls_i == 2 then
aC_L compress a1, a2, kthresh, kLowKnee, kHighKnee, kratio, katt, krel, i(klook) ; compress mono
aC_R compress a1, a2, kthresh, kLowKnee, kHighKnee, kratio, katt, krel, i(klook)
elseif nchnls_i == 4 then
aC_L compress a1, a3, kthresh, kLowKnee, kHighKnee, kratio, katt, krel, i(klook) ; compress stereo
aC_R compress a2, a4, kthresh, kLowKnee, kHighKnee, kratio, katt, krel, i(klook)
endif
aC_L *= ampdb(kgain)
aC_R *= ampdb(kgain)
if nchnls_i == 1 then
outs aC_L, aC_L
elseif nchnls_i == 2 then
outs aC_L, aC_R
elseif nchnls_i == 4 then
if chnget:k("bypass") == 0 then
outs aC_L, aC_R
else
outs a3, a4
endif
else
outs aC_L, aC_R
endif
endin
</CsInstruments>
<CsScore>
i1 0 [60*60*24*7]
f0 z
</CsScore>
</CsoundSynthesizer>