hybrid wave folding (even if you can't help, you may enjoy this patch)

back's icon

Ive been playing around a lot with writing expressions to fill buffers with with simple synthesis voices (sine, square,tri,saw) also adding wave fold to these expressions, Ive had this idea that Im calling hybrid wavefold (not sure if the method already exists).
Anyway the idea is, if you have for example a triangle wave and take its amplitude above the wave fold threshold, a different waveform folds back, for example a sine.
At present I using a [switch] object achieve this but this gives a type of triangle/square/sine waveform (which kinda sounds interesting).
what I really want is the polarised sine waves 1. to 1. and -1. to -1. points to be aligned with the triangle waves folding and unfolding points.
I really want to try and keep this as a single expression as I build my own non commercial modular synths (using arduinos) and I would really like to build this as a oscillator function and kinda want to avoid if statements to keep the code more elegant.
Thanks in advance
Lee

hybrid wavefold.maxpat
Max Patch

Rick's icon

Here's one way to put the switch and if together in an expr statement. I'll leave it to you to combine the three expr statements into a single one.

Max Patch
Copy patch and select New From Clipboard in Max.

back's icon

Hi Rick, thanks so much for that, you really helped me to write if statements in [expr] there, that will come in so useful in many patches in the future.
Just had a little go at making it into one expression but failed so far.
Its getting a bit late here in the UK so my brain isn't as bright as it can be.
Will have a better go with it tomorrow.
Thanks so much for this
Lee