Csound Csound-dev Csound-tekno Search About

[Cs-dev] numbers for arrays

Date2015-08-13 07:39
Fromjoachim heintz
Subject[Cs-dev] numbers for arrays
hi all -

is it possible to point to an array by a number?

for function tables, it is: i can point to a table by a variable name, 
or by a number.  for arrays, i only see the variable name as 
possibility: gkArr[] init 13.

the use case is, for instance, this.  the user fills an array with a 
flexible number of values, and i want to create as many arrays as there 
are values in it, and then later refer to them.  with function tables, i 
can do:
   giTimes[] fillarray 100, 439, 801, 6543
   iCnt = 0
   while iCnt < lenarray(giTimes) do
     event_i "f",  iCnt+1, 0, -giTimes[iCnt], 2, 0
     iCnt += 1
   od
and then refer to the tables by the number 1,2,3,4.

but for arrays, i can not. and because if cannot create dynamic variable 
names either (like giArr%d[]), i must use tables here, although i'd 
prefer arrays.

or did i overlook something?

best -
	joachim

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-08-13 08:49
FromAnders Genell
SubjectRe: [Cs-dev] numbers for arrays
AttachmentsNone  None  
That is an excellent question related to things I've been pondering myself!
There are opcodes to convert from strings to floats or intergers, but not the other way around, I believe.
Also, I don't know if there is a way to treat contents of a string as a variable name, so that a variable name can be dynamically created...

Regards,
Anders

On Thu, Aug 13, 2015 at 8:39 AM, joachim heintz <jh@joachimheintz.de> wrote:
hi all -

is it possible to point to an array by a number?

for function tables, it is: i can point to a table by a variable name,
or by a number.  for arrays, i only see the variable name as
possibility: gkArr[] init 13.

the use case is, for instance, this.  the user fills an array with a
flexible number of values, and i want to create as many arrays as there
are values in it, and then later refer to them.  with function tables, i
can do:
   giTimes[] fillarray 100, 439, 801, 6543
   iCnt = 0
   while iCnt < lenarray(giTimes) do
     event_i "f",  iCnt+1, 0, -giTimes[iCnt], 2, 0
     iCnt += 1
   od
and then refer to the tables by the number 1,2,3,4.

but for arrays, i can not. and because if cannot create dynamic variable
names either (like giArr%d[]), i must use tables here, although i'd
prefer arrays.

or did i overlook something?

best -
        joachim

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-08-13 14:03
FromVictor Lazzarini
SubjectRe: [Cs-dev] numbers for arrays
You could use a 2-d array for this, perhaps

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

> On 13 Aug 2015, at 07:39, joachim heintz  wrote:
> 
> hi all -
> 
> is it possible to point to an array by a number?
> 
> for function tables, it is: i can point to a table by a variable name, 
> or by a number.  for arrays, i only see the variable name as 
> possibility: gkArr[] init 13.
> 
> the use case is, for instance, this.  the user fills an array with a 
> flexible number of values, and i want to create as many arrays as there 
> are values in it, and then later refer to them.  with function tables, i 
> can do:
>   giTimes[] fillarray 100, 439, 801, 6543
>   iCnt = 0
>   while iCnt < lenarray(giTimes) do
>     event_i "f",  iCnt+1, 0, -giTimes[iCnt], 2, 0
>     iCnt += 1
>   od
> and then refer to the tables by the number 1,2,3,4.
> 
> but for arrays, i can not. and because if cannot create dynamic variable 
> names either (like giArr%d[]), i must use tables here, although i'd 
> prefer arrays.
> 
> or did i overlook something?
> 
> best -
>    joachim
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net