Dear List,
I' ve managed to program simple objects for pd so far where inlets and
outlets were only scalars. But the amount of numbers I want to send out
increased and it makes no sense to have for everything an outlet:
Could anybody briefly tell me how to output a list through an outlet, say a list, containing three floats.
In particular, how to I have to change these lines?
x->list_out = outlet_new(&x->x_obj, &s_???????????????);
outlet_???????(x->list_out, x->???????????);
A quick reply would be very appreciated,
Thanks,
Florian
Depending on what you are doing I would suggest flext for most uses, the API is cleaner, has more helper functions and is easier to learn that native PD externals.
you can look at the source for "pso" which outputs complex lists and has multiple outlets. in externals/bbogart/externals (uses flext).
off hand I can't remember how to output lists in native externals, output_list?
B.
Florian Grond wrote:
Dear List,
I' ve managed to program simple objects for pd so far where inlets and outlets were only scalars. But the amount of numbers I want to send out increased and it makes no sense to have for everything an outlet:
Could anybody briefly tell me how to output a list through an outlet, say a list, containing three floats.
In particular, how to I have to change these lines?
x->list_out = outlet_new(&x->x_obj, &s_???????????????);
outlet_???????(x->list_out, x->???????????);
A quick reply would be very appreciated,
Thanks,
Florian
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Fri, Apr 08, 2005 at 10:34:45AM -0400, B. Bogart wrote:
Depending on what you are doing I would suggest flext for most uses, the API is cleaner, has more helper functions and is easier to learn that native PD externals.
you can look at the source for "pso" which outputs complex lists and has multiple outlets. in externals/bbogart/externals (uses flext).
off hand I can't remember how to output lists in native externals, output_list?
t_atom at[5];
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0);
SETFLOAT(at+3,b1/a0);
SETFLOAT(at+4,b2/a0);
outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
B.
Florian Grond wrote:
Dear List,
I' ve managed to program simple objects for pd so far where inlets and outlets were only scalars. But the amount of numbers I want to send out increased and it makes no sense to have for everything an outlet:
Could anybody briefly tell me how to output a list through an outlet, say a list, containing three floats.
In particular, how to I have to change these lines?
x->list_out = outlet_new(&x->x_obj, &s_???????????????);
outlet_???????(x->list_out, x->???????????);
A quick reply would be very appreciated,
Thanks,
Florian
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Fri, 8 Apr 2005, Florian Grond wrote:
I' ve managed to program simple objects for pd so far where inlets and outlets were only scalars. But the amount of numbers I want to send out increased and it makes no sense to have for everything an outlet: Could anybody briefly tell me how to output a list through an outlet, say a list, containing three floats. In particular, how to I have to change these lines? x->list_out = outlet_new(&x->x_obj, &s_???????????????); outlet_???????(x->list_out, x->???????????); A quick reply would be very appreciated,
from include/m_pd.h:
EXTERN void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv); EXTERN void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
So that to do like a msgbox containing "2 3 5 7" you could do:
t_atom t[4]; SETFLOAT(t[0],2); SETFLOAT(t[1],3); SETFLOAT(t[2],5); SETFLOAT(t[3],7); outlet_anything(my_outlet,gensym("list"),sizeof(t)/sizeof(t_atom),t);
but i don't know why outlet_list has a t_symbol *s argument, and i never used it. (I also am using a wrapper, and mine only ever uses outlet_anything)
PS: I just had a look at the source code of Pd and it seems that the s of outlet_list is just ignored, that is, just assumed to be gensym("list"). that's somewhat confusing, but for compatibility, the s argument can't be removed.
,-o---------o---------o---------o-. ,----. |
| The Diagram is the Program (TM) | | ,-o----------------------------o-.
-o-----------------------------o-' | | Mathieu Bouchard | | |---' | http://artengine.ca/matju | | |
-o------------------------------'
On Fri, 8 Apr 2005, Mathieu Bouchard wrote:
t_atom t[4]; SETFLOAT(t[0],2); SETFLOAT(t[1],3); SETFLOAT(t[2],5); SETFLOAT(t[3],7); outlet_anything(my_outlet,gensym("list"),sizeof(t)/sizeof(t_atom),t);
Actually Carmen's code is better, as it has less typos.
(Sigh)
,-o---------o---------o---------o-. ,----. |
| The Diagram is the Program (TM) | | ,-o----------------------------o-.
-o-----------------------------o-' | | Mathieu Bouchard | | |---' | http://artengine.ca/matju | | |
-o------------------------------'
Hello list,
Mathieu Bouchard a écrit :
So that to do like a msgbox containing "2 3 5 7" you could do:
t_atom t[4]; SETFLOAT(t[0],2); SETFLOAT(t[1],3); SETFLOAT(t[2],5); SETFLOAT(t[3],7); outlet_anything(my_outlet,gensym("list"),sizeof(t)/sizeof(t_atom),t);
In this case "outlet_anything(my_outlet,gensym("list"),4,t); " is better ;-)
but i don't know why outlet_list has a t_symbol *s argument, and i never used it. (I also am using a wrapper, and mine only ever uses outlet_anything)
PS: I just had a look at the source code of Pd and it seems that the s of outlet_list is just ignored, that is, just assumed to be gensym("list"). that's somewhat confusing, but for compatibility, the s argument can't be removed.
The t_symbol *s argument is ignored if it's "gensym("list")" but is bounded to the list if it's different.
t_atom t[4]; SETFLOAT(t[0],2); SETFLOAT(t[1],3); SETFLOAT(t[2],5); SETFLOAT(t[3],7); outlet_anything(my_outlet,gensym("floatList"),4,t);
will output :
floatList 2 3 5 7
on my_outlet. You can then route it as you want without mixing it with other lists ;-).
Bye,
Nicolas