summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libaf/af_tools.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libaf/af_tools.c b/libaf/af_tools.c
index 11eea2b49e..bd36a243f8 100644
--- a/libaf/af_tools.c
+++ b/libaf/af_tools.c
@@ -78,3 +78,15 @@ inline int af_test_output(struct af_instance_s* af, af_data_t* out)
}
return AF_OK;
}
+
+/* Soft clipping, the sound of a dream, thanks to Jon Wattes
+ post to Musicdsp.org */
+inline float af_softclip(float a)
+{
+ if (a >= M_PI/2)
+ return 1.0;
+ else if (a <= -M_PI/2)
+ return -1.0;
+ else
+ return sin(a);
+}