How do I use Gen Objects to implement the features in CodeBox?

david reason's icon

I've written an AD Envelope in CodeBox, which essentially functions as a smoothing/easing effect. However, when I try to recreate this using built-in Gen objects, I just can't seem to get it right. Could anyone help me figure this out?

Graham Wakefield's icon

The nearest thing to patching an if() statement is using the switch operator.

You can start with the `history y`, `history target` and history easing objects, then patch the sequence from there.

For example, the y + (target - y)*easing can be patched up with a - , then a *, then a +. Don't send that back to the history y yet though -- that comes at the end.

Next get the first condition expression, routing in 1 to > 0, and routing the history target into == 0, then both those conditions into an && operator.

That && output is the condition you will send to switch 1 whose other input is from the history target. And so on for updating easing and y. Again, still not yet routed back to the history.

Only after the final value of y is send to out 1, then also route this back to the input of history y.

--

Another way of thinking about this is to work backwards from the final outputs (`out 1`, but also the inputs to the history objects). Work backwards up the code to add expressions, switches, latches etc. to populate these.

For example, starting with the input to history easing, you can see there's one possible input which could be a switch 2/samplerate, where the condition is y>0.99 and the "else" input of this switch is where you continue up the code. The next assignment back, which will go into this "else" input, is in the other if() block condition -- here again you can use switch 100/samplerate with the && condition, and the "else" input is where you continue backwards. There are no other assignments to "easing" in the code, so this else input will connect to the history easing output.

Do the same for the history target and history y , and you have the full patch.

--

Hopefully this gives an idea of how to do it!

david reason's icon

Graham Wakefield, thank you for your reply! I've been a bit busy lately, but I've also figured out how to build it. Since I've been a Reaktor user for a long time, I tend to think in terms of Core event-based structures. Of course, both technologies are excellent.

Max Gen Building
Reaktor Core Building