changeset 14621:0293cab15c03

af_softclip
author alex
date Mon, 31 Jan 2005 11:34:49 +0000
parents b9a05a395726
children 637fbaa8f56c
files libaf/af_tools.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_tools.c	Mon Jan 31 11:22:11 2005 +0000
+++ b/libaf/af_tools.c	Mon Jan 31 11:34:49 2005 +0000
@@ -78,3 +78,15 @@
   }
   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);
+}