aboutsummaryrefslogtreecommitdiff
path: root/modules++
diff options
context:
space:
mode:
Diffstat (limited to 'modules++')
-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
7 files changed, 323 insertions, 270 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);