Cabbage Logo
Back to Cabbage Site

Simple poscil instrument with reverb note issues

I found an issue with playing simple oscillators when run into a freeverb reverb unit.

When I play notes on my keyboard, between new notes there is a small burst of static.

When I plug in this instrument CSD into the Cabbage Reverb CSD- there isn’t this problem?

I am sure that I am doing something wrong somewhere… But I can’t find it.

Here is my CSD:

<Cabbage>
form caption("TEST") size(400, 300), colour(58, 110, 182), pluginID("def1")
keyboard bounds(8, 158, 381, 95)

groupbox bounds(88, 42, 215, 89) text("ADSR"){ 
rslider bounds(1, 25, 40, 64) channel("_a") range(.01, 1, 0.1, 1, 0.001) text("A") 
rslider bounds(40, 25, 40, 64) channel("_d") range(.01, 1, 0.2, 1, 0.001) text("D") 
rslider bounds(80, 25, 40, 64) channel("_s") range(.01, 1, 0.3, 1, 0.001) text("S") 
rslider bounds(120, 25, 40, 64) channel("_r") range(.01, 1, 0.4, 1, 0.001) text("R") 
button bounds(160, 32, 50, 32) channel("reverb") text("off", "on") value(0)
label bounds(160, 75, 50, 10) text("reverb")
}

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

massign 0,0
massign 1,2

gaOut init 0

instr 1
gka chnget "_a"
gkd chnget "_d"
gks chnget "_s"
gkr chnget "_r"
gkRevBool chnget "reverb"
endin

instr 2
aEnv madsr i(gka), i(gkd), i(gks), i(gkr)
aOut poscil p5, p4
if (gkRevBool == 0) then
outs aOut*aEnv*.5, aOut*aEnv*.5
else
gaOut = aOut*aEnv*.5
endif
endin

instr 99
aL, aR freeverb gaOut, gaOut, .9, 1
outs aL, aR
clear gaOut
endin

</CsInstruments>
<CsScore>
i 1 0 3600  ;Read in widget values
i 99 0 3600  ;Reverb instrument

</CsScore>
</CsoundSynthesizer>

UPDATE: Used VINCR to accumulate the global audio… fixed. Forgot about polyphony…

You could also send signals around on named channels, which can be used internally in an orchestra. For example:

instr 1
a1 oscil 1, 100
chnset a1 "instr1"
endin

instr 2
aSig chnget "instr1"
outs aSig, aSig
endin

I find this approach makes my code easier to read afterwards, but the use of global variables is tried and trusted. One approach is no better than the other I’d say.

Didn’t realise we could also use chnset/get at audio rate! Thanks for tip!

So far there looks like 3 ways to route audio within CSD files:

  • global a rate variable
  • Zak bus opcodes
  • chnset/get opcodes

Just depends on personal preference?

We can add the connect opcode to the list too, but I don’t think you can dynamically alter the graph.