On 11/25, Oleg Nesterov wrote:
>
> Thanks for looking at this!

Yes, and this reminds me another discussion on discord ;)

To remind, ma.zc() is wrong in that it can't detect the crossing if the input
is zero in between.

So how about the patch below?

This change is not compatible too, but I guess we can treat it as a bugfix?

I think the new ba.tAndH() makes sense regardless, for example we can do

        zc_threshold(t) = ba.tAndH(abs >= t) <: *(mem) < 0;

which reports the "significant" changes from -t to +t or vice versa.

Oleg.
---

diff --git a/basics.lib b/basics.lib
index ed3e9c5..d150872 100644
--- a/basics.lib
+++ b/basics.lib
@@ -1777,8 +1777,22 @@ latch(trig, x) = x * s : + ~ *(1-s) with { s = (trig' <= 
0) & (trig > 0); };
 //----------------------------------------------------------------
 declare sAndH author "Romain Michon";
 
-sAndH(trig) = select2(trig,_,_) ~ _;
+sAndH(trig) = select2(trig) ~ _;
 
+//--------------------------`(ba.)tAndH`-------------------------------
+// Test And Hold: "records" the input when pred(input) is true, outputs a 
frozen value otherwise.
+//
+// #### Usage
+//
+// ```
+// _ : tAndH(pred) : _
+// ```
+//
+// Where:
+//
+// * `pred`: predicate to test the input
+//----------------------------------------------------------------
+tAndH(pred) = _ <: pred,_ : sAndH;
 
 //--------------------------`(ba.)downSample`-------------------------------
 // Down sample a signal. WARNING: this function doesn't change the
diff --git a/maths.lib b/maths.lib
index aa92b11..9f04037 100644
--- a/maths.lib
+++ b/maths.lib
@@ -50,6 +50,7 @@ closed source license or any other license if you decide so.
 ************************************************************************/
 
 // This library contains platform specific constants 
+ba = library("basics.lib");
 pl = library("platform.lib");
 ma = library("maths.lib"); // for compatible copy/paste out of this file
 
@@ -794,5 +795,4 @@ nextpow2(x) = ceil(log(x)/log(2.0));
 // _ : zc : _
 // ```
 //-----------------------------------------------------------------------------
-zc(x) = x * x' < 0;
-
+zc = ba.tAndH(!=(0)) <: *(mem) < 0;



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

Reply via email to