Cabbage Logo
Back to Cabbage Site

Multiple instrument inputs

I usually build my plugins with either mono-in/stereo-out or stereo-in/stereo-out. That works great as either an instrument plugin or on a stereo bus.

But what if I want several mono inputs and stereo output? I’d like to manage the mono signals in the plug-in for muting, side-chaining, or whatever. How should I think about this in Logic?

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 :crossed_fingers: (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>

That all makes sense. What I’m hung up on is how Logic will interface with this. Plugins seems to expect either a mono or stereo input, but I’m probably missing something.

I guess a side chain input is available in Logic, but I’m thinking about a case where I have all inputs available for processing.

Maybe I create a multi-channel bus (quad, 5.1, 7.1 or whatever) and use the plug-in on that bus, outputting to stereo? That seems kludgey, but might work.

You can set any arbitrary number of inputs/outputs as you like. Different hosts will deal with these in their own way. But under the hood it should all work the same way. In reaper, for example, I don’t think I’ve ever seen the term sidechain applied anywhere. You simply select the inputs you wish to access and do as you wish with them. I’m not sure about Logic, but I assume it can handle any number of inputs just as well. Give it a whirl and let us know your findings :+1: FWIW, most of the work done on the sidechain feature was with done with Logic in mind so it should behave pretty well there.