'Turn off' a Gen subpatch?
Hi. I have a Gen patch where I have either 3 Sawtooth oscillators or a Square wave oscillator. A param comes into in 3
to determine which is used. The problem I have is that even though I thought the gate
object would prevent the squareOsc
from using any cpu, it still does.

If I disconnect the connection between the squareOsc
and the *
object below, the squareOsc
does not add to the cpu overhead. I tried using a switch
object to choose between the saws and the square wave but still the square wave adds to the cpu.
Is there a way to 'switch off' the square wave oscillator or am I thinking totally along the wrong lines?
Cheers
Thanks Raja,
I'll take another look. :-)
in gen~ patching there is simply no way to do this.
if an object / subpatch whatever is not connected to anything at all in the signal chain, the compiler will simply ignore it and it will not incur any cpu. but as long as something is connected in the chain, it will be compiled and processed no matter what gates / selectors / etc you use. (this is unlike latching in reaktor-core, for example).
this is a big feature request for gen~ patching and cycling 74 know about it.
however, all is not lost. to control cpu usage in gen~ you need to use GenExpr language in a codebox. in an if/else block, cpu usage is on or off depending on if the function / code is 'called' or not. (there are caveats if you are using data / buffer, but that is a longer story).
myoutput = 0; // initialise
if (mydecision == 1) {
myoutput = somethingveryexpensive;
} else {
myoutput = somethingverycheap;
}
out1 = myoutput * afunvariable;
...you get the idea. the cool thing is, "somethingveryexpensive" could be a '.gendsp' abstraction in the search path, but i usually just use it with a declared function at the top of the gen codebox file.
there is a (very simple) example of such an if/else block in the filters i posted as a zip file in this thread:
https://cycling74.com/forums/collaborate-on-building-reaktor-filters-in-gen/
if/else in GenExpr really works. i have made very complex multiple nested if/else blocking and got away with it very well (https://www.ableton.com/packs/dub-machines/ for your reference).
GenExpr is remarkably easy. it is literally like typing gen~ patches. syntax very forgiving. really worth learning.
hth.
That's interesting, thank you. Is it only possible to block cpu usage for code inside a code box? I do prefer drawing networks in gen~. I suppose I could copy the code and paste it into a code box, but it does not seem the best way to manage a design.
Hi STKR,
It should come as no surprise to you when I tell you that it worked! Using a codebox with a simple if else solved my cpu woes.
Thanks a million
Dave
Thanks Raja.
That's two things I've learnt today