Codebox efficiency / for loop and if

Lume's icon

I'm new to gen and not a very good programmer, so was wondering if anyone would look at my patch
and see if anything could be done about the efficiency of [gen~] in this patch.

The patch is an attempt to imitate stochastic synthesis, and uses [codebox] to write sample values in a
triangular shape to a Data object. My guess is I'm missing something with regards to for() loops and
if(), but it could be something else.

Average audio CPU usage shows 8.81% with gen taking 90.5% of that.

Any help appreciated. Thanks.

stoch-08C.zip
zip
Lume's icon

Thanks, Raja. Super helpful, I was wondering about how often the for loop is running.
You're right about changing every phase of the wave too, otherwise it leads to distorted effects which seems to be the kind of sound-world covered by this release:
https://cycling74.com/tools/db-bounce-chaotic-triangle-wave-oscillator-bank/

btw, to get audio going you need to start the Clock, move some params around and choose a fundamental... maybe.
I've change the way the patch works and UI elements have been moving around, so might not be clear
how to get sound on first use!

Anyway, thanks again, much appreciated!

Lume's icon

Average 3.36% CPU. Booyah.
Raja, you legend.

Stoch-8C.zip
zip
fram hamill's icon

i really find this patch interesting. quick question, what is preventing me from seeing all the objects and connections. it seems like a phantom patch! would like to dissect it and learn more.

Lume's icon

It's in Presentation Mode, which hides the connections.
Control + alt + E on PC to switch to edit mode.
Command + alt + E on Mac (from memory).

Lume's icon

Attached the latest version. Has some improvements.

Stoch-08C.zip
zip
Asher's icon

Really impressive patch, great job.

Lume's icon

I did an update. You can draw the oscillator shape in the function (though still restricted to triangle type waves).
And the controls are simpler.
Thanks for the kind words.

Stoch11.zip
zip
fram hamill's icon

really quite great sounding

Lume's icon

Cheers. I am quite happy with it.
I recommend opening 3 or 4 instances, you can get quite a thick sound.
I'll probably make a [poly~] version at some point.