aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules++/DSPI.h59
-rw-r--r--modules++/DSPIcomplex.h70
-rw-r--r--modules++/DSPIfilters.h206
-rw-r--r--modules++/biquadseries~.cc6
-rw-r--r--modules++/blosc~.cc210
-rw-r--r--modules++/filterortho~.cc6
-rw-r--r--modules++/filters.h36
-rw-r--r--modules/bdiag~.c26
-rw-r--r--modules/bwin~.c20
-rw-r--r--modules/cmath~.c58
-rw-r--r--modules/diag~.c14
-rw-r--r--modules/dwt~.c30
-rw-r--r--modules/dynwav~.c32
-rw-r--r--modules/extlib_util.h33
-rw-r--r--modules/fdn~.c8
-rw-r--r--modules/filters.h36
-rw-r--r--modules/lattice~.c2
-rw-r--r--modules/permut~.c20
-rw-r--r--modules/ramp~.c2
-rw-r--r--modules/ratio.c4
-rw-r--r--modules/resofilt~.c72
-rw-r--r--modules/sbosc~.c48
-rw-r--r--modules/scrollgrid1D~.c28
-rw-r--r--modules/statwav~.c22
-rw-r--r--modules/tabreadmix~.c40
-rw-r--r--modules/xfm~.c2
26 files changed, 584 insertions, 506 deletions
diff --git a/modules++/DSPI.h b/modules++/DSPI.h
index d9e2acf..283e848 100644
--- a/modules++/DSPI.h
+++ b/modules++/DSPI.h
@@ -1,3 +1,6 @@
+
+#include "m_pd.h"
+
#ifndef DSPI_h
#define DSPI_h
@@ -7,10 +10,60 @@
// test if floating point number is denormal
-#define DSPI_IS_DENORMAL(f) (((*(unsigned int *)&(f))&0x7f800000) == 0)
+
+#if defined(__i386__) || defined(__x86_64__) // Type punning code:
+
+#if PD_FLOAT_PRECISION == 32
+
+typedef union
+{
+ unsigned int i;
+ t_float f;
+} t_dspiflint;
+
+static inline int DSPI_IS_DENORMAL(t_float f)
+{
+ t_dspiflint pun;
+ pun.f = f;
+ return ((pun.i[1] & 0x7f800000) == 0);
+}
// test if almost denormal, choose whichever is fastest
-#define DSPI_IS_ALMOST_DENORMAL(f) (((*(unsigned int *)&(f))&0x7f800000) < 0x08000000)
+static inline int DSPI_IS_ALMOST_DENORMAL(t_float f)
+{
+ t_dspiflint pun;
+ pun.f = f;
+ return ((pun.i[1] & 0x7f800000) < 0x08000000);
+}
+
+#elif PD_FLOAT_PRECISION == 64
+
+typedef union
+{
+ unsigned int i[2];
+ t_float f;
+} t_dspiflint;
+
+static inline int DSPI_IS_DENORMAL(t_float f)
+{
+ t_dspiflint pun;
+ pun.f = f;
+ return ((pun.i[1] & 0x7ff00000) == 0);
+}
+
+static inline int DSPI_IS_ALMOST_DENORMAL(t_float f)
+{
+ t_dspiflint pun;
+ pun.f = f;
+ return ((pun.i[1] & 0x7ff00000) < 0x10000000);
+}
+
+#endif // endif PD_FLOAT_PRECISION
+#else // if not defined(__i386__) || defined(__x86_64__)
+#define DSPI_IS_DENORMAL(f) 0
+#endif // end if defined(__i386__) || defined(__x86_64__)
+
+
//#define DSPI_IS_ALMOST_DENORMAL(f) (fabs(f) < 3.e-34)
-#endif
+#endif // end ifndef DSPI_h
diff --git a/modules++/DSPIcomplex.h b/modules++/DSPIcomplex.h
index ad3e041..5ce4b60 100644
--- a/modules++/DSPIcomplex.h
+++ b/modules++/DSPIcomplex.h
@@ -28,31 +28,31 @@ class DSPIcomplex
{
public:
inline DSPIcomplex() {_r = _i = 0;}
- inline DSPIcomplex(const float &a, const float &b) {setCart(a, b);}
- inline DSPIcomplex(const float &phasor) {setAngle(phasor);}
+ inline DSPIcomplex(const t_float &a, const t_float &b) {setCart(a, b);}
+ inline DSPIcomplex(const t_float &phasor) {setAngle(phasor);}
- inline void setAngle(const float &angle) {_r = cos(angle); _i = sin(angle);}
- inline void setPolar(const float &phasor, const float &norm)
+ inline void setAngle(const t_float &angle) {_r = cos(angle); _i = sin(angle);}
+ inline void setPolar(const t_float &phasor, const t_float &norm)
{_r = norm * cos(phasor); _i = norm * sin(phasor);}
- inline void setCart(const float &a, const float &b) {_r = a; _i = b;}
+ inline void setCart(const t_float &a, const t_float &b) {_r = a; _i = b;}
- inline const float& r() const {return _r;}
- inline const float& i() const {return _i;}
+ inline const t_float& r() const {return _r;}
+ inline const t_float& i() const {return _i;}
- inline float norm2() const {return _r*_r+_i*_i;}
- inline float norm() const {return sqrt(norm2());}
- inline void normalize() {float n = 1.0f / norm(); _r *= n; _i *= n;}
+ inline t_float norm2() const {return _r*_r+_i*_i;}
+ inline t_float norm() const {return sqrt(norm2());}
+ inline void normalize() {t_float n = 1.0f / norm(); _r *= n; _i *= n;}
inline DSPIcomplex conj() const {return DSPIcomplex(_r, -_i);}
- inline float angle() const {return atan2(_i, _r);}
+ inline t_float angle() const {return atan2(_i, _r);}
inline DSPIcomplex operator+ (const DSPIcomplex &a) const
{
return DSPIcomplex(_r + a.r(), _i + a.i());
}
- inline DSPIcomplex operator+ (float f) const
+ inline DSPIcomplex operator+ (t_float f) const
{
return DSPIcomplex(_r + f, _i);
}
@@ -60,7 +60,7 @@ class DSPIcomplex
{
return DSPIcomplex(_r - a.r(), _i - a.i());
}
- inline DSPIcomplex operator- (float f) const
+ inline DSPIcomplex operator- (t_float f) const
{
return DSPIcomplex(_r - f, _i);
}
@@ -69,18 +69,18 @@ class DSPIcomplex
{
return DSPIcomplex(_r * a.r() - _i * a.i(), _i * a.r() + _r * a.i());
}
- inline DSPIcomplex operator* (float f) const
+ inline DSPIcomplex operator* (t_float f) const
{
return DSPIcomplex(_r * f, _i * f);
}
inline DSPIcomplex operator/ (const DSPIcomplex &a) const
{
- float n_t = 1.0f / a.norm2();
+ t_float n_t = 1.0f / a.norm2();
return DSPIcomplex(n_t * (_r * a.r() + _i * a.i()), n_t * (_i * a.r() - _r * a.i()));
}
- inline DSPIcomplex operator/ (float f) const
+ inline DSPIcomplex operator/ (t_float f) const
{
- float n_t = 1.0f / f;
+ t_float n_t = 1.0f / f;
return DSPIcomplex(n_t * _r, n_t * _i);
}
@@ -89,36 +89,36 @@ class DSPIcomplex
return o << "(" << a.r() << "," << a.i() << ")";
}
- inline friend DSPIcomplex operator+ (float f, DSPIcomplex& a)
+ inline friend DSPIcomplex operator+ (t_float f, DSPIcomplex& a)
{
return(DSPIcomplex(a.r() + f, a.i()));
}
- inline friend DSPIcomplex operator- (float f, DSPIcomplex& a)
+ inline friend DSPIcomplex operator- (t_float f, DSPIcomplex& a)
{
return(DSPIcomplex(f - a.r(), - a.i()));
}
- inline friend DSPIcomplex operator/ (float f, DSPIcomplex& a)
+ inline friend DSPIcomplex operator/ (t_float f, DSPIcomplex& a)
{
return(DSPIcomplex(f,0) / a);
}
// ????
- inline friend DSPIcomplex operator* (float f, DSPIcomplex& a)
+ inline friend DSPIcomplex operator* (t_float f, DSPIcomplex& a)
{
return(DSPIcomplex(f*a.r(), f*a.i()));
}
- inline DSPIcomplex& operator *= (float f)
+ inline DSPIcomplex& operator *= (t_float f)
{
_r *= f;
_i *= f;
return *this;
}
- inline DSPIcomplex& operator /= (float f)
+ inline DSPIcomplex& operator /= (t_float f)
{
_r /= f;
_i /= f;
@@ -127,7 +127,7 @@ class DSPIcomplex
inline DSPIcomplex& operator *= (DSPIcomplex& a)
{
- float r_t = _r * a.r() - _i * a.i();
+ t_float r_t = _r * a.r() - _i * a.i();
_i = _r * a.i() + _i * a.r();
_r = r_t;
@@ -136,8 +136,8 @@ class DSPIcomplex
inline DSPIcomplex& operator /= (DSPIcomplex& a)
{
- float n_t = a.norm2();
- float r_t = n_t * (_r * a.r() + _i * a.i());
+ t_float n_t = a.norm2();
+ t_float r_t = n_t * (_r * a.r() + _i * a.i());
_i = n_t * (_i * a.r() - _r * a.i());
_r = r_t;
@@ -145,8 +145,8 @@ class DSPIcomplex
}
- float _r;
- float _i;
+ t_float _r;
+ t_float _i;
};
@@ -154,8 +154,8 @@ class DSPIcomplex
inline DSPIcomplex dspilog(DSPIcomplex a) /* complex log */
{
- float r_t = log(a.norm());
- float i_t = a.angle();
+ t_float r_t = log(a.norm());
+ t_float i_t = a.angle();
return DSPIcomplex(r_t, i_t);
}
@@ -170,22 +170,22 @@ inline DSPIcomplex dspiexp(DSPIcomplex a) /* complex exp */
inline DSPIcomplex bilin_stoz(DSPIcomplex a)
{
- DSPIcomplex a2 = a * 0.5f;
- return((1.0f + a2)/(1.0f - a2));
+ DSPIcomplex a2 = a * 0.5;
+ return((1.0 + a2)/(1.0 - a2));
}
// BILINEAR TRANSFORM digital -> analog
inline DSPIcomplex bilin_ztos(DSPIcomplex a)
{
- return ((a - 1.0f) / (a + 1.0f))*2.0f;
+ return ((a - 1.0) / (a + 1.0))*2.0;
}
// not really a complex function but a nice complement to the bilinear routines
-inline float bilin_prewarp(float freq)
+inline t_float bilin_prewarp(t_float freq)
{
- return 2.0f * tan(M_PI * freq);
+ return 2.0 * tan(M_PI * freq);
}
#endif //DSPIcomplex_h
diff --git a/modules++/DSPIfilters.h b/modules++/DSPIfilters.h
index 09268de..4fa53ea 100644
--- a/modules++/DSPIfilters.h
+++ b/modules++/DSPIfilters.h
@@ -33,9 +33,9 @@ class DSPIfilterOrtho {
inline DSPIfilterOrtho(){resetState();resetCoef();resetSCoef();}
inline ~DSPIfilterOrtho(){}
- inline void resetState(){d1A = d1B = d2A = d2B = 0.0f;}
- inline void resetCoef(){ai = ar = c0 = c1 = c2 = 0.0f;}
- inline void resetSCoef(){s_ai = s_ar = s_c0 = s_c1 = s_c2 = 0.0f;}
+ inline void resetState(){d1A = d1B = d2A = d2B = 0.0;}
+ inline void resetCoef(){ai = ar = c0 = c1 = c2 = 0.0;}
+ inline void resetSCoef(){s_ai = s_ar = s_c0 = s_c1 = s_c2 = 0.0;}
/*
* Biquad filters remarks
@@ -56,15 +56,15 @@ class DSPIfilterOrtho {
*/
// make sure freq and Q are positive and within bounds
- inline void checkBounds(float &freq, float &Q)
+ inline void checkBounds(t_float &freq, t_float &Q)
{
freq = fabs(freq);
Q = fabs(Q);
- float epsilon = .0001f; // stability guard
- float fmin = 0.0f + epsilon;
- float fmax = 0.5f - epsilon;
- float Qmin = 1.1f;
+ t_float epsilon = .0001; // stability guard
+ t_float fmin = 0.0 + epsilon;
+ t_float fmax = 0.5 - epsilon;
+ t_float Qmin = 1.1;
if (freq < fmin) freq = fmin;
if (freq > fmax) freq = fmax;
@@ -73,7 +73,7 @@ class DSPIfilterOrtho {
}
- inline void setAP(float freq, float Q) // allpass
+ inline void setAP(t_float freq, t_float Q) // allpass
{
// prototype: H(s) = (1 - 2s/Qw0 + (s/w0)^2) / (1 + 2s/Qw0 + (s/w0)^2)
@@ -83,46 +83,46 @@ class DSPIfilterOrtho {
// prewarp for bilin transfo
freq = bilin_prewarp(freq);
- float zeta = 1.0f/Q;
+ t_float zeta = 1.0/Q;
- DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0f-zeta*zeta))*freq);
- DSPIcomplex z = 1.0f / p;
+ DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0-zeta*zeta))*freq);
+ DSPIcomplex z = 1.0 / p;
setPoleZeroNormalized(p, z, DSPIcomplex(1,0));
}
- inline void setLP(float freq, float Q) // low pass
+ inline void setLP(t_float freq, t_float Q) // low pass
{
// prototype: H(s) = 1 / (1 + 2s/Qw0 + (s/w0)^2)
// the bilinear transform has 2 zeros at NY
checkBounds(freq, Q);
freq = bilin_prewarp(freq);
- float zeta = 1/Q;
+ t_float zeta = 1/Q;
- DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0f-zeta*zeta))*freq);
+ DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0-zeta*zeta))*freq);
setPoleZeroNormalized(p, DSPIcomplex(-1, 0), DSPIcomplex(1, 0));
}
- inline void setHP(float freq, float Q) // hi pass
+ inline void setHP(t_float freq, t_float Q) // hi pass
{
// prototype: H(s) = (s/w0)^2 / (1 + 2s/Qw0 + (s/w0)^2)
// the bilinear transform has 2 zeros at DC
checkBounds(freq, Q);
freq = bilin_prewarp(freq);
- float zeta = 1/Q;
+ t_float zeta = 1/Q;
- DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0f-zeta*zeta))*freq);
+ DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0-zeta*zeta))*freq);
setPoleZeroNormalized(p, DSPIcomplex(1, 0), DSPIcomplex(-1, 0));
}
- inline void setBP(float freq, float Q) // band pass (1-allpass)
+ inline void setBP(t_float freq, t_float Q) // band pass (1-allpass)
{
// prototype: 1/2 * (1 - H_allpass(z))
setAP(freq, Q);
- float h = -0.5f;
+ t_float h = -0.5;
c0 *= h;
c1 *= h;
c2 *= h;
@@ -130,46 +130,46 @@ class DSPIfilterOrtho {
}
- inline void setBR(float freq, float Q) // band reject
+ inline void setBR(t_float freq, t_float Q) // band reject
{
// prototype: H(s) = (1 - (s/w0)^2) / (1 + 2s/Qw0 + (s/w0)^2)
checkBounds(freq, Q);
// pole phasor
- DSPIcomplex z = DSPIcomplex(2.0f * M_PI * freq);
+ DSPIcomplex z = DSPIcomplex(2.0 * M_PI * freq);
// prewarp for bilin transfo
freq = bilin_prewarp(freq);
- float zeta = 1/Q;
+ t_float zeta = 1/Q;
- DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0f-zeta*zeta))*freq);
+ DSPIcomplex p = bilin_stoz(DSPIcomplex(-zeta, (1.0-zeta*zeta))*freq);
setPoleZeroNormalized(p, z, DSPIcomplex(1,0));
}
- inline void setHS(float freq, float gain) // low shelf
+ inline void setHS(t_float freq, t_float gain) // low shelf
{
// hi shelf = LP - g(LP-1)
- float Q = M_SQRT2;
+ t_float Q = M_SQRT2;
setLP(freq, Q);
- c0 -= gain * (c0 - 1.0f);
+ c0 -= gain * (c0 - 1.0);
c1 -= gain * (c1);
c2 -= gain * (c2);
}
- inline void setLS(float freq, float gain) // low shelf
+ inline void setLS(t_float freq, t_float gain) // low shelf
{
// hi shelf = HP - g(HP-1)
- float Q = M_SQRT2;
+ t_float Q = M_SQRT2;
setHP(freq, Q);
- c0 -= gain * (c0 - 1.0f);
+ c0 -= gain * (c0 - 1.0);
c1 -= gain * (c1);
c2 -= gain * (c2);
}
- inline void setEQ(float freq, float Q, float gain)// param EQ
+ inline void setEQ(t_float freq, t_float Q, t_float gain)// param EQ
{
// EQ = (1+A)/2 + (1-A)/2 AP
- float a0 = 0.5f * (1.0f + gain);
- float a1 = 0.5f * (1.0f - gain);
+ t_float a0 = 0.5 * (1.0 + gain);
+ t_float a1 = 0.5 * (1.0 - gain);
setAP(freq, Q);
c0 *= a1;
c1 *= a1;
@@ -186,8 +186,8 @@ class DSPIfilterOrtho {
ar = a.r();
ai = a.i();
- c0 = 1.0f;
- c1 = 2.0f * (a.r() - b.r());
+ c0 = 1.0;
+ c1 = 2.0 * (a.r() - b.r());
c2 = (a.norm2() - b.norm2() - c1 * a.r()) / a.i();
}
@@ -201,7 +201,7 @@ class DSPIfilterOrtho {
{
setPoleZero(a, b);
DSPIcomplex invComplexGain = ((c-a)*(c-a.conj()))/((c-b)*(c-b.conj()));
- float invGain = invComplexGain.norm();
+ t_float invGain = invComplexGain.norm();
c0 *= invGain;
c1 *= invGain;
c2 *= invGain;
@@ -212,12 +212,12 @@ class DSPIfilterOrtho {
// one channel bang
inline void Bang
(
- float &input,
- float &output
+ t_float &input,
+ t_float &output
)
{
- float d1t = ar * d1A + ai * d2A + input;
- float d2t = ar * d2A - ai * d1A;
+ t_float d1t = ar * d1A + ai * d2A + input;
+ t_float d2t = ar * d2A - ai * d1A;
output = c0 * input + c1 * d1A + c2 * d2A;
d1A = d1t;
d2A = d2t;
@@ -227,13 +227,13 @@ class DSPIfilterOrtho {
// a default s could be s = (1 - (.1)^(1/n))
inline void BangSmooth
(
- float &input, // input ref
- float &output, // output ref
- float s // smooth pole
+ t_float &input, // input ref
+ t_float &output, // output ref
+ t_float s // smooth pole
)
{
- float d1t = s_ar * d1A + s_ai * d2A + input;
- float d2t = s_ar * d2A - s_ai * d1A;
+ t_float d1t = s_ar * d1A + s_ai * d2A + input;
+ t_float d2t = s_ar * d2A - s_ai * d1A;
s_ar += s * (ar - s_ar);
s_ai += s * (ai - s_ai);
output = s_c0 * input + s_c1 * d1A + s_c2 * d2A;
@@ -247,16 +247,16 @@ class DSPIfilterOrtho {
// two channel bang
inline void Bang2
(
- float &input1,
- float &input2,
- float &output1,
- float &output2
+ t_float &input1,
+ t_float &input2,
+ t_float &output1,
+ t_float &output2
)
{
- float d1tA = ar * d1A + ai * d2A + input1;
- float d1tB = ar * d1B + ai * d2B + input2;
- float d2tA = ar * d2A - ai * d1A;
- float d2tB = ar * d2B - ai * d1B;
+ t_float d1tA = ar * d1A + ai * d2A + input1;
+ t_float d1tB = ar * d1B + ai * d2B + input2;
+ t_float d2tA = ar * d2A - ai * d1A;
+ t_float d2tB = ar * d2B - ai * d1B;
output1 = c0 * input1 + d1A * c1 + d2A * c2;
output2 = c0 * input2 + d1B * c1 + d2B * c2;
d1A = d1tA;
@@ -268,17 +268,17 @@ class DSPIfilterOrtho {
// two channel bang smooth
inline void Bang2Smooth
(
- float &input1,
- float &input2,
- float &output1,
- float &output2,
- float s
+ t_float &input1,
+ t_float &input2,
+ t_float &output1,
+ t_float &output2,
+ t_float s
)
{
- float d1tA = s_ar * d1A + s_ai * d2A + input1;
- float d1tB = s_ar * d1B + s_ai * d2B + input2;
- float d2tA = s_ar * d2A - s_ai * d1A;
- float d2tB = s_ar * d2B - s_ai * d1B;
+ t_float d1tA = s_ar * d1A + s_ai * d2A + input1;
+ t_float d1tB = s_ar * d1B + s_ai * d2B + input2;
+ t_float d2tA = s_ar * d2A - s_ai * d1A;
+ t_float d2tB = s_ar * d2B - s_ai * d1B;
s_ar += s * (ar - s_ar);
s_ai += s * (ai - s_ai);
output1 = s_c0 * input1 + d1A * s_c1 + d2A * s_c2;
@@ -296,7 +296,7 @@ class DSPIfilterOrtho {
{
// state data
- float zero = 0.0f;
+ t_float zero = 0.0;
d1A = DSPI_IS_DENORMAL(d1A) ? zero : d1A;
d2A = DSPI_IS_DENORMAL(d2A) ? zero : d2A;
@@ -310,11 +310,11 @@ class DSPIfilterOrtho {
// smooth data
- float dai = ai - s_ai;
- float dar = ar - s_ar;
- float dc0 = c0 - s_c0;
- float dc1 = c1 - s_c1;
- float dc2 = c2 - s_c2;
+ t_float dai = ai - s_ai;
+ t_float dar = ar - s_ar;
+ t_float dc0 = c0 - s_c0;
+ t_float dc1 = c1 - s_c1;
+ t_float dc2 = c2 - s_c2;
s_ai = DSPI_IS_DENORMAL(dai) ? ai : s_ai;
@@ -332,25 +332,25 @@ class DSPIfilterOrtho {
private:
// state data
- float d1A;
- float d2A;
+ t_float d1A;
+ t_float d2A;
- float d1B;
- float d2B;
+ t_float d1B;
+ t_float d2B;
// pole data
- float ai;
- float s_ai;
- float ar;
- float s_ar;
+ t_float ai;
+ t_float s_ai;
+ t_float ar;
+ t_float s_ar;
// zero data
- float c0;
- float s_c0;
- float c1;
- float s_c1;
- float c2;
- float s_c2;
+ t_float c0;
+ t_float s_c0;
+ t_float c1;
+ t_float s_c1;
+ t_float c2;
+ t_float s_c2;
};
@@ -369,22 +369,22 @@ class DSPIfilterSeries{
biquad = new DSPIfilterOrtho[numberOfSections];
}
- inline void setButterHP(float freq)
+ inline void setButterHP(t_float freq)
{
/* This member function computes the poles for a highpass butterworth filter.
* The filter is transformed to the digital domain using a bilinear transform.
* Every biquad section is normalized at NY.
*/
- float epsilon = .0001f; // stability guard
- float min = 0.0f + epsilon;
- float max = 0.5f - epsilon;
+ t_float epsilon = .0001; // stability guard
+ t_float min = 0.0 + epsilon;
+ t_float max = 0.5 - epsilon;
if (freq < min) freq = min;
if (freq > max) freq = max;
// prewarp cutoff frequency
- float omega = bilin_prewarp(freq);
+ t_float omega = bilin_prewarp(freq);
DSPIcomplex NY(-1,0); //normalize at NY
DSPIcomplex DC(1,0); //all zeros will be at DC
@@ -403,7 +403,7 @@ class DSPIfilterSeries{
}
- inline void setButterLP(float freq)
+ inline void setButterLP(t_float freq)
{
/* This member function computes the poles for a lowpass butterworth filter.
* The filter is transformed to the digital domain using a bilinear transform.
@@ -414,16 +414,16 @@ class DSPIfilterSeries{
*/
- float epsilon = .0001f; // stability guard
- float min = 0.0f + epsilon;
- float max = 0.5f - epsilon;
+ t_float epsilon = .0001; // stability guard
+ t_float min = 0.0 + epsilon;
+ t_float max = 0.5 - epsilon;
if (freq < min) freq = min;
if (freq > max) freq = max;
// prewarp cutoff frequency
- float omega = bilin_prewarp(freq);
+ t_float omega = bilin_prewarp(freq);
DSPIcomplex DC(1,0); //normalize at DC
DSPIcomplex NY(-1,0); //all zeros will be at NY
@@ -444,19 +444,19 @@ class DSPIfilterSeries{
for (int i=0; i<sections; i++) biquad[i].resetState();
}
- inline void Bang(float &input, float &output)
+ inline void Bang(t_float &input, t_float &output)
{
- float x = input;
+ t_float x = input;
for (int i=0; i<sections; i++)
{
biquad[i].Bang(x, x);
}
output = x;
}
- inline void Bang2(float &input1, float &input2, float &output1, float &output2)
+ inline void Bang2(t_float &input1, t_float &input2, t_float &output1, t_float &output2)
{
- float x = input1;
- float y = input2;
+ t_float x = input1;
+ t_float y = input2;
for (int i=0; i<sections; i++)
{
biquad[i].Bang2(x, y, x, y);
@@ -465,19 +465,19 @@ class DSPIfilterSeries{
output2 = y;
}
- inline void BangSmooth(float &input, float &output, float s)
+ inline void BangSmooth(t_float &input, t_float &output, t_float s)
{
- float x = input;
+ t_float x = input;
for (int i=0; i<sections; i++)
{
biquad[i].BangSmooth(x, x, s);
}
output = x;
}
- inline void Bang2(float &input1, float &input2, float &output1, float &output2, float s)
+ inline void Bang2(t_float &input1, t_float &input2, t_float &output1, t_float &output2, t_float s)
{
- float x = input1;
- float y = input2;
+ t_float x = input1;
+ t_float y = input2;
for (int i=0; i<sections; i++)
{
biquad[i].Bang2Smooth(x, y, x, y, s);
@@ -489,7 +489,7 @@ class DSPIfilterSeries{
private:
int sections;
DSPIfilterOrtho *biquad;
- float gain;
+ t_float gain;
};
#endif //DSPIfilters_h
diff --git a/modules++/biquadseries~.cc b/modules++/biquadseries~.cc
index 40b3aef..9a952c5 100644
--- a/modules++/biquadseries~.cc
+++ b/modules++/biquadseries~.cc
@@ -54,15 +54,15 @@ static t_int *biquadseries_perform(t_int *w)
{
- t_float *in = (float *)(w[3]);
- t_float *out = (float *)(w[4]);
+ t_float *in = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
DSPIfilterSeries* biquadseries = (DSPIfilterSeries *)(w[1]);
t_int n = (t_int)(w[2]);
t_int i;
t_float x;
// dit kan beter
- float smooth = .01;
+ t_float smooth = .01;
//1.0f - pow(.9f,1.0f/(float)(n));
for (i = 0; i < n; i++)
diff --git a/modules++/blosc~.cc b/modules++/blosc~.cc
index 8a4dd4b..9028eaf 100644
--- a/modules++/blosc~.cc
+++ b/modules++/blosc~.cc
@@ -46,14 +46,14 @@ typedef unsigned long u32;
#define L (1<<LLENGTH)
#define LMASK (L-1)
-#define WALPHA 0.1f // windowing alpha (0 = cos -> 1 = rect)
-#define CUTOFF 0.8f // fraction of nyquist for impulse cutoff
-#define NBPERIODS ((float)(L) * CUTOFF / 2.0f)
+#define WALPHA 0.1 // windowing alpha (0 = cos -> 1 = rect)
+#define CUTOFF 0.8 // fraction of nyquist for impulse cutoff
+#define NBPERIODS ((t_float)(L) * CUTOFF / 2.0)
/* sample buffers */
-static float bli[N]; // band limited impulse
-static float bls[N]; // band limited step
-static float blr[N]; // band limited ramp
+static t_float bli[N]; // band limited impulse
+static t_float bls[N]; // band limited step
+static t_float blr[N]; // band limited ramp
typedef struct bloscctl
@@ -83,17 +83,17 @@ typedef struct blosc
/* phase converters */
-static inline float _phase_to_float(u32 p){return ((float)p) * (1.0f / 4294967296.0f);}
-static inline u32 _float_to_phase(float f){return ((u32)(f * 4294967296.0f)) & ~(S-1);}
+static inline t_float _phase_to_float(u32 p){return ((t_float)p) * (1.0 / 4294967296.0);}
+static inline u32 _float_to_phase(t_float f){return ((u32)(f * 4294967296.0)) & ~(S-1);}
/* flat table: better for linear interpolation */
-static inline float _play_voice_lint(float *table, t_int *index, float frac, float scale)
+static inline t_float _play_voice_lint(t_float *table, t_int *index, t_float frac, t_float scale)
{
int i = *index;
/* perform linear interpolation */
- float f = (((1.0f - frac) * table[i]) + (table[i+1] * frac)) * scale;
+ t_float f = (((1.0 - frac) * table[i]) + (table[i+1] * frac)) * scale;
/* increment phase index if next 2 elements will still be inside table
if not there's no increment and the voice will keep playing the same sample */
@@ -105,9 +105,9 @@ static inline float _play_voice_lint(float *table, t_int *index, float frac, flo
}
/* get one sample from the bandlimited discontinuity wavetable playback syth */
-static inline t_float _get_bandlimited_discontinuity(t_bloscctl *ctl, float *table)
+static inline t_float _get_bandlimited_discontinuity(t_bloscctl *ctl, t_float *table)
{
- float sum = 0.0f;
+ t_float sum = 0.0;
int i;
/* sum all voices */
for (i=0; i<VOICES; i++){
@@ -119,18 +119,18 @@ static inline t_float _get_bandlimited_discontinuity(t_bloscctl *ctl, float *tab
/* update waveplayers on zero cross */
-static void _bang_comparator(t_bloscctl *ctl, float prev, float curr)
+static void _bang_comparator(t_bloscctl *ctl, t_float prev, t_float curr)
{
/* check for sign change */
- if ((prev * curr) < 0.0f){
+ if ((prev * curr) < 0.0){
int voice;
/* determine the location of the discontinuity (in oversampled coordiates
using linear interpolation */
- float f = (float)S * curr / (curr - prev);
+ t_float f = (t_float)S * curr / (curr - prev);
/* get the offset in the oversample table */
@@ -139,11 +139,11 @@ static void _bang_comparator(t_bloscctl *ctl, float prev, float curr)
/* determine the fractional part (in oversampled coordinates)
for linear interpolation */
- float table_frac_index = f - (float)table_index;
+ t_float table_frac_index = f - (t_float)table_index;
/* set state (+ or -) */
- ctl->c_state = (curr > 0.0f) ? 0.5f : -0.5f;
+ ctl->c_state = (curr > 0.0) ? 0.5 : -0.5;
/* steal the oldest voice */
@@ -154,7 +154,7 @@ static void _bang_comparator(t_bloscctl *ctl, float prev, float curr)
ctl->c_index[voice] = table_index;
ctl->c_frac[voice] = table_frac_index;
- ctl->c_vscale[voice] = -ctl->c_scale * 2.0f * ctl->c_state;
+ ctl->c_vscale[voice] = -ctl->c_scale * 2.0 * ctl->c_state;
}
@@ -162,20 +162,20 @@ static void _bang_comparator(t_bloscctl *ctl, float prev, float curr)
/* advance phasor and update waveplayers on phase wrap */
-static void _bang_phasor(t_bloscctl *ctl, float freq)
+static void _bang_phasor(t_bloscctl *ctl, t_float freq)
{
u32 phase = ctl->c_phase;
u32 phase_inc;
u32 oldphase;
int voice;
- float scale = ctl->c_scale;
+ t_float scale = ctl->c_scale;
/* get increment */
- float inc = freq * ctl->c_phase_inc_scale;
+ t_float inc = freq * ctl->c_phase_inc_scale;
/* calculate new phase
the increment (and the phase) should be a multiple of S */
- if (inc < 0.0f) inc = -inc;
+ if (inc < 0.0) inc = -inc;
phase_inc = ((u32)inc) & ~(S-1);
oldphase = phase;
phase += phase_inc;
@@ -205,7 +205,7 @@ static void _bang_phasor(t_bloscctl *ctl, float freq)
/* use it to initialize the new voice index and interpolation fraction */
ctl->c_index[voice] = table_index;
- ctl->c_frac[voice] = (float)table_phase / (float)phase_inc_decimated;
+ ctl->c_frac[voice] = (t_float)table_phase / (t_float)phase_inc_decimated;
ctl->c_vscale[voice] = scale;
scale = scale * ctl->c_scale_update;
@@ -221,7 +221,7 @@ static void _bang_phasor(t_bloscctl *ctl, float freq)
the second osc can reset the first osc's phase (hence it determines the pitch)
the first osc determines the waveform */
-static void _bang_hardsync_phasor(t_bloscctl *ctl, float freq, float freq2)
+static void _bang_hardsync_phasor(t_bloscctl *ctl, t_float freq, t_float freq2)
{
u32 phase = ctl->c_phase;
u32 phase2 = ctl->c_phase2;
@@ -230,12 +230,12 @@ static void _bang_hardsync_phasor(t_bloscctl *ctl, float freq, float freq2)
u32 oldphase;
u32 oldphase2;
int voice;
- float scale = ctl->c_scale;
+ t_float scale = ctl->c_scale;
/* get increment */
- float inc = freq * ctl->c_phase_inc_scale;
- float inc2 = freq2 * ctl->c_phase_inc_scale;
+ t_float inc = freq * ctl->c_phase_inc_scale;
+ t_float inc2 = freq2 * ctl->c_phase_inc_scale;
/* calculate new phases
the increment (and the phase) should be a multiple of S */
@@ -245,12 +245,12 @@ static void _bang_hardsync_phasor(t_bloscctl *ctl, float freq, float freq2)
oldphase2 = phase2;
/* update second osc */
- if (inc2 < 0.0f) inc2 = -inc2;
+ if (inc2 < 0.0) inc2 = -inc2;
phase_inc2 = ((u32)inc2) & ~(S-1);
phase2 += phase_inc2;
/* update first osc (freq should be >= freq of sync osc */
- if (inc < 0.0f) inc = -inc;
+ if (inc < 0.0) inc = -inc;
phase_inc = ((u32)inc) & ~(S-1);
if (phase_inc < phase_inc2) phase_inc = phase_inc2;
phase += phase_inc;
@@ -274,7 +274,7 @@ static void _bang_hardsync_phasor(t_bloscctl *ctl, float freq, float freq2)
u32 phase_inc_decimated = phase_inc >> LOVERSAMPLE;
u32 table_index;
u32 table_phase;
- float stepsize;
+ t_float stepsize;
/* steal the oldest voice if we have a phase wrap */
@@ -298,12 +298,12 @@ static void _bang_hardsync_phasor(t_bloscctl *ctl, float freq, float freq2)
reduce the bit depth to prevent overflow */
stepsize = _phase_to_float(((oldphase-phase) >> LOVERSAMPLE)
- + phase_inc_decimated) * (float)S;
+ + phase_inc_decimated) * (t_float)S;
/* use it to initialize the new voice index and interpolation fraction */
ctl->c_index[voice] = table_index;
- ctl->c_frac[voice] = (float)table_phase / (float)phase_inc_decimated;
+ ctl->c_frac[voice] = (t_float)table_phase / (t_float)phase_inc_decimated;
ctl->c_vscale[voice] = scale * stepsize;
scale = scale * ctl->c_scale_update;
@@ -318,28 +318,28 @@ static void _bang_hardsync_phasor(t_bloscctl *ctl, float freq, float freq2)
static t_int *blosc_perform_hardsync_saw(t_int *w)
{
- t_float *freq = (float *)(w[3]);
- t_float *freq2 = (float *)(w[4]);
- t_float *out = (float *)(w[5]);
+ t_float *freq = (t_float *)(w[3]);
+ t_float *freq2 = (t_float *)(w[4]);
+ t_float *out = (t_float *)(w[5]);
t_bloscctl *ctl = (t_bloscctl *)(w[1]);
t_int n = (t_int)(w[2]);
t_int i;
/* set postfilter cutoff */
- ctl->c_butter->setButterHP(0.85f * (*freq / sys_getsr()));
+ ctl->c_butter->setButterHP(0.85 * (*freq / sys_getsr()));
while (n--) {
- float frequency = *freq++;
- float frequency2 = *freq2++;
+ t_float frequency = *freq++;
+ t_float frequency2 = *freq2++;
/* get the bandlimited discontinuity */
- float sample = _get_bandlimited_discontinuity(ctl, bls);
+ t_float sample = _get_bandlimited_discontinuity(ctl, bls);
/* add aliased sawtooth wave */
- sample += _phase_to_float(ctl->c_phase) - 0.5f;
+ sample += _phase_to_float(ctl->c_phase) - 0.5;
/* highpass filter output to remove DC offset and low frequency aliasing */
- ctl->c_butter->BangSmooth(sample, sample, 0.05f);
+ ctl->c_butter->BangSmooth(sample, sample, 0.05);
/* send to output */
*out++ = sample;
@@ -354,20 +354,20 @@ static t_int *blosc_perform_hardsync_saw(t_int *w)
static t_int *blosc_perform_saw(t_int *w)
{
- t_float *freq = (float *)(w[3]);
- t_float *out = (float *)(w[4]);
+ t_float *freq = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
t_bloscctl *ctl = (t_bloscctl *)(w[1]);
t_int n = (t_int)(w[2]);
t_int i;
while (n--) {
- float frequency = *freq++;
+ t_float frequency = *freq++;
/* get the bandlimited discontinuity */
- float sample = _get_bandlimited_discontinuity(ctl, bls);
+ t_float sample = _get_bandlimited_discontinuity(ctl, bls);
/* add aliased sawtooth wave */
- sample += _phase_to_float(ctl->c_phase) - 0.5f;
+ sample += _phase_to_float(ctl->c_phase) - 0.5;
/* send to output */
*out++ = sample;
@@ -384,24 +384,24 @@ static t_int *blosc_perform_saw(t_int *w)
static t_int *blosc_perform_pulse(t_int *w)
{
- t_float *freq = (float *)(w[3]);
- t_float *out = (float *)(w[4]);
+ t_float *freq = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
t_bloscctl *ctl = (t_bloscctl *)(w[1]);
t_int n = (t_int)(w[2]);
t_int i;
/* set postfilter cutoff */
- ctl->c_butter->setButterHP(0.85f * (*freq / sys_getsr()));
+ ctl->c_butter->setButterHP(0.85 * (*freq / sys_getsr()));
while (n--) {
- float frequency = *freq++;
+ t_float frequency = *freq++;
/* get the bandlimited discontinuity */
- float sample = _get_bandlimited_discontinuity(ctl, bli);
+ t_float sample = _get_bandlimited_discontinuity(ctl, bli);
/* highpass filter output to remove DC offset and low frequency aliasing */
- ctl->c_butter->BangSmooth(sample, sample, 0.05f);
+ ctl->c_butter->BangSmooth(sample, sample, 0.05);
/* send to output */
*out++ = sample;
@@ -416,21 +416,21 @@ static t_int *blosc_perform_pulse(t_int *w)
static t_int *blosc_perform_comparator(t_int *w)
{
- t_float *amp = (float *)(w[3]);
- t_float *out = (float *)(w[4]);
+ t_float *amp = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
t_bloscctl *ctl = (t_bloscctl *)(w[1]);
t_int n = (t_int)(w[2]);
t_int i;
t_float prev_amp = ctl->c_prev_amp;
while (n--) {
- float curr_amp = *amp++;
+ t_float curr_amp = *amp++;
/* exact zero won't work for zero detection (sic) */
- if (curr_amp == 0.0f) curr_amp = 0.0000001f;
+ if (curr_amp == 0.0) curr_amp = 0.0000001;
/* get the bandlimited discontinuity */
- float sample = _get_bandlimited_discontinuity(ctl, bls);
+ t_float sample = _get_bandlimited_discontinuity(ctl, bls);
/* add the block wave state */
sample += ctl->c_state;
@@ -471,38 +471,38 @@ static void blosc_dsp(t_blosc *x, t_signal **sp)
int n = sp[0]->s_n;
/* set sampling rate scaling for phasors */
- x->x_ctl.c_phase_inc_scale = 4.0f * (float)(1<<(LPHASOR-2)) / sys_getsr();
+ x->x_ctl.c_phase_inc_scale = 4.0 * (t_float)(1<<(LPHASOR-2)) / sys_getsr();
/* setup & register the correct process routine depending on the waveform */
/* 2 osc */
if (x->x_ctl.c_waveform == gensym("syncsaw")){
- x->x_ctl.c_scale = 1.0f;
- x->x_ctl.c_scale_update = 1.0f;
+ x->x_ctl.c_scale = 1.0;
+ x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_hardsync_saw, 5, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec);
}
/* 1 osc */
else if (x->x_ctl.c_waveform == gensym("pulse")){
- x->x_ctl.c_scale = 1.0f;
- x->x_ctl.c_scale_update = 1.0f;
+ x->x_ctl.c_scale = 1.0;
+ x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_pulse, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
else if (x->x_ctl.c_waveform == gensym("pulse2")){
x->x_ctl.c_phase_inc_scale *= 2;
- x->x_ctl.c_scale = 1.0f;
- x->x_ctl.c_scale_update = -1.0f;
+ x->x_ctl.c_scale = 1.0;
+ x->x_ctl.c_scale_update = -1.0;
dsp_add(blosc_perform_pulse, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
else if (x->x_ctl.c_waveform == gensym("comparator")){
- x->x_ctl.c_scale = 1.0f;
- x->x_ctl.c_scale_update = 1.0f;
+ x->x_ctl.c_scale = 1.0;
+ x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_comparator, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
else{
- x->x_ctl.c_scale = 1.0f;
- x->x_ctl.c_scale_update = 1.0f;
+ x->x_ctl.c_scale = 1.0;
+ x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_saw, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
@@ -540,7 +540,7 @@ static void *blosc_new(t_symbol *s)
/* init oscillators */
for (i=0; i<VOICES; i++) {
x->x_ctl.c_index[i] = N-2;
- x->x_ctl.c_frac[i] = 0.0f;
+ x->x_ctl.c_frac[i] = 0.0;
}
/* init rest of state data */
@@ -549,8 +549,8 @@ static void *blosc_new(t_symbol *s)
x->x_ctl.c_state = 0.0;
x->x_ctl.c_prev_amp = 0.0;
x->x_ctl.c_next_voice = 0;
- x->x_ctl.c_scale = 1.0f;
- x->x_ctl.c_scale_update = 1.0f;
+ x->x_ctl.c_scale = 1.0;
+ x->x_ctl.c_scale_update = 1.0;
x->x_ctl.c_waveform = s;
return (void *)x;
@@ -568,31 +568,31 @@ static void *blosc_new(t_symbol *s)
/* some vector ops */
/* clear a buffer */
-static inline void _clear(float *array, int size)
+static inline void _clear(t_float *array, int size)
{
- memset(array, 0, sizeof(float)*size);
+ memset(array, 0, sizeof(t_float)*size);
}
/* compute complex log */
-static inline void _clog(float *real, float *imag, int size)
+static inline void _clog(t_float *real, t_float *imag, int size)
{
int k;
for (k=0; k<size; k++){
- float r = real[k];
- float i = imag[k];
- float radius = sqrt(r*r+i*i);
+ t_float r = real[k];
+ t_float i = imag[k];
+ t_float radius = sqrt(r*r+i*i);
real[k] = log(radius);
imag[k] = atan2(i,r);
}
}
/* compute complex exp */
-static inline void _cexp(float *real, float *imag, int size)
+static inline void _cexp(t_float *real, t_float *imag, int size)
{
int k;
for (k=0; k<size; k++){
- float r = exp(real[k]);
- float i = imag[k];
+ t_float r = exp(real[k]);
+ t_float i = imag[k];
real[k] = r * cos(i);
imag[k] = r * sin(i);
}
@@ -600,10 +600,10 @@ static inline void _cexp(float *real, float *imag, int size)
/* compute fft */
-static inline void _fft(float *real, float *imag, int size)
+static inline void _fft(t_float *real, t_float *imag, int size)
{
int i;
- float scale = 1.0f / sqrt((float)size);
+ t_float scale = 1.0 / sqrt((t_float)size);
for (i=0; i<size; i++){
real[i] *= scale;
imag[i] *= scale;
@@ -612,10 +612,10 @@ static inline void _fft(float *real, float *imag, int size)
mayer_fft(size, real, imag);
}
/* compute ifft */
-static inline void _ifft(float *real, float *imag, int size)
+static inline void _ifft(t_float *real, t_float *imag, int size)
{
int i;
- float scale = 1.0f / sqrt((float)size);
+ t_float scale = 1.0 / sqrt((t_float)size);
for (i=0; i<size; i++){
real[i] *= scale;
imag[i] *= scale;
@@ -625,15 +625,15 @@ static inline void _ifft(float *real, float *imag, int size)
}
/* convert an integer index to a phase: [0 -> pi, -pi -> 0] */
-static inline float _i2theta(int i, int size){
- float p = 2.0f * M_PI * (float)i / (float)size;
- if (p >= M_PI) p -= 2.0f * M_PI;
+static inline t_float _i2theta(int i, int size){
+ t_float p = 2.0 * M_PI * (t_float)i / (t_float)size;
+ if (p >= M_PI) p -= 2.0 * M_PI;
return p;
}
/* print matlab array */
-static void _printm(float *array, char *name, int size)
+static void _printm(t_float *array, char *name, int size)
{
int i;
fprintf(stderr, "%s = [", name);
@@ -644,7 +644,7 @@ static void _printm(float *array, char *name, int size)
}
/* store oversampled waveform as decimated chunks */
-static void _store_decimated(float *dst, float *src, float scale, int size)
+static void _store_decimated(t_float *dst, t_float *src, t_float scale, int size)
{
int i;
for (i=0; i<size; i++){
@@ -656,7 +656,7 @@ static void _store_decimated(float *dst, float *src, float scale, int size)
}
/* store waveform as one chunk */
-static void _store(float *dst, float *src, float scale, int size)
+static void _store(t_float *dst, t_float *src, t_float scale, int size)
{
int i;
for (i=0; i<size; i++){
@@ -674,24 +674,24 @@ static void build_tables(void)
/* we work in the complex domain to eliminate the need to avoid
negative spectral components */
- float real[M];
- float imag[M];
- float sum,scale;
+ t_float real[M];
+ t_float imag[M];
+ t_float sum,scale;
int i,j;
/* create windowed sinc */
_clear(imag, M);
- real[0] = 1.0f;
+ real[0] = 1.0;
for (i=1; i<M; i++){
- float tw = _i2theta(i,M);
- float ts = tw * NBPERIODS * (float)(M) / (float)(N);
+ t_float tw = _i2theta(i,M);
+ t_float ts = tw * NBPERIODS * (t_float)(M) / (t_float)(N);
/* sinc */
real[i] = sin(ts)/ts;
/* blackman window */
- real[i] *= 0.42f + 0.5f * (cos(tw)) + 0.08f * (cos(2.0f*tw));
+ real[i] *= 0.42 + 0.5 * (cos(tw)) + 0.08 * (cos(2.0*tw));
//real[i] *= 0.5f * (1.0f + WALPHA) + 0.5f * (1.0f - WALPHA) * (cos(tw));
@@ -711,8 +711,8 @@ static void build_tables(void)
/* kill anti-causal part (contribution of non minimum phase zeros) */
/* should we kill nyquist too ?? */
for (i=M/2+1; i<M; i++){
- real[i] *= 0.0000f;
- imag[i] *= 0.0000f;
+ real[i] *= 0.0000;
+ imag[i] *= 0.0000;
}
@@ -727,27 +727,27 @@ static void build_tables(void)
and work with the first N samples */
/* normalize impulse (integral = 1) */
- sum = 0.0f;
+ sum = 0.0;
for (i=0; i<N; i++){sum += real[i];}
- scale = 1.0f / sum;
+ scale = 1.0 / sum;
for (i=0; i<N; i++){real[i] *= scale;}
/* store bli table */
- _store(bli, real, (float)S, N);
+ _store(bli, real, (t_float)S, N);
//_printm(bli, "h", N);
/* integrate impulse and invert to produce a step function
from 1->0 */
- sum = 0.0f;
+ sum = 0.0;
for (i=0; i<N; i++){
sum += real[i];
- real[i] = (1.0f - sum);
+ real[i] = (1.0 - sum);
}
/* store decimated bls tables */
- _store(bls, real, 1.0f, N);
+ _store(bls, real, 1.0, N);
}
diff --git a/modules++/filterortho~.cc b/modules++/filterortho~.cc
index c80552b..b792729 100644
--- a/modules++/filterortho~.cc
+++ b/modules++/filterortho~.cc
@@ -43,8 +43,8 @@ static t_int *filterortho_perform(t_int *w)
{
- t_float *in = (float *)(w[3]);
- t_float *out = (float *)(w[4]);
+ t_float *in = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
DSPIfilterOrtho* filterortho = (DSPIfilterOrtho *)(w[1]);
t_int n = (t_int)(w[2]);
t_int i;
@@ -52,7 +52,7 @@ static t_int *filterortho_perform(t_int *w)
// dit kan beter
- float smooth = 1.0f - pow(.05f,1.0f/(float)(n));
+ t_float smooth = 1.0 - pow(.05,1.0/(t_float)(n));
for (i = 0; i < n; i++)
{
diff --git a/modules++/filters.h b/modules++/filters.h
index e0d1c49..8485bec 100644
--- a/modules++/filters.h
+++ b/modules++/filters.h
@@ -4,7 +4,7 @@
/* the typedef */
#ifndef T
-#define T float
+#define T t_float
#endif
@@ -54,14 +54,14 @@ P vcmul2 (T A, T C) { cmul2(a,a+1,c,c+1); }
/* norm */
-static inline float vcnorm(T X) { return hypot(x[0], x[1]); }
+static inline t_float vcnorm(T X) { return hypot(x[0], x[1]); }
/* swap */
P vcswap(T Y, T X)
{
- float t[2] = {x[0], x[1]};
+ t_float t[2] = {x[0], x[1]};
x[0] = y[0];
x[1] = y[1];
y[0] = t[0];
@@ -72,14 +72,14 @@ P vcswap(T Y, T X)
/* inverse */
P vcinv(T Y, T X)
{
- float scale = 1.0f / vcnorm(x);
+ t_float scale = 1.0 / vcnorm(x);
y[0] = scale * x[0];
y[1] = scale * x[1];
}
P vcinv1(T X)
{
- float scale = 1.0f / vcnorm(x);
+ t_float scale = 1.0 / vcnorm(x);
x[0] *= scale;
x[1] *= scale;
}
@@ -162,24 +162,24 @@ P two_pole_complex_conj (T X, T Y, T S, T A, T C)
/* evaluate pole and allzero TF in z^-1 given the complex zeros/poles:
p(z) (or p(z)^-1) = \product (1-z_i z^-1) */
-PP eval_zero_poly(float *val, float *arg, float *zeros, int nb_zeros)
+PP eval_zero_poly(t_float *val, t_float *arg, t_float *zeros, int nb_zeros)
{
int i;
- float a[2] = {arg[0], arg[1]};
+ t_float a[2] = {arg[0], arg[1]};
vcinv1(a);
- val[0] = 1.0f;
- val[1] = 0.0f;
+ val[0] = 1.0;
+ val[1] = 0.0;
a[0] *= -1;
a[1] *= -1;
for (i=0; i<nb_zeros; i++){
- float t[2];
+ t_float t[2];
vcmul(t, a, zeros + 2*i);
- t[0] += 1.0f;
+ t[0] += 1.0;
vcmul2(val, t);
}
}
-PP eval_pole_poly(float *val, float *arg, float *poles, int nb_poles)
+PP eval_pole_poly(t_float *val, t_float *arg, t_float *poles, int nb_poles)
{
eval_zero_poly(val, arg, poles, nb_poles);
vcinv1(val);
@@ -189,10 +189,10 @@ PP eval_pole_poly(float *val, float *arg, float *poles, int nb_poles)
/* since it's more efficient to store half of the poles for a real impulse
response, these functions compute p(z) conj(p(conj(z))) */
-PP eval_conj_zero_poly(float *val, float *arg, float *zeros, int nb_zeros)
+PP eval_conj_zero_poly(t_float *val, t_float *arg, t_float *zeros, int nb_zeros)
{
- float t[2];
- float a[2] = {arg[0], arg[1]};
+ t_float t[2];
+ t_float a[2] = {arg[0], arg[1]};
eval_zero_poly(t, a, zeros, nb_zeros);
a[1] *= -1;
eval_zero_poly(val, a, zeros, nb_zeros);
@@ -200,15 +200,15 @@ PP eval_conj_zero_poly(float *val, float *arg, float *zeros, int nb_zeros)
vcmul2(val, t);
}
-PP eval_conj_pole_poly(float *val, float *arg, float *poles, int nb_poles)
+PP eval_conj_pole_poly(t_float *val, t_float *arg, t_float *poles, int nb_poles)
{
eval_conj_zero_poly(val, arg, poles, nb_poles);
vcinv1(val);
}
-PP eval_conj_pole_zero_ratfunc(float *val, float *arg, float *poles, float *zeros, int nb_poles, int nb_zeros)
+PP eval_conj_pole_zero_ratfunc(t_float *val, t_float *arg, t_float *poles, t_float *zeros, int nb_poles, int nb_zeros)
{
- float t[2];
+ t_float t[2];
eval_conj_zero_poly(t, arg, zeros, nb_zeros);
eval_conj_pole_poly(val, arg, poles, nb_zeros);
vcmul2(val, t);
diff --git a/modules/bdiag~.c b/modules/bdiag~.c
index ac0a363..be7df79 100644
--- a/modules/bdiag~.c
+++ b/modules/bdiag~.c
@@ -43,8 +43,8 @@ typedef struct bdiag
} t_bdiag;
-static float randfloat(void){
- float r = rand ();
+static t_float randfloat(void){
+ t_float r = rand ();
r /= (RAND_MAX/2);
r -= 1;
return r;
@@ -94,22 +94,22 @@ static void bdiag_eigen(t_bdiag *x, t_floatarg index,
static void bdiag_timefreq(t_bdiag *x, t_floatarg index,
t_floatarg time, t_floatarg freq)
{
- float r,a,b,n;
- float sr = sys_getsr() / (float)x->x_ctl.c_order;
+ t_float r,a,b,n;
+ t_float sr = sys_getsr() / (t_float)x->x_ctl.c_order;
/* time in ms */
time *= 0.001;
- if (time < 0.0f) time = 0.0f;
- r = pow(0.001f, 1.0f / (time * sr));
- if (r < 0.0f) r = 0.0f;
- if (r > 1.0f) r = 1.0f;
+ if (time < 0.0) time = 0.0;
+ r = pow(0.001, 1.0 / (time * sr));
+ if (r < 0.0) r = 0.0;
+ if (r > 1.0) r = 1.0;
a = cos(2*M_PI*freq/sr);
b = sin(2*M_PI*freq/sr);
/* normalize to be sure */
- n = 1.0f / sqrt(a*a + b*b);
+ n = 1.0 / sqrt(a*a + b*b);
a *= n;
b *= n;
@@ -120,14 +120,14 @@ static void bdiag_preset(t_bdiag *x, t_floatarg preset)
{
int p = preset;
int i;
- float a, b, w, r;
+ t_float a, b, w, r;
switch(p){
case 0:
post("preset 0");
for (i=0; i<x->x_ctl.c_order/2; i++){
w = randfloat() * .001;
- r = 1. - (((float)i + 1.)/1000.);
+ r = 1. - (((t_float)i + 1.)/1000.);
a = cos(w) * r;
b = sin(w) * r;
post("%f %f %f %f", w, r, a, b);
@@ -145,8 +145,8 @@ static t_int *bdiag_perform(t_int *w)
{
- t_float *in = (float *)(w[3]);
- t_float *out = (float *)(w[4]);
+ t_float *in = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
t_bdiagctl *ctl = (t_bdiagctl *)(w[1]);
t_float *eigen = ctl->c_eigen;
diff --git a/modules/bwin~.c b/modules/bwin~.c
index 90a9e2a..5a462d4 100644
--- a/modules/bwin~.c
+++ b/modules/bwin~.c
@@ -53,7 +53,7 @@ static void window_size(t_window *x, t_int n)
{
if (x->x_size != n){
if (x->x_window) free(x->x_window);
- x->x_window = malloc(sizeof(float)*n);
+ x->x_window = malloc(sizeof(t_float)*n);
x->x_size = n;
}
}
@@ -62,26 +62,26 @@ static void window_size(t_window *x, t_int n)
static void window_type(t_window *x, t_symbol *s, t_float f)
{
int i;
- float a = 0;
- float a_inc = 2 * M_PI / (float)(x->x_size);
+ t_float a = 0;
+ t_float a_inc = 2 * M_PI / (t_float)(x->x_size);
if (!s) s = gensym("hamming");
if (s == gensym("hamming")){
for (i=0; i<x->x_size; i++){
- float c = cos(a);
+ t_float c = cos(a);
x->x_window[i] = (0.54 - 0.46 * c);
a += a_inc;
}
}
else if (s == gensym("hann")){
for (i=0; i<x->x_size; i++){
- float c = cos(a);
+ t_float c = cos(a);
x->x_window[i] = (0.5 - 0.5 * c);
a += a_inc;
}
}
else if (s == gensym("hann/hamming")){
for (i=0; i<x->x_size; i++) {
- float c = cos(a);
+ t_float c = cos(a);
x->x_window[i] = (0.5 - 0.5 * c) / (0.54 - 0.46 * c);
a += a_inc;
}
@@ -91,7 +91,7 @@ static void window_type(t_window *x, t_symbol *s, t_float f)
x->x_window[1] = 1.0f / sqrt((double)(x->x_size>>1)); //NY
for (i=2; i<x->x_size; i+=2) {
double freq = (double)(i>>1);
- float amp = sqrt(1.0 / freq);
+ t_float amp = sqrt(1.0 / freq);
x->x_window[i] = amp;
x->x_window[i+1] = amp;
}
@@ -101,18 +101,18 @@ static void window_type(t_window *x, t_symbol *s, t_float f)
x->x_window[1] = sqrt((double)(x->x_size>>1)); //NY
for (i=2; i<x->x_size; i+=2) {
double freq = (double)(i>>1);
- float amp = sqrt(freq);
+ t_float amp = sqrt(freq);
x->x_window[i] = amp;
x->x_window[i+1] = amp;
}
}
else if (s == gensym("bfft_db/octave")){
- float power = f/6.0;
+ t_float power = f/6.0;
x->x_window[0] = 1.0f; //DC
x->x_window[1] = pow((double)(x->x_size>>1), power); //NY
for (i=2; i<x->x_size; i+=2) {
double freq = (double)(i>>1);
- float amp = pow(freq, power);
+ t_float amp = pow(freq, power);
x->x_window[i] = amp;
x->x_window[i+1] = amp;
}
diff --git a/modules/cmath~.c b/modules/cmath~.c
index 5526b9f..85db447 100644
--- a/modules/cmath~.c
+++ b/modules/cmath~.c
@@ -33,19 +33,19 @@ typedef struct cmath
static t_int *cmath_perform_clog(t_int *w)
{
- t_float *inx = (float *)(w[2]);
- t_float *iny = (float *)(w[3]);
- t_float *outx = (float *)(w[5]); // clockwize addressing
- t_float *outy = (float *)(w[4]);
+ t_float *inx = (t_float *)(w[2]);
+ t_float *iny = (t_float *)(w[3]);
+ t_float *outx = (t_float *)(w[5]); // clockwize addressing
+ t_float *outy = (t_float *)(w[4]);
t_int i;
t_int n = (t_int)(w[1]);
t_float x;
while (n--){
- float x = *inx++;
- float y = *iny++;
- float norm = sqrt(x*x + y*y);
- float arg = atan2(y, x);
+ t_float x = *inx++;
+ t_float y = *iny++;
+ t_float norm = sqrt(x*x + y*y);
+ t_float arg = atan2(y, x);
if (norm < MINNORM){
norm = MINNORM;
}
@@ -59,18 +59,18 @@ static t_int *cmath_perform_clog(t_int *w)
static t_int *cmath_perform_cexp(t_int *w)
{
- t_float *inx = (float *)(w[2]);
- t_float *iny = (float *)(w[3]);
- t_float *outx = (float *)(w[5]); // clockwize addressing
- t_float *outy = (float *)(w[4]);
+ t_float *inx = (t_float *)(w[2]);
+ t_float *iny = (t_float *)(w[3]);
+ t_float *outx = (t_float *)(w[5]); // clockwize addressing
+ t_float *outy = (t_float *)(w[4]);
t_int i;
t_int n = (t_int)(w[1]);
t_float x;
while (n--){
- float x = *inx++;
- float y = *iny++;
- float norm = exp(x);
+ t_float x = *inx++;
+ t_float y = *iny++;
+ t_float norm = exp(x);
*outx++ = norm * cos(y);
*outy++ = norm * sin(y);
}
@@ -80,20 +80,20 @@ static t_int *cmath_perform_cexp(t_int *w)
static t_int *cmath_perform_nfft(t_int *w)
{
- t_float *inx = (float *)(w[2]);
- t_float *iny = (float *)(w[3]);
- t_float *outx = (float *)(w[5]); // clockwize addressing
- t_float *outy = (float *)(w[4]);
+ t_float *inx = (t_float *)(w[2]);
+ t_float *iny = (t_float *)(w[3]);
+ t_float *outx = (t_float *)(w[5]); // clockwize addressing
+ t_float *outy = (t_float *)(w[4]);
t_int i;
t_int n = (t_int)(w[1]);
t_float x;
- t_float scale = 1.0f / (sqrt((float)n));
+ t_float scale = 1.0 / (sqrt((t_float)n));
mayer_fft(n, inx, outx);
while (n--){
- float x = *inx++;
- float y = *iny++;
+ t_float x = *inx++;
+ t_float y = *iny++;
*outx++ = scale * x;
*outy++ = scale * y;
}
@@ -103,20 +103,20 @@ static t_int *cmath_perform_nfft(t_int *w)
static t_int *cmath_perform_nifft(t_int *w)
{
- t_float *inx = (float *)(w[2]);
- t_float *iny = (float *)(w[3]);
- t_float *outx = (float *)(w[5]); // clockwize addressing
- t_float *outy = (float *)(w[4]);
+ t_float *inx = (t_float *)(w[2]);
+ t_float *iny = (t_float *)(w[3]);
+ t_float *outx = (t_float *)(w[5]); // clockwize addressing
+ t_float *outy = (t_float *)(w[4]);
t_int i;
t_int n = (t_int)(w[1]);
t_float x;
- t_float scale = 1.0f / (sqrt((float)n));
+ t_float scale = 1.0 / (sqrt((t_float)n));
mayer_ifft(n, inx, outx);
while (n--){
- float x = *inx++;
- float y = *iny++;
+ t_float x = *inx++;
+ t_float y = *iny++;
*outx++ = scale * x;
*outy++ = scale * y;
}
diff --git a/modules/diag~.c b/modules/diag~.c
index c8a94c5..1e99682 100644
--- a/modules/diag~.c
+++ b/modules/diag~.c
@@ -43,8 +43,8 @@ typedef struct diag
} t_diag;
-static float randfloat(void){
- float r = rand ();
+static t_float randfloat(void){
+ t_float r = rand ();
r /= (RAND_MAX/2);
r -= 1;
return r;
@@ -62,15 +62,15 @@ static void diag_eigen(t_diag *x, t_floatarg index, t_floatarg val)
/* set decay time of pole at index */
static void diag_time(t_diag *x, t_floatarg index, t_floatarg time)
{
- float r;
+ t_float r;
/* time in ms */
time *= 0.001;
- if (time < 0.0f) time = 0.0f;
- r = pow(0.001f, (t_float)x->x_ctl.c_order / (time * sys_getsr()));
- if (r < 0.0f) r = 0.0f;
- if (r > 1.0f) r = 1.0f;
+ if (time < 0.0) time = 0.0;
+ r = pow(0.001, (t_float)x->x_ctl.c_order / (time * sys_getsr()));
+ if (r < 0.0) r = 0.0;
+ if (r > 1.0) r = 1.0;
diag_eigen(x, index, r);
}
diff --git a/modules/dwt~.c b/modules/dwt~.c
index 9634002..6d394ae 100644
--- a/modules/dwt~.c
+++ b/modules/dwt~.c
@@ -58,9 +58,9 @@ static void dwt_even(t_dwt *x, t_floatarg f)
{
int k = (int)f;
int i, j;
- float *p = x->x_ctl.c_predict;
- float *u = x->x_ctl.c_update;
- float l, xi, xj;
+ t_float *p = x->x_ctl.c_predict;
+ t_float *u = x->x_ctl.c_update;
+ t_float l, xi, xj;
if ((k>0) && (k<MAXORDER/2))
{
@@ -230,12 +230,12 @@ static void dwt_filter(t_dwt *x, t_symbol *s, int argc, t_atom *argv)
char *name = x->x_ctl.c_name;
- float *pfilter = x->x_ctl.c_predict;
- float *ufilter = x->x_ctl.c_update;
- float *mask = NULL;
+ t_float *pfilter = x->x_ctl.c_predict;
+ t_float *ufilter = x->x_ctl.c_update;
+ t_float *mask = NULL;
t_int *length = NULL;
- float sum = 0;
+ t_float sum = 0;
if (s == gensym("predict"))
{
@@ -305,13 +305,13 @@ static inline void dwtloop(t_float *vector,
int backup,
int numcoef,
int mask,
- float *filter,
+ t_float *filter,
int filtlength,
- float sign)
+ t_float sign)
{
int k,m;
- float acc;
+ t_float acc;
for (k = 0; k < numcoef; k++)
{
@@ -338,13 +338,13 @@ static inline void dwtloop16(t_float *vector,
int backup,
int numcoef,
int mask,
- float *filter,
+ t_float *filter,
int filtlength, /* ignored, set to 16 */
- float sign)
+ t_float sign)
{
int k,m;
- float acc;
+ t_float acc;
for (k = 0; k < numcoef; k++)
{
@@ -516,7 +516,7 @@ static t_int *idwt_perform(t_int *w)
int backup_u = (ctl->c_nupdate-1)*n;
int backup_p = (ctl->c_npredict-1)*n;
int fake_in = ctl->c_fakein;
- float fake_val = ctl->c_fakeval;
+ t_float fake_val = ctl->c_fakeval;
/* copy input to output */
if (in != out)
@@ -653,7 +653,7 @@ static t_int *idwt16_perform(t_int *w)
int backup_u = (ctl->c_nupdate-1)*n;
int backup_p = (ctl->c_npredict-1)*n;
int fake_in = ctl->c_fakein;
- float fake_val = ctl->c_fakeval;
+ t_float fake_val = ctl->c_fakeval;
/* copy input to output */
if (in != out)
diff --git a/modules/dynwav~.c b/modules/dynwav~.c
index c04f56d..cd94907 100644
--- a/modules/dynwav~.c
+++ b/modules/dynwav~.c
@@ -74,9 +74,9 @@ static t_int *dynwav_perform(t_int *w)
for (i = 0; i < n; i++)
{
- float findex = *freq++ * (t_float)n;
+ t_float findex = *freq++ * (t_float)n;
int index = findex;
- float frac, a, b, c, d, cminusb, q, r;
+ t_float frac, a, b, c, d, cminusb, q, r;
int ia, ib, ic, id;
frac = findex - index;
@@ -134,16 +134,16 @@ static t_int *dynwav_perform_8point(t_int *w)
if (buf && dbuf)
{
-/* const float N1 = 1 / ( 2 * (1-(1/9)) * (1-(1/25)) * (1-(1/49)) );
-** const float N2 = 1 / ( (1-(9)) * 2 * (1-(9/25)) * (1-(9/49)) );
-** const float N3 = 1 / ( (1-(25)) * (1-(25/9)) * 2 * (1-(25/49)) );
-** const float N4 = 1 / ( (1-(49)) * (1-(49/9)) * (1-(49/25)) * 2 );
+/* const t_float N1 = 1 / ( 2 * (1-(1/9)) * (1-(1/25)) * (1-(1/49)) );
+** const t_float N2 = 1 / ( (1-(9)) * 2 * (1-(9/25)) * (1-(9/49)) );
+** const t_float N3 = 1 / ( (1-(25)) * (1-(25/9)) * 2 * (1-(25/49)) );
+** const t_float N4 = 1 / ( (1-(49)) * (1-(49/9)) * (1-(49/25)) * 2 );
*/
- const float N1 = 0.59814453125;
- const float N2 = -0.11962890625;
- const float N3 = 0.02392578125;
- const float N4 = -0.00244140625;
+ const t_float N1 = 0.59814453125;
+ const t_float N2 = -0.11962890625;
+ const t_float N3 = 0.02392578125;
+ const t_float N4 = -0.00244140625;
/* store input wavetable in buffer */
@@ -152,13 +152,13 @@ static t_int *dynwav_perform_8point(t_int *w)
for (i = 0; i < n; i++)
{
- float findex = *freq++ * (t_float)n;
+ t_float findex = *freq++ * (t_float)n;
int index = findex;
- float frac, q, r, fm, fp, fe, fo;
- float x1, x2, x3, x4;
- float g1, g2, g3, g4;
- float gg, g2g3g4, g1g3g4, g1g2g4, g1g2g3;
- float acc;
+ t_float frac, q, r, fm, fp, fe, fo;
+ t_float x1, x2, x3, x4;
+ t_float g1, g2, g3, g4;
+ t_float gg, g2g3g4, g1g3g4, g1g2g4, g1g2g3;
+ t_float acc;
int im, ip;
frac = 2 *(findex - index) - 1;
diff --git a/modules/extlib_util.h b/modules/extlib_util.h
index 195d85f..6261e39 100644
--- a/modules/extlib_util.h
+++ b/modules/extlib_util.h
@@ -26,28 +26,31 @@
/* envelope stuff */
/* exponential range for envelopes is 60dB */
-#define ENVELOPE_RANGE 0.001f
-#define ENVELOPE_MAX (1.0f - ENVELOPE_RANGE)
+#define ENVELOPE_RANGE 0.001
+#define ENVELOPE_MAX (1.0 - ENVELOPE_RANGE)
#define ENVELOPE_MIN ENVELOPE_RANGE
/* convert milliseconds to 1-p, with p a real pole */
-static inline float milliseconds_2_one_minus_realpole(float time)
+static inline t_float milliseconds_2_one_minus_realpole(t_float time)
{
- float r;
+ t_float r;
- if (time < 0.0f) time = 0.0f;
- r = -expm1(1000.0f * log(ENVELOPE_RANGE) / (sys_getsr() * time));
- if (!(r < 1.0f)) r = 1.0f;
+ if (time < 0.0) time = 0.0;
+ r = -expm1(1000.0 * log(ENVELOPE_RANGE) / (sys_getsr() * time));
+ if (!(r < 1.0)) r = 1.0;
//post("%f",r);
return r;
}
+#if defined(__i386__) || defined(__x86_64__) // type punning code:
+
+#if PD_FLOAT_PRECISION == 32
typedef union
{
unsigned int i;
- float f;
+ t_float f;
} t_flint;
/* check if floating point number is denormal */
@@ -56,6 +59,20 @@ typedef union
#define IS_DENORMAL(f) (((((t_flint)(f)).i) & 0x7f800000) == 0)
+#elif PD_FLOAT_PRECISION == 64
+
+typedef union
+{
+ unsigned int i[2];
+ t_float f;
+} t_flint;
+
+#define IS_DENORMAL(f) (((((t_flint)(f)).i[1]) & 0x7ff00000) == 0)
+
+#endif // endif PD_FLOAT_PRECISION
+#else // if not defined(__i386__) || defined(__x86_64__)
+#define IS_DENORMAL(f) 0
+#endif // end if defined(__i386__) || defined(__x86_64__)
#endif /* CREB_EXTLIB_UTIL_H */
diff --git a/modules/fdn~.c b/modules/fdn~.c
index 68a7723..3eef988 100644
--- a/modules/fdn~.c
+++ b/modules/fdn~.c
@@ -32,7 +32,7 @@ check filtering code
#include <stdio.h>
#include <string.h>
-#define FDN_MIN_DECAY_TIME .01f
+#define FDN_MIN_DECAY_TIME .01
/*
@@ -330,8 +330,8 @@ static void fdn_setupdelayline(t_fdn *x){
int mask = x->x_ctl.c_bufsize - 1;
int start = x->x_ctl.c_tap[0];
t_int *tap = x->x_ctl.c_tap;
- float *length = x->x_ctl.c_length;
- float scale = sys_getsr() * .001f;
+ t_float *length = x->x_ctl.c_length;
+ t_float scale = sys_getsr() * .001f;
sum = 0;
tap[0] = (start & mask);
@@ -350,7 +350,7 @@ static void fdn_setupdelayline(t_fdn *x){
static void fdn_list (t_fdn *x, t_symbol *s, int argc, t_atom *argv){
int i;
- float l;
+ t_float l;
int sum=0;
int order = argc & 0xfffffffc;
diff --git a/modules/filters.h b/modules/filters.h
index e0d1c49..8485bec 100644
--- a/modules/filters.h
+++ b/modules/filters.h
@@ -4,7 +4,7 @@
/* the typedef */
#ifndef T
-#define T float
+#define T t_float
#endif
@@ -54,14 +54,14 @@ P vcmul2 (T A, T C) { cmul2(a,a+1,c,c+1); }
/* norm */
-static inline float vcnorm(T X) { return hypot(x[0], x[1]); }
+static inline t_float vcnorm(T X) { return hypot(x[0], x[1]); }
/* swap */
P vcswap(T Y, T X)
{
- float t[2] = {x[0], x[1]};
+ t_float t[2] = {x[0], x[1]};
x[0] = y[0];
x[1] = y[1];
y[0] = t[0];
@@ -72,14 +72,14 @@ P vcswap(T Y, T X)
/* inverse */
P vcinv(T Y, T X)
{
- float scale = 1.0f / vcnorm(x);
+ t_float scale = 1.0 / vcnorm(x);
y[0] = scale * x[0];
y[1] = scale * x[1];
}
P vcinv1(T X)
{
- float scale = 1.0f / vcnorm(x);
+ t_float scale = 1.0 / vcnorm(x);
x[0] *= scale;
x[1] *= scale;
}
@@ -162,24 +162,24 @@ P two_pole_complex_conj (T X, T Y, T S, T A, T C)
/* evaluate pole and allzero TF in z^-1 given the complex zeros/poles:
p(z) (or p(z)^-1) = \product (1-z_i z^-1) */
-PP eval_zero_poly(float *val, float *arg, float *zeros, int nb_zeros)
+PP eval_zero_poly(t_float *val, t_float *arg, t_float *zeros, int nb_zeros)
{
int i;
- float a[2] = {arg[0], arg[1]};
+ t_float a[2] = {arg[0], arg[1]};
vcinv1(a);
- val[0] = 1.0f;
- val[1] = 0.0f;
+ val[0] = 1.0;
+ val[1] = 0.0;
a[0] *= -1;
a[1] *= -1;
for (i=0; i<nb_zeros; i++){
- float t[2];
+ t_float t[2];
vcmul(t, a, zeros + 2*i);
- t[0] += 1.0f;
+ t[0] += 1.0;
vcmul2(val, t);
}
}
-PP eval_pole_poly(float *val, float *arg, float *poles, int nb_poles)
+PP eval_pole_poly(t_float *val, t_float *arg, t_float *poles, int nb_poles)
{
eval_zero_poly(val, arg, poles, nb_poles);
vcinv1(val);
@@ -189,10 +189,10 @@ PP eval_pole_poly(float *val, float *arg, float *poles, int nb_poles)
/* since it's more efficient to store half of the poles for a real impulse
response, these functions compute p(z) conj(p(conj(z))) */
-PP eval_conj_zero_poly(float *val, float *arg, float *zeros, int nb_zeros)
+PP eval_conj_zero_poly(t_float *val, t_float *arg, t_float *zeros, int nb_zeros)
{
- float t[2];
- float a[2] = {arg[0], arg[1]};
+ t_float t[2];
+ t_float a[2] = {arg[0], arg[1]};
eval_zero_poly(t, a, zeros, nb_zeros);
a[1] *= -1;
eval_zero_poly(val, a, zeros, nb_zeros);
@@ -200,15 +200,15 @@ PP eval_conj_zero_poly(float *val, float *arg, float *zeros, int nb_zeros)
vcmul2(val, t);
}
-PP eval_conj_pole_poly(float *val, float *arg, float *poles, int nb_poles)
+PP eval_conj_pole_poly(t_float *val, t_float *arg, t_float *poles, int nb_poles)
{
eval_conj_zero_poly(val, arg, poles, nb_poles);
vcinv1(val);
}
-PP eval_conj_pole_zero_ratfunc(float *val, float *arg, float *poles, float *zeros, int nb_poles, int nb_zeros)
+PP eval_conj_pole_zero_ratfunc(t_float *val, t_float *arg, t_float *poles, t_float *zeros, int nb_poles, int nb_zeros)
{
- float t[2];
+ t_float t[2];
eval_conj_zero_poly(t, arg, zeros, nb_zeros);
eval_conj_pole_poly(val, arg, poles, nb_zeros);
vcmul2(val, t);
diff --git a/modules/lattice~.c b/modules/lattice~.c
index 3568ea7..d9f07de 100644
--- a/modules/lattice~.c
+++ b/modules/lattice~.c
@@ -23,7 +23,7 @@
#include <math.h>
#define MAXORDER 1024
-#define MAXREFCO 0.9999f
+#define MAXREFCO 0.9999
typedef struct latticesegment
{
diff --git a/modules/permut~.c b/modules/permut~.c
index 402d007..58da769 100644
--- a/modules/permut~.c
+++ b/modules/permut~.c
@@ -25,6 +25,11 @@
//#include "m_pd.h"
#include "extlib_util.h"
+typedef union
+{
+ float f;
+ unsigned int i;
+}t_permutflint;
typedef struct permutctl
@@ -34,6 +39,7 @@ typedef struct permutctl
int c_blocksize;
} t_permutctl;
+
typedef struct permut
{
t_object x_obj;
@@ -64,9 +70,10 @@ static void permut_random(t_permut *x, t_floatarg seed)
int mask = N-1;
t_int *p = x->x_ctl.c_permutationtable;
int r, last = 0;
-
- //srand(* ((unsigned int *)(&seed)));
- srand (((t_flint)seed).i);
+ t_permutflint flintseed;
+
+ flintseed.f = (float)seed;
+ srand(flintseed.i);
if(p)
{
@@ -92,9 +99,10 @@ static void permut_random(t_permut *x, t_floatarg seed)
static void permut_bang(t_permut *x)
{
- unsigned int r = rand();
- //permut_random(x, *((t_float *)(&r)));
- permut_random(x, ((t_flint)r).f);
+ t_permutflint seed;
+ seed.i = rand();
+ t_float floatseed = (t_float)seed.f;
+ permut_random(x, floatseed);
}
static void permut_resize_table(t_permut *x, int size)
diff --git a/modules/ramp~.c b/modules/ramp~.c
index e4d5ed4..fa87809 100644
--- a/modules/ramp~.c
+++ b/modules/ramp~.c
@@ -57,7 +57,7 @@ static t_int *ramp_perform(t_int *w)
t_int n = (t_int)(w[2]);
t_float x;
- t_float scale = ctl->c_blockscale ? 1.0f / (t_float)n : 1.0f;
+ t_float scale = ctl->c_blockscale ? 1.0 / (t_float)n : 1.0;
x = ctl->c_offset;
diff --git a/modules/ratio.c b/modules/ratio.c
index 777f2b9..c192b30 100644
--- a/modules/ratio.c
+++ b/modules/ratio.c
@@ -37,8 +37,8 @@ static void ratio_float(t_ratio *x, t_floatarg f)
f = (f<0)?(-f):(f);
if (f)
{
- while (f < 1.0f) f *= 2.0f;
- while (f >= 2.0f) f *= 0.5f;
+ while (f < 1.0) f *= 2.0;
+ while (f >= 2.0) f *= 0.5;
}
outlet_float(x->x_out, f);
diff --git a/modules/resofilt~.c b/modules/resofilt~.c
index 09f1a72..3dd6af1 100644
--- a/modules/resofilt~.c
+++ b/modules/resofilt~.c
@@ -51,11 +51,11 @@ typedef struct resofilt
static inline void _sat_state(t_float *x)
{
- const float norm_squared_max = 1.0f;
- float norm_squared = x[0] * x[0] + x[1] * x[1];
+ const t_float norm_squared_max = 1.0;
+ t_float norm_squared = x[0] * x[0] + x[1] * x[1];
if (norm_squared > norm_squared_max){
- float scale = 1.0f / sqrt(norm_squared);
+ t_float scale = 1.0 / sqrt(norm_squared);
x[0] *= scale;
x[1] *= scale;
}
@@ -75,8 +75,8 @@ static t_int *resofilt_perform_fourpole(t_int *w)
t_float *out = (t_float *)(w[6]);
int i;
- t_float inv_n = 1.0f / ((t_float)n);
- t_float inv_sr = 1.0f / sys_getsr();
+ t_float inv_n = 1.0 / ((t_float)n);
+ t_float inv_sr = 1.0 / sys_getsr();
t_float phasor[2], phasor_rot[2];
t_float radior[2], radior_rot[2];
@@ -92,7 +92,7 @@ static t_int *resofilt_perform_fourpole(t_int *w)
interpolated linearly (that is, linearly in the "analog" domain,
so exponentially in the z-domain) */
- reso_rms = freq_rms = 0.0f;
+ reso_rms = freq_rms = 0.0;
for (i=0; i<n; i++){
/* first input is the reso frequency (absolute) */
t_float _freq = *freq++;
@@ -104,7 +104,7 @@ static t_int *resofilt_perform_fourpole(t_int *w)
}
freq_rms = sqrt(freq_rms * inv_n) * inv_sr;
reso_rms = sqrt(reso_rms * inv_n);
- f = (freq_rms > 0.5f) ? 0.5f : freq_rms;
+ f = (freq_rms > 0.5) ? 0.5 : freq_rms;
r = sqrt(sqrt(reso_rms));
@@ -132,18 +132,18 @@ static t_int *resofilt_perform_fourpole(t_int *w)
/* moog like scaling */
if (1){
- float r2 = r_prev * r_prev;
- float r4 = r2 * r2;
- scalor = 1.0f + (1.0f + 4.0f * r4);
+ t_float r2 = r_prev * r_prev;
+ t_float r4 = r2 * r2;
+ scalor = 1.0f + (1.0 + 4.0 * r4);
r2 = r * r;
r4 = r2 * r2;
- scalor_inc = ((1.0f + (1.0f + 4.0f * r4)) - scalor) * inv_n;
+ scalor_inc = ((1.0 + (1.0 + 4.0 * r4)) - scalor) * inv_n;
}
/* no scaling */
else{
- scalor = 1.0f;
- scalor_inc = 0.0f;
+ scalor = 1.0;
+ scalor_inc = 0.0;
}
ctl->c_f_prev = f;
@@ -155,11 +155,11 @@ static t_int *resofilt_perform_fourpole(t_int *w)
/* perform filtering */
for (i=0; i<n; i++){
- float poleA[2], poleB[2];
- float *stateA = ctl->c_state;
- float *stateB = ctl->c_state+2;
+ t_float poleA[2], poleB[2];
+ t_float *stateA = ctl->c_state;
+ t_float *stateB = ctl->c_state+2;
- float x;
+ t_float x;
/* compute poles */
poleA[0] = radior[0] * phasor[0];
@@ -232,7 +232,7 @@ static t_int *resofilt_perform_threepole(t_int *w)
t_float sqrt5 = sqrt(5.0);
/* use rms of input to drive freq and reso */
- reso_rms = freq_rms = 0.0f;
+ reso_rms = freq_rms = 0.0;
for (i=0; i<n; i++){
/* first input is the reso frequency (absolute) */
t_float _freq = *freq++;
@@ -243,7 +243,7 @@ static t_int *resofilt_perform_threepole(t_int *w)
}
freq_rms = sqrt(freq_rms * inv_n) * inv_sr;
reso_rms = sqrt(reso_rms * inv_n);
- f = (freq_rms > 0.5f) ? 0.25f : freq_rms * 0.5f;
+ f = (freq_rms > 0.5) ? 0.25 : freq_rms * 0.5;
r = cbrt(reso_rms);
@@ -269,42 +269,42 @@ static t_int *resofilt_perform_threepole(t_int *w)
*/
/* compute phasor, radius and update eqs */
- phasor[0] = cos(2.0 * M_PI * r_prev * f_prev * 2.0f);
- phasor[1] = sin(2.0 * M_PI * r_prev * f_prev * 2.0f);
- phasor_rot[0] = cos(2.0 * M_PI * (r*f - r_prev*f_prev) * 2.0f * inv_n);
- phasor_rot[1] = sin(2.0 * M_PI * (r*f - r_prev*f_prev) * 2.0f * inv_n);
+ phasor[0] = cos(2.0 * M_PI * r_prev * f_prev * 2.0);
+ phasor[1] = sin(2.0 * M_PI * r_prev * f_prev * 2.0);
+ phasor_rot[0] = cos(2.0 * M_PI * (r*f - r_prev*f_prev) * 2.0 * inv_n);
+ phasor_rot[1] = sin(2.0 * M_PI * (r*f - r_prev*f_prev) * 2.0 * inv_n);
radior[0] = exp(f_prev * (-1.0 + r_prev)); /* dominant radius */
radior[1] = exp(f_prev * (-1.0 - sqrt5 * r_prev));
- radior_rot[0] = exp((f*(-1.0f + r) - f_prev * (-1.0 + r_prev)) * inv_n);
- radior_rot[1] = exp((f*(-1.0f - r) - f_prev * (-1.0 - sqrt5 * r_prev)) * inv_n);
+ radior_rot[0] = exp((f*(-1.0 + r) - f_prev * (-1.0 + r_prev)) * inv_n);
+ radior_rot[1] = exp((f*(-1.0 - r) - f_prev * (-1.0 - sqrt5 * r_prev)) * inv_n);
/* 303 like scaling */
if (1){
- float r3 = r_prev * r_prev * r_prev;
- scalor = 1.0f + (1.0f + 3.0f * r_prev);
+ t_float r3 = r_prev * r_prev * r_prev;
+ scalor = 1.0 + (1.0 + 3.0 * r_prev);
r3 = r * r * r;
- scalor_inc = ((1.0f + (1.0f + 3.0f * r3)) - scalor) * inv_n;
+ scalor_inc = ((1.0f + (1.0f + 3.0 * r3)) - scalor) * inv_n;
}
/* no scaling */
else{
- scalor = 1.0f;
- scalor_inc = 0.0f;
+ scalor = 1.0;
+ scalor_inc = 0.0;
}
ctl->c_f_prev = f;
ctl->c_r_prev = r;
- ctl->c_state[3] = 0.0f;
+ ctl->c_state[3] = 0.0;
/* perform filtering */
for (i=0; i<n; i++){
- float poleA[2], poleB[2];
- float *stateA = ctl->c_state;
- float *stateB = ctl->c_state+2;
+ t_float poleA[2], poleB[2];
+ t_float *stateA = ctl->c_state;
+ t_float *stateB = ctl->c_state+2;
- float x;
+ t_float x;
/* compute poles */
poleA[0] = radior[0] * phasor[0];
@@ -385,7 +385,7 @@ static void *resofilt_new(t_floatarg algotype)
/* set algo type */
- if (algotype == 3.0f){
+ if (algotype == 3.0){
post("resofilt~: 3-pole lowpass ladder vcf");
x->x_dsp = resofilt_perform_threepole;
}
diff --git a/modules/sbosc~.c b/modules/sbosc~.c
index 7b740b8..b337213 100644
--- a/modules/sbosc~.c
+++ b/modules/sbosc~.c
@@ -32,25 +32,25 @@
#define SHIFTTABSIZE ((sizeof(unsigned int) * 8) - LOGTABSIZE)
#define FRACTABSIZE (1<<SHIFTTABSIZE)
-#define INVFRACTABSIZE (1.0f / (float)(FRACTABSIZE))
+#define INVFRACTABSIZE (1.0 / (t_float)(FRACTABSIZE))
#define MASKFRACTABSIZE (FRACTABSIZE-1)
-#define PITCHLIMIT 20.0f
+#define PITCHLIMIT 20.0
-static float costable[TABSIZE];
+static t_float costable[TABSIZE];
-static inline void _exp_j2pi(unsigned int t, float *real, float *imag)
+static inline void _exp_j2pi(unsigned int t, t_float *real, t_float *imag)
{
unsigned int i1 = t >> SHIFTTABSIZE;
- float f2 = (t & MASKFRACTABSIZE) * INVFRACTABSIZE;
+ t_float f2 = (t & MASKFRACTABSIZE) * INVFRACTABSIZE;
unsigned int i2 = (i1+1) & MASKTABSIZE;
unsigned int i3 = (i1 - (TABSIZE>>2)) & MASKTABSIZE;
unsigned int i4 = (i2 + 1 - (TABSIZE>>2)) & MASKTABSIZE;
- float f1 = 1.0f - f2;
- float a1 = f1 * costable[i1];
- float a2 = f2 * costable[i2];
- float b1 = f1 * costable[i3];
- float b2 = f2 * costable[i4];
+ t_float f1 = 1.0 - f2;
+ t_float a1 = f1 * costable[i1];
+ t_float a2 = f2 * costable[i2];
+ t_float b1 = f1 * costable[i3];
+ t_float b2 = f2 * costable[i4];
*real = a1 + a2;
*imag = b1 + b2;
}
@@ -60,13 +60,13 @@ static t_class *sbosc_tilde_class;
typedef struct _sbosc_tilde
{
t_object x_obj;
- float x_f;
+ t_float x_f;
/* state vars */
unsigned int x_phase; // phase of main pitch osc
unsigned int x_phase_inc; // frequency of main pitch osc
unsigned int x_harmonic; // first harmonic
- float x_frac; // fraction of first harmonic
+ t_float x_frac; // fraction of first harmonic
} t_sbosc_tilde;
@@ -94,13 +94,13 @@ static t_int *sbosc_tilde_perform(t_int *w)
int n = (int)(w[6]);
int i;
- t_float pitch_to_phase = 4294967295.0f / sys_getsr();
+ t_float pitch_to_phase = 4294967295.0 / sys_getsr();
for (i = 0; i < n; i++)
{
- float p = *pitch++;
- float c = *center++;
- float r1,r2,i1,i2;
+ t_float p = *pitch++;
+ t_float c = *center++;
+ t_float r1,r2,i1,i2;
/* compute harmonic mixture */
unsigned int h1 = x->x_phase * x->x_harmonic;
@@ -109,8 +109,8 @@ static t_int *sbosc_tilde_perform(t_int *w)
_exp_j2pi(h2, &r2, &i2);
r1 *= x->x_frac;
i1 *= x->x_frac;
- r2 *= 1.0f - x->x_frac;
- i2 *= 1.0f - x->x_frac;
+ r2 *= 1.0 - x->x_frac;
+ i2 *= 1.0 - x->x_frac;
*out_real++ = r1 + r2;
*out_imag++ = i1 + i2;
@@ -121,13 +121,13 @@ static t_int *sbosc_tilde_perform(t_int *w)
/* check for phase wrap & update osc */
if ((x->x_phase <= x->x_phase_inc))
{
- float p_plus = (p < 0.0f) ? -p : p;
- float p_limit = (p_plus < PITCHLIMIT) ? PITCHLIMIT : p_plus;
- float c_plus = (c < 0.0f) ? -c : c;
- float harmonic = c_plus/p_limit;
+ t_float p_plus = (p < 0.0) ? -p : p;
+ t_float p_limit = (p_plus < PITCHLIMIT) ? PITCHLIMIT : p_plus;
+ t_float c_plus = (c < 0.0) ? -c : c;
+ t_float harmonic = c_plus/p_limit;
x->x_phase_inc = pitch_to_phase * p_limit;
x->x_harmonic = harmonic;
- x->x_frac = 1.0f - (harmonic - x->x_harmonic);
+ x->x_frac = 1.0 - (harmonic - x->x_harmonic);
}
@@ -149,7 +149,7 @@ static void sbosc_tilde_free(t_sbosc_tilde *x)
static void sbosc_tilde_phase(t_sbosc_tilde *x, t_floatarg f)
{
- x->x_phase = f * (1.0f / 4294967295.0f);
+ x->x_phase = f * (1.0 / 4294967295.0);
}
void sbosc_tilde_setup(void)
diff --git a/modules/scrollgrid1D~.c b/modules/scrollgrid1D~.c
index d59a101..b7e9aa2 100644
--- a/modules/scrollgrid1D~.c
+++ b/modules/scrollgrid1D~.c
@@ -55,17 +55,17 @@ typedef struct scrollgrid1D
} t_scrollgrid1D;
-static inline float _fixedpoint(float x, int n)
+static inline t_float _fixedpoint(t_float x, int n)
{
- int ix = (x + 0.5f);
+ int ix = (x + 0.5);
if (ix < 0) ix = 0;
else if (ix >= n) ix = n-1;
- return (float)ix;
+ return (t_float)ix;
}
-static inline float _sat(float x, float upper)
+static inline t_float _sat(t_float x, t_float upper)
{
- float lower = -1.0f;
+ t_float lower = -1.0;
if (x < lower) x = lower;
else if (x > upper) x = upper;
return x;
@@ -86,7 +86,7 @@ static t_int *scrollgrid1D_perform(t_int *w)
t_int n = (t_int)(w[2]);
t_int i;
- t_float inv_sr = 1.0f /sys_getsr();
+ t_float inv_sr = 1.0 /sys_getsr();
t_float state[3] = {ctl->c_x, ctl->c_y, ctl->c_z};
t_float c,f;
t_float pole[2], r1, r2;
@@ -97,24 +97,24 @@ static t_int *scrollgrid1D_perform(t_int *w)
for (i=0; i<n; i++){
/* get params */
- r1 = exp(1000.0f * inv_sr / (0.01f + fabs(*t1++)));
- r2 = exp(-1000.0f * inv_sr / (0.01f + fabs(*t2++)));
+ r1 = exp(1000.0 * inv_sr / (0.01 + fabs(*t1++)));
+ r2 = exp(-1000.0 * inv_sr / (0.01 + fabs(*t2++)));
f = *freq++;
o = (int)(*order++);
if (o < 2) o = 2;
- pole[0] = r1 * cos(2.0f * M_PI * inv_sr * f);
- pole[1] = r1 * sin(2.0f * M_PI * inv_sr * f);
+ pole[0] = r1 * cos(2.0 * M_PI * inv_sr * f);
+ pole[1] = r1 * sin(2.0 * M_PI * inv_sr * f);
/* debug */
//post("%f", r1);
/* base transform + clipping to prevent blowup */
/* projection onto axis containing fixed */
- x = _sat(0.5f * (state[0] - state[2]), (float)o);
+ x = _sat(0.5 * (state[0] - state[2]), (t_float)o);
/* the "pure" oscillation axis */
- y = _sat(0.5f * state[1], 1.0f);
+ y = _sat(0.5 * state[1], 1.0);
/* orthogonal complement of x */
- z = _sat(0.5f * (state[0] + state[2]), 1.0f);
+ z = _sat(0.5 * (state[0] + state[2]), 1.0);
/* output */
*outx++ = x;
@@ -127,7 +127,7 @@ static t_int *scrollgrid1D_perform(t_int *w)
/* inverse base transform */
state[0] = x + z;
- state[1] = 2.0f * y;
+ state[1] = 2.0 * y;
state[2] = -x + z;
diff --git a/modules/statwav~.c b/modules/statwav~.c
index 4fd2765..369a0a8 100644
--- a/modules/statwav~.c
+++ b/modules/statwav~.c
@@ -30,9 +30,9 @@ typedef struct _statwav_tilde
{
t_object x_obj;
int x_npoints;
- float *x_vec;
+ t_float *x_vec;
t_symbol *x_arrayname;
- float x_f;
+ t_float x_f;
} t_statwav_tilde;
static void *statwav_tilde_new(t_symbol *s)
@@ -51,9 +51,9 @@ static t_int *statwav_tilde_perform(t_int *w)
t_float *in = (t_float *)(w[2]);
t_float *out = (t_float *)(w[3]);
int n = (int)(w[4]);
- float maxindex;
+ t_float maxindex;
int imaxindex;
- float *buf = x->x_vec, *fp;
+ t_float *buf = x->x_vec, *fp;
int i;
maxindex = x->x_npoints;
@@ -64,15 +64,15 @@ static t_int *statwav_tilde_perform(t_int *w)
for (i = 0; i < n; i++)
{
- float phase = *in++;
- float modphase = phase - (int)phase;
- float findex;
+ t_float phase = *in++;
+ t_float modphase = phase - (int)phase;
+ t_float findex;
int index;
int ia, ib, ic, id;
- float frac, a, b, c, d, cminusb;
+ t_float frac, a, b, c, d, cminusb;
static int count;
- if (modphase < 0.0f) modphase += 1.0f;
+ if (modphase < 0.0) modphase += 1.0;
findex = modphase * maxindex;
index = findex;
@@ -92,8 +92,8 @@ static t_int *statwav_tilde_perform(t_int *w)
cminusb = c-b;
*out++ = b + frac * (
- cminusb - 0.5f * (frac-1.) * (
- (a - d + 3.0f * cminusb) * frac + (b - a - cminusb)
+ cminusb - 0.5 * (frac-1.) * (
+ (a - d + 3.0 * cminusb) * frac + (b - a - cminusb)
)
);
}
diff --git a/modules/tabreadmix~.c b/modules/tabreadmix~.c
index 9661ec4..74940a2 100644
--- a/modules/tabreadmix~.c
+++ b/modules/tabreadmix~.c
@@ -27,9 +27,9 @@ typedef struct _tabreadmix_tilde
{
t_object x_obj;
int x_npoints;
- float *x_vec;
+ t_float *x_vec;
t_symbol *x_arrayname;
- float x_f;
+ t_float x_f;
/* file position vars */
int x_currpos;
@@ -38,10 +38,10 @@ typedef struct _tabreadmix_tilde
/* cross fader state vars */
int x_xfade_size;
int x_xfade_phase;
- float x_xfade_cos;
- float x_xfade_sin;
- float x_xfade_state_c;
- float x_xfade_state_s;
+ t_float x_xfade_cos;
+ t_float x_xfade_sin;
+ t_float x_xfade_state_c;
+ t_float x_xfade_state_s;
} t_tabreadmix_tilde;
@@ -74,10 +74,10 @@ static t_int *tabreadmix_tilde_perform(t_int *w)
t_float *out = (t_float *)(w[3]);
int n = (int)(w[4]);
int maxxindex;
- float *buf = x->x_vec;
+ t_float *buf = x->x_vec;
int i;
- float currgain, prevgain;
- float c,s;
+ t_float currgain, prevgain;
+ t_float c,s;
int chunk;
int leftover;
int newpos = (int)*pos;
@@ -95,8 +95,8 @@ static t_int *tabreadmix_tilde_perform(t_int *w)
for (i = 0; i < chunk; i++){
/* compute crossfade gains from oscillator state */
- currgain = 0.5f - x->x_xfade_state_c;
- prevgain = 0.5f + x->x_xfade_state_c;
+ currgain = 0.5 - x->x_xfade_state_c;
+ prevgain = 0.5 + x->x_xfade_state_c;
/* check indices & wrap */
tabreadmix_tilde_wrapindices(x);
@@ -124,8 +124,8 @@ static t_int *tabreadmix_tilde_perform(t_int *w)
if (x->x_xfade_size == x->x_xfade_phase){
x->x_prevpos = x->x_currpos;
x->x_currpos = newpos;
- x->x_xfade_state_c = 0.5f;
- x->x_xfade_state_s = 0.0f;
+ x->x_xfade_state_c = 0.5;
+ x->x_xfade_state_s = 0.0;
x->x_xfade_phase = 0;
}
@@ -145,7 +145,7 @@ static void tabreadmix_tilde_blocksize(t_tabreadmix_tilde *x, t_float size)
{
double prev_phase;
int max;
- float fmax = (float)x->x_npoints * 0.5f;
+ t_float fmax = (t_float)x->x_npoints * 0.5;
if (size < 1.0) size = 1.0;
@@ -159,8 +159,8 @@ static void tabreadmix_tilde_blocksize(t_tabreadmix_tilde *x, t_float size)
x->x_xfade_size = (int)size;
- x->x_xfade_cos = cos(M_PI / (float)x->x_xfade_size);
- x->x_xfade_sin = sin(M_PI / (float)x->x_xfade_size);
+ x->x_xfade_cos = cos(M_PI / (t_float)x->x_xfade_size);
+ x->x_xfade_sin = sin(M_PI / (t_float)x->x_xfade_size);
/* make sure indices are inside array */
@@ -184,8 +184,8 @@ void tabreadmix_tilde_pitch(t_tabreadmix_tilde *x, t_float f)
void tabreadmix_tilde_chunks(t_tabreadmix_tilde *x, t_float f)
{
- if (f < 1.0f) f = 1.0f;
- tabreadmix_tilde_blocksize(x, (float)x->x_npoints / f);
+ if (f < 1.0) f = 1.0;
+ tabreadmix_tilde_blocksize(x, (t_float)x->x_npoints / f);
}
void tabreadmix_tilde_bang(t_tabreadmix_tilde *x, t_float f)
@@ -247,8 +247,8 @@ static void *tabreadmix_tilde_new(t_symbol *s)
x->x_xfade_size = 1024;
x->x_currpos = 0;
x->x_prevpos = 0;
- x->x_xfade_state_c = 0.5f;
- x->x_xfade_state_s = 0.0f;
+ x->x_xfade_state_c = 0.5;
+ x->x_xfade_state_s = 0.0;
tabreadmix_tilde_blocksize(x, 1024);
return (x);
}
diff --git a/modules/xfm~.c b/modules/xfm~.c
index f66831d..d02b58e 100644
--- a/modules/xfm~.c
+++ b/modules/xfm~.c
@@ -53,7 +53,7 @@ some (possible) enhancements:
#include <string.h>
#define SINSAMPLES 512
-#define MYPI 3.1415927
+#define MYPI 3.141592653589793
#define DISTORTED 0