Cabbage Logo
Back to Cabbage Site

Trouble implementing a dry/wet effect mix in a synthesizer


I’m finishing up a granular synthesizer I’m making with Cabbage and I just implemented a wet/dry mix slider for the reverb and delay effects and 2 problems have appeared:

  1. After implementing the mix slider and changing the signal output to the effect instruments (I’m using ntrpol to interpolate between the dry and wet signal) to make it work, the instrument has become monophonic.
  2. The instrument also outputs a “ghost” pitch whenever I release a note. I went back and noticed this was happening before this implementation but it was much much quieter than it is now.

I’m attaching here my .csd Granulera_v1.0.csd (25.4 KB)

Any help on solving these issues would be very much appreciated!

Edit: uploaded the wrong .csd at first, the correct one is here now

The tone that you are hearing is because you are not clearing your output buffers at the end of each processing cycle. The simple fix for this is:

   gaSigL = 0
   gaSigR = 0

just before the end of the last instrument in the chain. In your case instr Delay, and make sure it’s outside the if/then block. As for the stereo issue, I can’t actually check this because I only have access to onboard speakers at the moment. So I literally can’t tell what’s coming from where. Is it just the delay instrument that is mixing to mono?

Of course I forgot that, thanks!

There’s no stereo issue actually, I meant monophonic as in the instrument is not behaving polyphonically anymore (it only outputs one note at a time) - I had the “Grains” instrument outputting signal before this and it worked polyphonically

You need to be careful about using global variables when you want full polyphony. Each new instance of an instrument can clear the output of the previous one. Personally I abhor the use of global variable in all programming languages. But my feeling towards them won’t help you :laughing:

What might help you in this case are audio channels. Your instrument suffers from the same thing as the one posted here:

instr 1
    kEnv madsr .1, .2, .6, .4
    aOut vco2 p5, p4
    gaSig = aOut*kEnv

instr 2
    out gaSig, gaSig
    gaSign = 0

Each new instance will cause the previous gaSig to be overwritten, thus removing any chance of polyphony. The following instrument however uses chmnix to mix the signals of all instances. Note we still have to 0 the output afterwards.

;instrument will be triggered by keyboard widget
instr 1
    kEnv madsr .1, .2, .6, .4
    aOut vco2 p5, p4
    chnmix aOut*kEnv, "signal"

instr 2
    a1 chnget "signal"
    out a1, a1
    chnclear "signal"

Ah, makes sense, this is exactly what I needed! Thank you so much for the help again.