[PD] writing dsp externals for variable number of inlets

2011-05-07 Thread Ahmet Kizilay
Hello,
I want to write an external which creates the signal inlets dynamically
depending on the number of arguments, just like the multiplex~ object from
zexy.
My question is about writing the dsp_add function. How do I set the
arguments when I don't exactly know how many signals I will be handling?

I hope my question is appropriate for the list (first post)?

Thanks.

-- 
ahmet kizilay
http://www.ahmetkizilay.com
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] writing dsp externals for variable number of inlets

2011-05-07 Thread Charles Henry
Hi, Ahmet

I don't know how to create a variable argument type of function definition
for this purpose, but it should be clear that your dsp function knows how
many inlets there will be.  You will be setting the number of inlets when
the object is created.

You could make a maximum number of inlets and add a data structure element
to store the number of inlets.  Then, in your dsp function, put a case
statement to look up the dsp_add call with the correct number of arguments.


I'm not sure that's the best way, since dsp_add has a variable number of
arguments in its definition.  It would make sense to me if function calls
had to have a fixed number of arguments, but I'm just not sure.

Chuck

On Sat, May 7, 2011 at 10:01 AM, Ahmet Kizilay ahmet.kizi...@gmail.comwrote:

 Hello,
 I want to write an external which creates the signal inlets dynamically
 depending on the number of arguments, just like the multiplex~ object from
 zexy.
 My question is about writing the dsp_add function. How do I set the
 arguments when I don't exactly know how many signals I will be handling?

 I hope my question is appropriate for the list (first post)?

 Thanks.

 --
 ahmet kizilay
 http://www.ahmetkizilay.com

 ___
 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


Re: [PD] writing dsp externals for variable number of inlets

2011-05-07 Thread Ahmet Kizilay
Hi,
Thanks for your reply.
I looked through the source code and found out about the dsp_addv method,
which was created specifically for this purpose.
Best,

On Sat, May 7, 2011 at 7:43 PM, Charles Henry czhe...@gmail.com wrote:

 Hi, Ahmet

 I don't know how to create a variable argument type of function definition
 for this purpose, but it should be clear that your dsp function knows how
 many inlets there will be.  You will be setting the number of inlets when
 the object is created.

 You could make a maximum number of inlets and add a data structure element
 to store the number of inlets.  Then, in your dsp function, put a case
 statement to look up the dsp_add call with the correct number of arguments.


 I'm not sure that's the best way, since dsp_add has a variable number of
 arguments in its definition.  It would make sense to me if function calls
 had to have a fixed number of arguments, but I'm just not sure.

 Chuck

 On Sat, May 7, 2011 at 10:01 AM, Ahmet Kizilay ahmet.kizi...@gmail.comwrote:

 Hello,
 I want to write an external which creates the signal inlets dynamically
 depending on the number of arguments, just like the multiplex~ object from
 zexy.
 My question is about writing the dsp_add function. How do I set the
 arguments when I don't exactly know how many signals I will be handling?

 I hope my question is appropriate for the list (first post)?

 Thanks.

 --
 ahmet kizilay
 http://www.ahmetkizilay.com

 ___
 Pd-list@iem.at mailing list
 UNSUBSCRIBE and account-management -
 http://lists.puredata.info/listinfo/pd-list





-- 
ahmet kizilay
http://www.ahmetkizilay.com
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] writing dsp externals for variable number of inlets

2011-05-07 Thread Mathieu Bouchard

On Sat, 7 May 2011, Ahmet Kizilay wrote:

Hello, I want to write an external which creates the signal inlets 
dynamically depending on the number of arguments, just like the 
multiplex~ object from zexy. My question is about writing the dsp_add 
function. How do I set the arguments when I don't exactly know how many 
signals I will be handling?


For passing a variable number of args to dsp_add itself, use dsp_addv 
instead.


In any case, one of the fixed arguments has to be saying how many 
arguments there will be, or one of the variable arguments has to be 
telling it, or one of the arguments has to point to a struct that says it.


It's similar to how functions that depend on stdarg.h provide variable 
length lists of arguments. class_addmethod says end of arguments by 
passing A_NULL. printf's format strings have %-codes that tell you how 
many extra args there are. some functions in pd want format strings like 
ffsfsffp; to say two floats, one symbol, one float, etc., to announce 
the upcoming arguments in a function call. some other functions pass just 
an integer that says n arguments are upcoming, such as dsp_add itself.


(you know what I mean ?)

 ___
| Mathieu Bouchard  tél: +1.514.383.3801  Villeray, Montréal, QC
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list