summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/sig/sig.c128
-rw-r--r--src/libs/sig/sig.h21
2 files changed, 149 insertions, 0 deletions
diff --git a/src/libs/sig/sig.c b/src/libs/sig/sig.c
index d260006..2c3452c 100644
--- a/src/libs/sig/sig.c
+++ b/src/libs/sig/sig.c
@@ -112,6 +112,134 @@ float sig_output(sig_t *sig, unsigned ticks_ms)
}
+/* What follows is a bunch of convenience wrappers around the bundled
+ * sig_ops implementations. One may call sig_new() directly supplying
+ * the sig_ops_$op and appropriate va_args, which is important for
+ * supporting custom caller-implemented sig_ops in particular.
+ * However, it's desirable to use these helpers when possible, as
+ * they offer type checking of the arguments, as well less verbosity.
+ */
+
+sig_t * sig_new_abs(sig_t *x)
+{
+ return sig_new(&sig_ops_abs, x);
+}
+
+
+sig_t * sig_new_add(sig_t *a, sig_t *b)
+{
+ return sig_new(&sig_ops_add, a, b);
+}
+
+
+sig_t * sig_new_ceil(sig_t *x)
+{
+ return sig_new(&sig_ops_ceil, x);
+}
+
+
+sig_t * sig_new_clamp(sig_t *x, sig_t *min, sig_t *max)
+{
+ return sig_new(&sig_ops_clamp, x, min, max);
+}
+
+
+sig_t * sig_new_const(float x)
+{
+ return sig_new(&sig_ops_const, x);
+}
+
+
+sig_t * sig_new_div(sig_t *a, sig_t *b)
+{
+ return sig_new(&sig_ops_div, a, b);
+}
+
+
+sig_t * sig_new_expand(sig_t *x)
+{
+ return sig_new(&sig_ops_expand, x);
+}
+
+
+sig_t * sig_new_floor(sig_t *x)
+{
+ return sig_new(&sig_ops_floor, x);
+}
+
+
+sig_t * sig_new_inv(sig_t *x)
+{
+ return sig_new(&sig_ops_inv, x);
+}
+
+
+sig_t * sig_new_lerp(sig_t *a, sig_t *b, sig_t *t)
+{
+ return sig_new(&sig_ops_lerp, a, b, t);
+}
+
+
+sig_t * sig_new_max(sig_t *a, sig_t *b)
+{
+ return sig_new(&sig_ops_max, a, b);
+}
+
+
+sig_t * sig_new_min(sig_t *a, sig_t *b)
+{
+ return sig_new(&sig_ops_min, a, b);
+}
+
+
+sig_t * sig_new_mult(sig_t *a, sig_t *b)
+{
+ return sig_new(&sig_ops_mult, a, b);
+}
+
+
+sig_t * sig_new_neg(sig_t *x)
+{
+ return sig_new(&sig_ops_neg, x);
+}
+
+
+sig_t * sig_new_pow(sig_t *x, sig_t *y)
+{
+ return sig_new(&sig_ops_pow, x, y);
+}
+
+
+sig_t * sig_new_rand(void)
+{
+ return sig_new(&sig_ops_rand);
+}
+
+
+sig_t * sig_new_round(sig_t *x)
+{
+ return sig_new(&sig_ops_round, x);
+}
+
+
+sig_t * sig_new_scale(sig_t *x, sig_t *min, sig_t *max)
+{
+ return sig_new(&sig_ops_scale, x, min, max);
+}
+
+
+sig_t * sig_new_sin(sig_t *hz)
+{
+ return sig_new(&sig_ops_sin, hz);
+}
+
+
+sig_t * sig_new_sub(sig_t *a, sig_t *b)
+{
+ return sig_new(&sig_ops_sub, a, b);
+}
+
+
#ifdef TESTING
#include <stdio.h>
diff --git a/src/libs/sig/sig.h b/src/libs/sig/sig.h
index 3d61cfc..e905ba0 100644
--- a/src/libs/sig/sig.h
+++ b/src/libs/sig/sig.h
@@ -18,6 +18,27 @@ sig_t * sig_ref(sig_t *sig);
sig_t * sig_free(sig_t *sig);
float sig_output(sig_t *sig, unsigned ticks_ms);
+sig_t * sig_new_abs(sig_t *x);
+sig_t * sig_new_add(sig_t *a, sig_t *b);
+sig_t * sig_new_ceil(sig_t *x);
+sig_t * sig_new_clamp(sig_t *x, sig_t *min, sig_t *max);
+sig_t * sig_new_const(float x);
+sig_t * sig_new_div(sig_t *a, sig_t *b);
+sig_t * sig_new_expand(sig_t *x);
+sig_t * sig_new_floor(sig_t *x);
+sig_t * sig_new_inv(sig_t *x);
+sig_t * sig_new_lerp(sig_t *a, sig_t *b, sig_t *t);
+sig_t * sig_new_max(sig_t *a, sig_t *b);
+sig_t * sig_new_min(sig_t *a, sig_t *b);
+sig_t * sig_new_mult(sig_t *a, sig_t *b);
+sig_t * sig_new_neg(sig_t *x);
+sig_t * sig_new_pow(sig_t *x, sig_t *y);
+sig_t * sig_new_rand(void);
+sig_t * sig_new_round(sig_t *x);
+sig_t * sig_new_scale(sig_t *x, sig_t *min, sig_t *max);
+sig_t * sig_new_sin(sig_t *hz);
+sig_t * sig_new_sub(sig_t *a, sig_t *b);
+
extern sig_ops_t sig_ops_const;
extern sig_ops_t sig_ops_rand;
extern sig_ops_t sig_ops_sin;
© All Rights Reserved