On 11/22/20, yoann.le.bor...@gmail.com <yoann.le.bor...@gmail.com> wrote: > In a non functional language, I would have used a classic if/then/else > but, as specified in the faust manual: > "WARNING: since select2 is strict (always evaluating both branches), the > resulting if does not have the usual "lazy" semantic of the C if form, > and thus cannot be used to protect against forbidden computations like > division-by-zero for instance."
I'm actually not sure this is correct; perhaps it's out of date? select2 compiles to the ternary operator in C (?:), which I believe is lazy in the sense of only evaluating the relevant branch. The only complication is that faust is 'eager' in evaluating expressions at compile-time, where it can, which makes this tricky to test. For this reason, select2 seems eager (i.e. it seems to eval both branches) when you test it with constant expressions. process = select2(0, 1/0, 1); // divide by zero error at compile time process = select2(1, 1/0, 1); // the same process = select2(0, 1/_, 1); // NaN at runtime process = select2(1, 1/_, 1); // fine; 1 at runtime The latter two evaluate a function on faust's input. When testing in faust2plot, this is set to an impulse of 1 for the first sample and zeroes thereafter. But doing it this way means that faust won't try to precompute the value and get the divide by zero at compile-time. So I believe your waveshaping should just work. I say go ahead and try it. Hope that helps, James _______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users