Say we are programming an external and we have a user-defined struct like:
typedef struct { float dist[8]; float ang[8]; float gain[8]; }loudspeakers;
Is there a way to output and receive a pointer to this struct from and to oulets and inlets of pd objects and so communicate the data between them? The outlet_pointer function seems to be only for the t_gpointer type which is a special graphic pointer. Many thanks. Isi
Isidro Gonzalez wrote:
Say we are programming an external and we have a user-defined struct like:
typedef struct { float dist[8]; float ang[8]; float gain[8]; }loudspeakers;
Is there a way to output and receive a pointer to this struct from and to oulets and inlets of pd objects and so communicate the data between them?
One way would be to convert a text representation of the pointer into a symbol and send that: char buf[9]; /*each byte of the pointer will be printed as two hex characters*/ loudspeakers *pointer_to_loudspeakers; t_symbol a_symbol;
sprintf(buf, "%p", pointer_to_loudspeakers); a_symbol = gensym(buf);
Then send a_symbol to other objects.
A symbol method in the receiver would convert the symbol name back into a pointer with: sscanf(s->s_name, "%p", &(void*)pointer_to_loudspeakers);
Another way, that uses no c, would be to load the 24 floats into a table and access it by name using [tabread loudspeakers] and [tabwrite loudspeakers].
Martin
Hi Isi,
There's no direct way to do this but it's possible to share data between objects using symbols. An example is the delay objects (d_delay.c) - the useful functions are "pd_bind", "pd_unbind" and "pd_findbyclass".
cheers Miller
On Sat, Nov 22, 2008 at 03:55:43PM -0800, Isidro Gonzalez wrote:
Say we are programming an external and we have a user-defined struct like:
typedef struct { float dist[8]; float ang[8]; float gain[8]; }loudspeakers;
Is there a way to output and receive a pointer to this struct from and to oulets and inlets of pd objects and so communicate the data between them? The outlet_pointer function seems to be only for the t_gpointer type which is a special graphic pointer. Many thanks. Isi
Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev