diff options
Diffstat (limited to 'bp.c')
-rw-r--r-- | bp.c | 52 |
1 files changed, 26 insertions, 26 deletions
@@ -4,21 +4,21 @@ typedef struct bpctl
{
- float c_x1;
- float c_x2;
- float c_coef1;
- float c_coef2;
- float c_gain;
+ t_float c_x1;
+ t_float c_x2;
+ t_float c_coef1;
+ t_float c_coef2;
+ t_float c_gain;
} t_bpctl;
typedef struct bp
{
t_object x_obj;
- float x_freq;
- float x_q;
+ t_float x_freq;
+ t_float x_q;
t_bpctl x_cspace;
t_bpctl *x_ctl;
- float x_f;
+ t_float x_f;
} t_bp;
t_class *bp_class;
@@ -39,29 +39,29 @@ static void *bp_new(t_floatarg f, t_floatarg q) return (x);
}
-static float bp_qcos(float f)
+static t_float bp_qcos(t_float f)
{
- if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f)
+ if (f >= -(0.5*3.141592653589793) && f <= 0.5*3.141592653589793)
{
- float g = f*f;
- return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5f) + 1);
+ t_float g = f*f;
+ return (((g*g*g * (-1.0/720.0) + g*g*(1.0/24.0)) - g*0.5) + 1);
}
else return (0);
}
static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q)
{
- float r, oneminusr, omega;
- if (f < 0.0001f) f = 0.0001f;
+ t_float r, oneminusr, omega;
+ if (f < 0.0001) f = 0.0001;
if (q < 0) q = 0;
x->x_freq = f;
x->x_q = q;
- omega = f * (2.0f * 3.14159f);
- if (q < 0.001) oneminusr = 1.0f;
+ omega = f * (2.0 * 3.141592653589793);
+ if (q < 0.001) oneminusr = 1.0;
else oneminusr = omega/q;
- if (oneminusr > 1.0f) oneminusr = 1.0f;
- r = 1.0f - oneminusr;
- x->x_ctl->c_coef1 = 2.0f * bp_qcos(omega) * r;
+ if (oneminusr > 1.0) oneminusr = 1.0;
+ r = 1.0 - oneminusr;
+ x->x_ctl->c_coef1 = 2.0 * bp_qcos(omega) * r;
x->x_ctl->c_coef2 = - r * r;
x->x_ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega);
/* post("r %f, omega %f, coef1 %f, coef2 %f",
@@ -85,15 +85,15 @@ static void bp_clear(t_bp *x, t_floatarg q) static void bp_perform(t_bp *x, t_float in)
{
- float out;
+ t_float out;
t_bpctl *c = x->x_ctl;
- float last = c->c_x1;
- float prev = c->c_x2;
- float coef1 = c->c_coef1;
- float coef2 = c->c_coef2;
- float gain = c->c_gain;
+ t_float last = c->c_x1;
+ t_float prev = c->c_x2;
+ t_float coef1 = c->c_coef1;
+ t_float coef2 = c->c_coef2;
+ t_float gain = c->c_gain;
- float output = in + coef1 * last + coef2 * prev;
+ t_float output = in + coef1 * last + coef2 * prev;
out = gain * output;
prev = last;
|