Csound Csound-dev Csound-tekno Search About

Using arrays as arguments

Date2016-01-21 05:38
FromGuillermo Senna
SubjectUsing arrays as arguments
Hi,

Is there a way to use an entire array as an argument list?

I need some way of doing this:
iArr[] init 10
event_i "i", 1, 0, 1, iArr

Actually, what I'm trying to achieve is to generate a table using an 
array for its arguments. The problem is that I don't know the size of 
the array until run-time.

Thanks.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-01-21 07:20
FromHlöðver Sigurðsson
SubjectRe: Using arrays as arguments
You could do:

iArr[] init 10
iArr fillarray 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2], iArr[3], iArr[4], iArr[5], iArr[6], iArr[7], iArr[8], iArr[9]

Doing variable argument count can be pain, but you would have to loop. If you dont want to initialize an Array to a fixed size, you could use Joachim Heinz's string arrays, then it's easy to just make an opcode that will count the number of values in an array and make an event function with the amount of parameters nedded (or requested for).

Maybe this is helpful, you have this opcode at both i- and k- rate.
https://github.com/csudo/csudo/blob/master/strays/StrayGetNum.csd

2016-01-21 6:38 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi,

Is there a way to use an entire array as an argument list?

I need some way of doing this:
iArr[] init 10
event_i "i", 1, 0, 1, iArr

Actually, what I'm trying to achieve is to generate a table using an array for its arguments. The problem is that I don't know the size of the array until run-time.

Thanks.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-01-21 07:29
FromGuillermo Senna
SubjectRe: Using arrays as arguments
Hi Hlöðver,

I've just implemented what you propose using a fixed size array. I'm already using StrayGetNum. But I was wondering if there was a way to write an event_i statement that has a variable (known at run-time) argument list. I have not been able to solve that.

What I mean is I've my variable-sized array already filled with the correct numbers, but how can I create an event_i that takes that information. Fixed-size arrays/arguments seems to be the only way. Isn't it?


On 21/01/16 04:20, Hlöðver Sigurðsson wrote:
You could do:

iArr[] init 10
iArr fillarray 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2], iArr[3], iArr[4], iArr[5], iArr[6], iArr[7], iArr[8], iArr[9]

Doing variable argument count can be pain, but you would have to loop. If you dont want to initialize an Array to a fixed size, you could use Joachim Heinz's string arrays, then it's easy to just make an opcode that will count the number of values in an array and make an event function with the amount of parameters nedded (or requested for).

Maybe this is helpful, you have this opcode at both i- and k- rate.
https://github.com/csudo/csudo/blob/master/strays/StrayGetNum.csd

2016-01-21 6:38 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi,

Is there a way to use an entire array as an argument list?

I need some way of doing this:
iArr[] init 10
event_i "i", 1, 0, 1, iArr

Actually, what I'm trying to achieve is to generate a table using an array for its arguments. The problem is that I don't know the size of the array until run-time.

Thanks.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Date2016-01-21 07:53
FromHlöðver Sigurðsson
SubjectRe: Using arrays as arguments
You will have to make a if tree or loop_lt loop. But an ugly if tree yould solve it easily, something like;

iparm count iArray

if iparm == 1 then
 event_i "i", 1, 0, 1, iArr[0]
elseif iparm == 2 then
 event_i "i", 1, 0, 1, iArr[0], iArr[1]
elseif iparm == 3 then
 event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2]

.....etc...

endif

you have to know the size of the string array or normal array, where are you filling the array, with score event, orchestra? Whereever the source of the array is coming from, you should be able to find a way to count how many arguments you are providing for the parameters in the score event.


2016-01-21 8:29 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi Hlöðver,

I've just implemented what you propose using a fixed size array. I'm already using StrayGetNum. But I was wondering if there was a way to write an event_i statement that has a variable (known at run-time) argument list. I have not been able to solve that.

What I mean is I've my variable-sized array already filled with the correct numbers, but how can I create an event_i that takes that information. Fixed-size arrays/arguments seems to be the only way. Isn't it?



On 21/01/16 04:20, Hlöðver Sigurðsson wrote:
You could do:

iArr[] init 10
iArr fillarray 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2], iArr[3], iArr[4], iArr[5], iArr[6], iArr[7], iArr[8], iArr[9]

Doing variable argument count can be pain, but you would have to loop. If you dont want to initialize an Array to a fixed size, you could use Joachim Heinz's string arrays, then it's easy to just make an opcode that will count the number of values in an array and make an event function with the amount of parameters nedded (or requested for).

Maybe this is helpful, you have this opcode at both i- and k- rate.
https://github.com/csudo/csudo/blob/master/strays/StrayGetNum.csd

2016-01-21 6:38 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi,

Is there a way to use an entire array as an argument list?

I need some way of doing this:
iArr[] init 10
event_i "i", 1, 0, 1, iArr

Actually, what I'm trying to achieve is to generate a table using an array for its arguments. The problem is that I don't know the size of the array until run-time.

Thanks.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-01-21 08:05
FromGuillermo Senna
SubjectRe: Using arrays as arguments
Unfortunately it is a Cabbage textbox, so the argument count could be anything between 0 and infinity. lol.

It would be nice to have an event_i opcode that takes an array as a (single) parameter and then automatically expands the thing.

On 21/01/16 04:53, Hlöðver Sigurðsson wrote:
You will have to make a if tree or loop_lt loop. But an ugly if tree yould solve it easily, something like;

iparm count iArray

if iparm == 1 then
 event_i "i", 1, 0, 1, iArr[0]
elseif iparm == 2 then
 event_i "i", 1, 0, 1, iArr[0], iArr[1]
elseif iparm == 3 then
 event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2]

.....etc...

endif

you have to know the size of the string array or normal array, where are you filling the array, with score event, orchestra? Whereever the source of the array is coming from, you should be able to find a way to count how many arguments you are providing for the parameters in the score event.


2016-01-21 8:29 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi Hlöðver,

I've just implemented what you propose using a fixed size array. I'm already using StrayGetNum. But I was wondering if there was a way to write an event_i statement that has a variable (known at run-time) argument list. I have not been able to solve that.

What I mean is I've my variable-sized array already filled with the correct numbers, but how can I create an event_i that takes that information. Fixed-size arrays/arguments seems to be the only way. Isn't it?



On 21/01/16 04:20, Hlöðver Sigurðsson wrote:
You could do:

iArr[] init 10
iArr fillarray 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2], iArr[3], iArr[4], iArr[5], iArr[6], iArr[7], iArr[8], iArr[9]

Doing variable argument count can be pain, but you would have to loop. If you dont want to initialize an Array to a fixed size, you could use Joachim Heinz's string arrays, then it's easy to just make an opcode that will count the number of values in an array and make an event function with the amount of parameters nedded (or requested for).

Maybe this is helpful, you have this opcode at both i- and k- rate.
https://github.com/csudo/csudo/blob/master/strays/StrayGetNum.csd

2016-01-21 6:38 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi,

Is there a way to use an entire array as an argument list?

I need some way of doing this:
iArr[] init 10
event_i "i", 1, 0, 1, iArr

Actually, what I'm trying to achieve is to generate a table using an array for its arguments. The problem is that I don't know the size of the array until run-time.

Thanks.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Date2016-01-21 08:09
FromHlöðver Sigurðsson
SubjectRe: Using arrays as arguments
Maybe someone has written an udo for that (something in github csudo?), if not, then you could write udo using while and/or loop_lt. If you succeed, then yes, I could see a use for that myself if you would share :)


2016-01-21 9:05 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Unfortunately it is a Cabbage textbox, so the argument count could be anything between 0 and infinity. lol.

It would be nice to have an event_i opcode that takes an array as a (single) parameter and then automatically expands the thing.


On 21/01/16 04:53, Hlöðver Sigurðsson wrote:
You will have to make a if tree or loop_lt loop. But an ugly if tree yould solve it easily, something like;

iparm count iArray

if iparm == 1 then
 event_i "i", 1, 0, 1, iArr[0]
elseif iparm == 2 then
 event_i "i", 1, 0, 1, iArr[0], iArr[1]
elseif iparm == 3 then
 event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2]

.....etc...

endif

you have to know the size of the string array or normal array, where are you filling the array, with score event, orchestra? Whereever the source of the array is coming from, you should be able to find a way to count how many arguments you are providing for the parameters in the score event.


2016-01-21 8:29 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi Hlöðver,

I've just implemented what you propose using a fixed size array. I'm already using StrayGetNum. But I was wondering if there was a way to write an event_i statement that has a variable (known at run-time) argument list. I have not been able to solve that.

What I mean is I've my variable-sized array already filled with the correct numbers, but how can I create an event_i that takes that information. Fixed-size arrays/arguments seems to be the only way. Isn't it?



On 21/01/16 04:20, Hlöðver Sigurðsson wrote:
You could do:

iArr[] init 10
iArr fillarray 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2], iArr[3], iArr[4], iArr[5], iArr[6], iArr[7], iArr[8], iArr[9]

Doing variable argument count can be pain, but you would have to loop. If you dont want to initialize an Array to a fixed size, you could use Joachim Heinz's string arrays, then it's easy to just make an opcode that will count the number of values in an array and make an event function with the amount of parameters nedded (or requested for).

Maybe this is helpful, you have this opcode at both i- and k- rate.
https://github.com/csudo/csudo/blob/master/strays/StrayGetNum.csd

2016-01-21 6:38 GMT+01:00 Guillermo Senna <gsenna@gmail.com>:
Hi,

Is there a way to use an entire array as an argument list?

I need some way of doing this:
iArr[] init 10
event_i "i", 1, 0, 1, iArr

Actually, what I'm trying to achieve is to generate a table using an array for its arguments. The problem is that I don't know the size of the array until run-time.

Thanks.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-01-21 08:16
Fromjoachim heintz
SubjectRe: Using arrays as arguments
hi guillermo -

if i understand correctly, you have a string first.  wouldn't it be 
better to send and receive this string (could be done with the scoreline 
opcode) instead of an array?

best -
	joachim


On 21/01/16 08:29, Guillermo Senna wrote:
> Hi Hlöðver,
>
> I've just implemented what you propose using a fixed size array. I'm
> already using StrayGetNum. But I was wondering if there was a way to
> write an event_i statement that has a variable (known at run-time)
> argument list. I have not been able to solve that.
>
> What I mean is I've my variable-sized array already filled with the
> correct numbers, but how can I create an event_i that takes that
> information. Fixed-size arrays/arguments seems to be the only way. Isn't it?
>
>
> On 21/01/16 04:20, Hlöðver Sigurðsson wrote:
>> You could do:
>>
>> iArr[] init 10
>> iArr fillarray 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
>> event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2], iArr[3], iArr[4],
>> iArr[5], iArr[6], iArr[7], iArr[8], iArr[9]
>>
>> Doing variable argument count can be pain, but you would have to loop.
>> If you dont want to initialize an Array to a fixed size, you could use
>> Joachim Heinz's string arrays, then it's easy to just make an opcode
>> that will count the number of values in an array and make an event
>> function with the amount of parameters nedded (or requested for).
>>
>> Maybe this is helpful, you have this opcode at both i- and k- rate.
>> https://github.com/csudo/csudo/blob/master/strays/StrayGetNum.csd
>>
>> 2016-01-21 6:38 GMT+01:00 Guillermo Senna > >:
>>
>>     Hi,
>>
>>     Is there a way to use an entire array as an argument list?
>>
>>     I need some way of doing this:
>>     iArr[] init 10
>>     event_i "i", 1, 0, 1, iArr
>>
>>     Actually, what I'm trying to achieve is to generate a table using
>>     an array for its arguments. The problem is that I don't know the
>>     size of the array until run-time.
>>
>>     Thanks.
>>
>>     Csound mailing list
>>     Csound@listserv.heanet.ie 
>>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>     Send bugs reports to
>>     https://github.com/csound/csound/issues
>>     Discussions of bugs and features can be posted here
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> 
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and
>> features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-01-21 08:23
FromGuillermo Senna
SubjectRe: Using arrays as arguments
Hi Joachim.

I think you are right! I haven't thought about using scoreline_i. I've 
actually never used it before. I'll try that right now.

Thank you.

On 21/01/16 05:16, joachim heintz wrote:
> hi guillermo -
>
> if i understand correctly, you have a string first.  wouldn't it be 
> better to send and receive this string (could be done with the 
> scoreline opcode) instead of an array?
>
> best -
>     joachim
>
>
> On 21/01/16 08:29, Guillermo Senna wrote:
>> Hi Hlöðver,
>>
>> I've just implemented what you propose using a fixed size array. I'm
>> already using StrayGetNum. But I was wondering if there was a way to
>> write an event_i statement that has a variable (known at run-time)
>> argument list. I have not been able to solve that.
>>
>> What I mean is I've my variable-sized array already filled with the
>> correct numbers, but how can I create an event_i that takes that
>> information. Fixed-size arrays/arguments seems to be the only way. 
>> Isn't it?
>>
>>
>> On 21/01/16 04:20, Hlöðver Sigurðsson wrote:
>>> You could do:
>>>
>>> iArr[] init 10
>>> iArr fillarray 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
>>> event_i "i", 1, 0, 1, iArr[0], iArr[1], iArr[2], iArr[3], iArr[4],
>>> iArr[5], iArr[6], iArr[7], iArr[8], iArr[9]
>>>
>>> Doing variable argument count can be pain, but you would have to loop.
>>> If you dont want to initialize an Array to a fixed size, you could use
>>> Joachim Heinz's string arrays, then it's easy to just make an opcode
>>> that will count the number of values in an array and make an event
>>> function with the amount of parameters nedded (or requested for).
>>>
>>> Maybe this is helpful, you have this opcode at both i- and k- rate.
>>> https://github.com/csudo/csudo/blob/master/strays/StrayGetNum.csd
>>>
>>> 2016-01-21 6:38 GMT+01:00 Guillermo Senna >> >:
>>>
>>>     Hi,
>>>
>>>     Is there a way to use an entire array as an argument list?
>>>
>>>     I need some way of doing this:
>>>     iArr[] init 10
>>>     event_i "i", 1, 0, 1, iArr
>>>
>>>     Actually, what I'm trying to achieve is to generate a table using
>>>     an array for its arguments. The problem is that I don't know the
>>>     size of the array until run-time.
>>>
>>>     Thanks.
>>>
>>>     Csound mailing list
>>>     Csound@listserv.heanet.ie 
>>>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>>     Send bugs reports to
>>>     https://github.com/csound/csound/issues
>>>     Discussions of bugs and features can be posted here
>>>
>>>
>>> Csound mailing list Csound@listserv.heanet.ie
>>> 
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>> https://github.com/csound/csound/issues Discussions of bugs and
>>> features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> 
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here