not sure how it goes on your OS, but here on osx, i think this is what you want:
contents -> Resources -> src -> d_osc.c
/* ------------------------ osc~ ----------------------------- */
static t_class *osc_class, *scalarosc_class;
typedef struct _osc
{
t_object x_obj;
double x_phase;
float x_conv;
float x_f; /* frequency if scalar */
} t_osc;
static void *osc_new(t_floatarg f)
{
t_osc *x = (t_osc *)pd_new(osc_class);
x->x_f = f;
outlet_new(&x->x_obj, gensym("signal"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
x->x_phase = 0;
x->x_conv = 0;
return (x);
}
static t_int *osc_perform(t_int *w)
{
t_osc *x = (t_osc *)(w[1]);
t_float *in = (t_float *)(w[2]);
t_float *out = (t_float *)(w[3]);
int n = (int)(w[4]);
float *tab = cos_table, *addr, f1, f2, frac;
double dphase = x->x_phase + UNITBIT32;
int normhipart;
union tabfudge tf;
float conv = x->x_conv;
tf.tf_d = UNITBIT32;
normhipart = tf.tf_i[HIOFFSET];
#if 0
while (n--)
{
tf.tf_d = dphase;
dphase += *in++ * conv;
addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
tf.tf_i[HIOFFSET] = normhipart;
frac = tf.tf_d - UNITBIT32;
f1 = addr[0];
f2 = addr[1];
*out++ = f1 + frac * (f2 - f1);
}
#endif
#if 1
tf.tf_d = dphase;
dphase += *in++ * conv;
addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
tf.tf_i[HIOFFSET] = normhipart;
frac = tf.tf_d - UNITBIT32;
while (--n)
{
tf.tf_d = dphase;
f1 = addr[0];
dphase += *in++ * conv;
f2 = addr[1];
addr = tab + (tf.tf_i[HIOFFSET] & (COSTABSIZE-1));
tf.tf_i[HIOFFSET] = normhipart;
*out++ = f1 + frac * (f2 - f1);
frac = tf.tf_d - UNITBIT32;
}
f1 = addr[0];
f2 = addr[1];
*out++ = f1 + frac * (f2 - f1);
#endif
tf.tf_d = UNITBIT32 * COSTABSIZE;
normhipart = tf.tf_i[HIOFFSET];
tf.tf_d = dphase + (UNITBIT32 * COSTABSIZE - UNITBIT32);
tf.tf_i[HIOFFSET] = normhipart;
x->x_phase = tf.tf_d - UNITBIT32 * COSTABSIZE;
return (w+5);
}
static void osc_dsp(t_osc *x, t_signal **sp)
{
x->x_conv = COSTABSIZE/sp[0]->s_sr;
dsp_add(osc_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
}
static void osc_ft1(t_osc *x, t_float f)
{
x->x_phase = COSTABSIZE * f;
}
static void osc_setup(void)
{
osc_class = class_new(gensym("osc~"), (t_newmethod)osc_new, 0,
sizeof(t_osc), 0, A_DEFFLOAT, 0);
CLASS_MAINSIGNALIN(osc_class, t_osc, x_f);
class_addmethod(osc_class, (t_method)osc_dsp, gensym("dsp"), 0);
class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0);
cos_maketable();
}