aboutsummaryrefslogtreecommitdiff
path: root/sc4pd/source/support.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'sc4pd/source/support.hpp')
-rw-r--r--sc4pd/source/support.hpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/sc4pd/source/support.hpp b/sc4pd/source/support.hpp
index 34e260a..6b51f2b 100644
--- a/sc4pd/source/support.hpp
+++ b/sc4pd/source/support.hpp
@@ -34,16 +34,18 @@
*/
+#ifndef _SUPPORT_HPP
+#define _SUPPORT_HPP
+
#include <flext.h>
-//#include <flsupport.h>
#include "SC_PlugIn.h"
-//#include <strings.h>
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 406)
#error You need at least FLEXT version 0.4.6
#endif
+
/* for argument parsing */
bool sc_add (flext::AtomList a);
float sc_getfloatarg (flext::AtomList a,int i);
@@ -65,6 +67,32 @@ bool sc_ar(flext::AtomList a);
int32 timeseed();
+/* cubic interpolation from DelayUGens.cpp */
+inline float cubicinterp(float x, float y0, float y1, float y2, float y3)
+{
+ // 4-point, 3rd-order Hermite (x-form)
+ float c0 = y1;
+ float c1 = 0.5f * (y2 - y0);
+ float c2 = y0 - 2.5f * y1 + 2.f * y2 - 0.5f * y3;
+ float c3 = 0.5f * (y3 - y0) + 1.5f * (y1 - y2);
+
+ return ((c3 * x + c2) * x + c1) * x + c0;
+}
+
+/* feedback calculation from DelayUGens.cpp */
+inline float CalcFeedback(float delaytime, float decaytime)
+{
+ if (delaytime == 0.f) {
+ return 0.f;
+ } else if (decaytime > 0.f) {
+ return exp(log001 * delaytime / decaytime);
+ } else if (decaytime < 0.f) {
+ return -exp(log001 * delaytime / -decaytime);
+ } else {
+ return 0.f;
+ }
+}
+
/* this is copied from thomas grill's xsample:
xsample - extended sample objects for Max/MSP and pd (pure data)
@@ -95,3 +123,4 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define SIGFUN(FUN) &thisType::FUN
+#endif