[PD-dev] trivial question (please help me)
Jamie Bullock
jamie at postlude.co.uk
Tue Dec 13 11:27:26 CET 2005
Hi Javier,
It works fine for me; what specific problem (e.g. won't compile, wrong behaviour in patch) are you experiencing?
Jamie
On Mon, 12 Dec 2005 18:24:46 +0000
"Javier Jimenez Urbano" <j2urban at hotmail.com> wrote:
> Hi, I'd like to make a question. Is it posible to create an external (dsp
> object) with two independient signal outlets? I'm newbie in externals
> writing and i can't resolve this.
>
> I'm trying to extend the external from the Johannes M Zmölning manual called
> pan~. i want to create a stereopan~ and this is the code: (it don't work as
> it must be). Can anyone help me?
>
> #include "m_pd.h"
>
> static t_class *stereopan_tilde_class;
>
> typedef struct _stereopan_tilde {
> t_object x_obj;
> t_sample f_pan;
> t_sample f;
> } t_stereopan_tilde;
>
> t_int *stereopan_tilde_perform(t_int *w)
> {
> t_stereopan_tilde *x = (t_stereopan_tilde *)(w[1]);
> t_sample *in1 = (t_sample *)(w[2]);
> t_sample *in2 = (t_sample *)(w[3]);
> t_sample *outL = (t_sample *)(w[4]);
> t_sample *outR = (t_sample *)(w[5]);
> int n = (int)(w[6]);
> t_sample f_pan = (x->f_pan<0)?0.0:(x->f_pan>1)?1.0:x->f_pan;
> while (n--)
> {
>
> *outL++ = (*in1++)*(1-f_pan);
> *outR++ = (*in2++)*f_pan;
>
> }
>
> return (w+7);
> }
>
> void stereopan_tilde_dsp(t_stereopan_tilde *x, t_signal **sp)
> {
> dsp_add(stereopan_tilde_perform, 6, x, sp[0]->s_vec, sp[1]->s_vec,
> sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n);
> }
>
> void *stereopan_tilde_new(t_floatarg f)
> {
> t_stereopan_tilde *x = (t_stereopan_tilde *)pd_new(stereopan_tilde_class);
> x->f_pan = f;
> inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
> floatinlet_new (&x->x_obj, &x->f_pan);
> outlet_new(&x->x_obj, &s_signal);
> outlet_new(&x->x_obj, &s_signal);
> return (void *)x;
> }
>
> void stereopan_tilde_setup(void) {
> stereopan_tilde_class =
> class_new(gensym("stereopan~"),(t_newmethod)stereopan_tilde_new,0,
> sizeof(t_stereopan_tilde),
> CLASS_DEFAULT, A_DEFFLOAT, 0);
> class_addmethod(stereopan_tilde_class, (t_method)stereopan_tilde_dsp,
> gensym("dsp"), 0);
> CLASS_MAINSIGNALIN(stereopan_tilde_class, t_stereopan_tilde, f);
> }
>
>
>
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev
More information about the Pd-dev
mailing list