Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
fdch committed Oct 20, 2024
1 parent de3c1da commit d2eb185
Showing 1 changed file with 40 additions and 43 deletions.
83 changes: 40 additions & 43 deletions src/lor~.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ typedef struct _lor
} t_lor;



static t_int *lor_perform(t_int *w)
{
t_lor *x = (t_lor *)(w[1]);
t_lor *x = (t_lor *)(w[1]);
t_sample *in1 = (t_sample *)(w[2]);
t_sample *in2 = (t_sample *)(w[3]);
t_sample *in3 = (t_sample *)(w[4]);
Expand All @@ -49,60 +48,59 @@ static t_int *lor_perform(t_int *w)
t_sample *out2 = (t_sample *)(w[7]);
t_sample *out3 = (t_sample *)(w[8]);
int n = (int)(w[9]);

float x0, y0, z0, x1, y1, z1;
float h, a, b, c;

while (n--)
{
h= *in1++;
a= *in2++;
b=*in3++;
c=*in4++;

x0 = x->x;
y0 = x->y;
z0 = x->z;

x1 = x0 + h * a * (y0 - x0);
y1 = y0 + h * (x0 * (b - z0) - y0);
z1 = z0 + h * (x0 * y0 - c * z0);

/*
distance = sqrt((x1 * x1) + (y1 * y1) + (z1 * z1));
*/

h = *in1++;
a = *in2++;
b = *in3++;
c = *in4++;

// get initial conditions
x0 = x->x;
y0 = x->y;
z0 = x->z;

// euler's method for differentiation
x1 = x0 + h * a * (y0 - x0);
y1 = y0 + h * (x0 * (b - z0) - y0);
z1 = z0 + h * (x0 * y0 - c * z0);

// feed the out buffer and the position with the new position
*out1++ = x->x = x1;
*out2++ = x->y = y1;
*out2++ = x->y = y1;
*out3++ = x->z = z1;

}
return (w+10);
}


void lor_tilde_free(t_lor *x)
{
inlet_free(x->in2);
inlet_free(x->in3);
inlet_free(x->in4);
outlet_free(x->out1);
outlet_free(x->out2);
outlet_free(x->out3);
inlet_free(x->in2);
inlet_free(x->in3);
inlet_free(x->in4);
outlet_free(x->out1);
outlet_free(x->out2);
outlet_free(x->out3);
}


static void lor_dsp(t_lor *x, t_signal **sp)
{
dsp_add(lor_perform, 9, x,
sp[0]->s_vec,
sp[1]->s_vec,
sp[2]->s_vec,
sp[3]->s_vec,
sp[4]->s_vec,
sp[5]->s_vec,
sp[6]->s_vec,
sp[0]->s_n);
dsp_add(lor_perform, 9, x,
sp[0]->s_vec,
sp[1]->s_vec,
sp[2]->s_vec,
sp[3]->s_vec,
sp[4]->s_vec,
sp[5]->s_vec,
sp[6]->s_vec,
sp[0]->s_n
);
}


Expand All @@ -113,7 +111,7 @@ void lor_initx(t_lor *x, int argcount, t_atom *argvec)
{
if (argvec[i].a_type == A_FLOAT)
{
x->x = argvec[i].a_w.w_float;
x->x = argvec[i].a_w.w_float;
}
}
}
Expand All @@ -124,7 +122,7 @@ void lor_inity(t_lor *x, int argcount, t_atom *argvec)
{
if (argvec[i].a_type == A_FLOAT)
{
x->y = argvec[i].a_w.w_float;
x->y = argvec[i].a_w.w_float;
}
}
}
Expand All @@ -135,7 +133,7 @@ void lor_initz(t_lor *x, int argcount, t_atom *argvec)
{
if (argvec[i].a_type == A_FLOAT)
{
x->z = argvec[i].a_w.w_float;
x->z = argvec[i].a_w.w_float;
}
}
}
Expand Down Expand Up @@ -163,13 +161,12 @@ static void *lor_new(void)
void lor_tilde_setup(void)
{
lor_class = class_new(gensym("lor~"),
(t_newmethod)lor_new, 0,
sizeof(t_lor), 0, A_DEFFLOAT, 0);
(t_newmethod)lor_new, 0, sizeof(t_lor), 0, A_DEFFLOAT, 0);

CLASS_MAINSIGNALIN(lor_class, t_lor, x_f);

class_addmethod(lor_class, (t_method)lor_dsp, gensym("dsp"), 0);
class_addmethod(lor_class, (t_method)lor_initx, gensym("initx"), A_GIMME, 0);
class_addmethod(lor_class, (t_method)lor_inity, gensym("inity"), A_GIMME, 0);
class_addmethod(lor_class, (t_method)lor_initz, gensym("initz"), A_GIMME, 0);
}
}

0 comments on commit d2eb185

Please sign in to comment.