Hi Florian!

Le 22/11/2020 à 13:03, Florian Hülsmann a écrit :
Hi Yoann,

You can simply multiply the functions with their conditions:

f(x) = (x < LowerThreshold) * LowerSignal(x) + ((x >= LowerThreshold)
& (x <= UpperThreshold)) * LinearSignal(x) + (x > UpperThreshold) *
UpperSignal(x)
process = f

Hope this works for you!

Flo

Unfortunately, this does not work as whatever the signal is, there is always an attemp to compute log(0) which set the DSP out of order (at least in FaustIDE).


Hi James!

Le 22/11/2020 à 13:04, James Mckernon a écrit :
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

I've tested with a select3 and got it working. While, as with Florian suggestion, log(0) seems to be computed it is handled transparently and for my personal curiosity I'll also try to use ba.selectoutn and look under the hood how both are implemented in C.

Thanks a lot to both of you!
Yoann






_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to