Csound Csound-dev Csound-tekno Search About

[Csnd] is it safe to override an array?

Date2018-12-30 16:25
Fromjoachim heintz
Subject[Csnd] is it safe to override an array?
the code below works.  i am just wondering whether it is really meant to 
work, and safe, or more or less random and note recommended?

thanks -
	joachim



instr Test_i
  iArr1[] fillarray 1, 2, 3
  iArr[] = iArr1
  print lenarray(iArr)
  iArr2[] fillarray 4, 5, 6, 7
  iArr[] = iArr2
  print lenarray(iArr)
  iArr3[] fillarray 9, 10
  iArr[] = iArr3
  print lenarray(iArr)
endin
schedule "Test_i", 0, 0

instr Test_k
  kArr1[] fillarray 1, 2, 3
  kArr[] = kArr1
  printk2 lenarray(kArr)
  kArr2[] fillarray 4, 5, 6, 7
  kArr[] = kArr2
  printk2 lenarray(kArr)
  kArr3[] fillarray 9, 10
  kArr[] = kArr3
  printk2 lenarray(kArr)
  turnoff
endin
schedule "Test_k", .1, .1


output is::

new alloc for instr Test_i:
instr 1:  #i0 = 3.000
instr 1:  #i1 = 4.000
instr 1:  #i2 = 2.000

new alloc for instr Test_k:
  i2     3.00000
  i2     4.00000
  i2     2.00000

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

Date2018-12-30 16:48
Fromjpff
SubjectRe: [Csnd] is it safe to override an array?
It is supposed to work within some meaning o work.


On Sun, 30 Dec 2018, joachim heintz wrote:

> the code below works.  i am just wondering whether it is really meant to 
> work, and safe, or more or less random and note recommended?
>
> thanks -
> 	joachim
>
>
>
> instr Test_i
> iArr1[] fillarray 1, 2, 3
> iArr[] = iArr1
> print lenarray(iArr)
> iArr2[] fillarray 4, 5, 6, 7
> iArr[] = iArr2
> print lenarray(iArr)
> iArr3[] fillarray 9, 10
> iArr[] = iArr3
> print lenarray(iArr)
> endin
> schedule "Test_i", 0, 0
>
> instr Test_k
> kArr1[] fillarray 1, 2, 3
> kArr[] = kArr1
> printk2 lenarray(kArr)
> kArr2[] fillarray 4, 5, 6, 7
> kArr[] = kArr2
> printk2 lenarray(kArr)
> kArr3[] fillarray 9, 10
> kArr[] = kArr3
> printk2 lenarray(kArr)
> turnoff
> endin
> schedule "Test_k", .1, .1
>
>
> output is::
>
> new alloc for instr Test_i:
> instr 1:  #i0 = 3.000
> instr 1:  #i1 = 4.000
> instr 1:  #i2 = 2.000
>
> new alloc for instr Test_k:
> i2     3.00000
> i2     4.00000
> i2     2.00000
>
> 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

Date2018-12-30 17:14
Fromjoachim heintz
SubjectRe: [Csnd] is it safe to override an array?
thanks.  good to know that it is supposed to work.  honestly, i don't 
understand what "within some meaning o (of?) work" means?



On 30/12/18 17:48, jpff wrote:
> It is supposed to work within some meaning o work.
>
>
> On Sun, 30 Dec 2018, joachim heintz wrote:
>
>> the code below works.  i am just wondering whether it is really meant
>> to work, and safe, or more or less random and note recommended?
>>
>> thanks -
>>     joachim
>>
>>
>>
>> instr Test_i
>> iArr1[] fillarray 1, 2, 3
>> iArr[] = iArr1
>> print lenarray(iArr)
>> iArr2[] fillarray 4, 5, 6, 7
>> iArr[] = iArr2
>> print lenarray(iArr)
>> iArr3[] fillarray 9, 10
>> iArr[] = iArr3
>> print lenarray(iArr)
>> endin
>> schedule "Test_i", 0, 0
>>
>> instr Test_k
>> kArr1[] fillarray 1, 2, 3
>> kArr[] = kArr1
>> printk2 lenarray(kArr)
>> kArr2[] fillarray 4, 5, 6, 7
>> kArr[] = kArr2
>> printk2 lenarray(kArr)
>> kArr3[] fillarray 9, 10
>> kArr[] = kArr3
>> printk2 lenarray(kArr)
>> turnoff
>> endin
>> schedule "Test_k", .1, .1
>>
>>
>> output is::
>>
>> new alloc for instr Test_i:
>> instr 1:  #i0 = 3.000
>> instr 1:  #i1 = 4.000
>> instr 1:  #i2 = 2.000
>>
>> new alloc for instr Test_k:
>> i2     3.00000
>> i2     4.00000
>> i2     2.00000
>>
>> 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

Date2018-12-31 10:29
FromMauro Giubileo
SubjectRe: [Csnd] is it safe to override an array?

Hi Joachim,

your example code shows that the basic Csound assignment operator "=" always reinits the destination array size (maybe the only exception is if the source and destination arrays have exactly the same size, but I don't know it for sure) and, to me, that's a good thing. But you have to be careful when you use genarray, fillarray, slicearray or similar opcodes because, unfortunately, they behave very differently from the assignment operator.

For example, if you do this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr[]      genarray    1, 3  ; <-- now we would think this generates an array of size 3...
             print       lenarray(iArr) ; <-- ...but this returns 10!

The output will be 10 (and I bet most programmers expect 3). From what I understand, the reason for this is that genarray and similar opcodes, actually, don't reinitialize an already defined output array, unless it is smaller than the size required to accomodate the new generated elements. In the recent past (I think some months ago) there was a discussion on this matter and genarray was modded to make it always resize the destination array (if necessary), but then the developers returned to make it work as the above example because, apparently, there was some previous Csound code that the modded genarray would break.

Fortunately, there exist an opcode that (at i-time) always reinits the size of an already defined array: "init". So, instead of using a completely new destination array, you could make Csound reduce the size of an already defined array by doing something like this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr        init        1     ; <-- this resizes iArr as a 1-element array
 iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray expands it
             print       lenarray(iArr) ; <-- so this prints 3, as we expect :)

Here you can notice that the [] notation is necessary only the first time you define an array. After that, Csound knows that iArr is an array so you can omit the brackets.

I don't know if this answers your question and sorry if I said all things you already know.


Best Regards and Happy New Year,

---
Mauro

 


Il 2018-12-30 17:25 joachim heintz ha scritto:

the code below works.  i am just wondering whether it is really meant to work, and safe, or more or less random and note recommended?

thanks -
    joachim



instr Test_i
 iArr1[] fillarray 1, 2, 3
 iArr[] = iArr1
 print lenarray(iArr)
 iArr2[] fillarray 4, 5, 6, 7
 iArr[] = iArr2
 print lenarray(iArr)
 iArr3[] fillarray 9, 10
 iArr[] = iArr3
 print lenarray(iArr)
endin
schedule "Test_i", 0, 0

instr Test_k
 kArr1[] fillarray 1, 2, 3
 kArr[] = kArr1
 printk2 lenarray(kArr)
 kArr2[] fillarray 4, 5, 6, 7
 kArr[] = kArr2
 printk2 lenarray(kArr)
 kArr3[] fillarray 9, 10
 kArr[] = kArr3
 printk2 lenarray(kArr)
 turnoff
endin
schedule "Test_k", .1, .1


output is::

new alloc for instr Test_i:
instr 1:  #i0 = 3.000
instr 1:  #i1 = 4.000
instr 1:  #i2 = 2.000

new alloc for instr Test_k:
 i2     3.00000
 i2     4.00000
 i2     2.00000

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

Date2018-12-31 19:47
Fromjoachim heintz
SubjectRe: [Csnd] is it safe to override an array?
hi mauro -

thanks for the explanation.  maybe i can add that there is now (since 
6.12) the opcode trim (trim_i) to adjust the size of arrays.

we definitely need an overview about all array opcodes.  i think there 
is none, so i will try to put it together.

have a good new year, too -

	joachim



On 31/12/18 11:29, Mauro Giubileo wrote:
> Hi Joachim,
>
> your example code shows that the basic Csound assignment operator "="
> always reinits the destination array size (maybe the only exception is
> if the source and destination arrays have exactly the same size, but I
> don't know it for sure) and, to me, that's a good thing. But you have to
> be careful when you use genarray, fillarray, slicearray or similar
> opcodes because, unfortunately, they behave very differently from the
> assignment operator.
>
> For example, if you do this:
>
>  iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>  iArr[]      genarray    1, 3  ; <-- now we would think this generates
> an array of size 3...
>              print       lenarray(iArr) ; <-- ...but this returns 10!
>
> The output will be 10 (and I bet most programmers expect 3). From what I
> understand, the reason for this is that genarray and similar opcodes,
> actually, don't reinitialize an already defined output array, unless it
> is smaller than the size required to accomodate the new generated
> elements. In the recent past (I think some months ago) there was a
> discussion on this matter and genarray was modded to make it always
> resize the destination array (if necessary), but then the developers
> returned to make it work as the above example because, apparently, there
> was some previous Csound code that the modded genarray would break.
>
> Fortunately, there exist an opcode that (at i-time) always reinits the
> size of an already defined array: "init". So, instead of using a
> completely new destination array, you could make Csound reduce the size
> of an already defined array by doing something like this:
>
>  iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>  iArr        init        1     ; <-- this resizes iArr as a 1-element array
>  iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
> expands it
>              print       lenarray(iArr) ; <-- so this prints 3, as we
> expect :)
>
> Here you can notice that the [] notation is necessary only the first
> time you define an array. After that, Csound knows that iArr is an array
> so you can omit the brackets.
>
> I don't know if this answers your question and sorry if I said all
> things you already know.
>
>
> Best Regards and Happy New Year,
>
> ---
> Mauro
>
>
>
>
> Il 2018-12-30 17:25 joachim heintz ha scritto:
>
>> the code below works.  i am just wondering whether it is really meant
>> to work, and safe, or more or less random and note recommended?
>>
>> thanks -
>>     joachim
>>
>>
>>
>> instr Test_i
>>  iArr1[] fillarray 1, 2, 3
>>  iArr[] = iArr1
>>  print lenarray(iArr)
>>  iArr2[] fillarray 4, 5, 6, 7
>>  iArr[] = iArr2
>>  print lenarray(iArr)
>>  iArr3[] fillarray 9, 10
>>  iArr[] = iArr3
>>  print lenarray(iArr)
>> endin
>> schedule "Test_i", 0, 0
>>
>> instr Test_k
>>  kArr1[] fillarray 1, 2, 3
>>  kArr[] = kArr1
>>  printk2 lenarray(kArr)
>>  kArr2[] fillarray 4, 5, 6, 7
>>  kArr[] = kArr2
>>  printk2 lenarray(kArr)
>>  kArr3[] fillarray 9, 10
>>  kArr[] = kArr3
>>  printk2 lenarray(kArr)
>>  turnoff
>> endin
>> schedule "Test_k", .1, .1
>>
>>
>> output is::
>>
>> new alloc for instr Test_i:
>> instr 1:  #i0 = 3.000
>> instr 1:  #i1 = 4.000
>> instr 1:  #i2 = 2.000
>>
>> new alloc for instr Test_k:
>>  i2     3.00000
>>  i2     4.00000
>>  i2     2.00000
>>
>> 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

Date2019-01-01 12:06
FromMauro Giubileo
SubjectRe: [Csnd] is it safe to override an array?

I didn't know John added the opcodes trim and trim_i. Nice! They address a problem with slicearray when used with the same array as input and ouput arrays.

Regarding an overview of the array opcodes, there is already this page in the manual (are you the author of it, right?):

https://csound.com/docs/manual/arrayOpcodes.html

but there are some opcodes missing (like trim/trim_i) and it doesn't explain that many opcodes that generate arrays never reduce the output array size if this array was already defined and bigger than what you need, so lenarray could give misleading results if the user is not aware of this peculiar behavior. Maybe you could update this page with the missing info.

Best Regards,

---
Mauro

 


Il 2018-12-31 20:47 joachim heintz ha scritto:

hi mauro -

thanks for the explanation.  maybe i can add that there is now (since 6.12) the opcode trim (trim_i) to adjust the size of arrays.

we definitely need an overview about all array opcodes.  i think there is none, so i will try to put it together.

have a good new year, too -

    joachim



On 31/12/18 11:29, Mauro Giubileo wrote:
Hi Joachim,

your example code shows that the basic Csound assignment operator "="
always reinits the destination array size (maybe the only exception is
if the source and destination arrays have exactly the same size, but I
don't know it for sure) and, to me, that's a good thing. But you have to
be careful when you use genarray, fillarray, slicearray or similar
opcodes because, unfortunately, they behave very differently from the
assignment operator.

For example, if you do this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr[]      genarray    1, 3  ; <-- now we would think this generates
an array of size 3...
             print       lenarray(iArr) ; <-- ...but this returns 10!

The output will be 10 (and I bet most programmers expect 3). From what I
understand, the reason for this is that genarray and similar opcodes,
actually, don't reinitialize an already defined output array, unless it
is smaller than the size required to accomodate the new generated
elements. In the recent past (I think some months ago) there was a
discussion on this matter and genarray was modded to make it always
resize the destination array (if necessary), but then the developers
returned to make it work as the above example because, apparently, there
was some previous Csound code that the modded genarray would break.

Fortunately, there exist an opcode that (at i-time) always reinits the
size of an already defined array: "init". So, instead of using a
completely new destination array, you could make Csound reduce the size
of an already defined array by doing something like this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr        init        1     ; <-- this resizes iArr as a 1-element array
 iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
expands it
             print       lenarray(iArr) ; <-- so this prints 3, as we
expect :)

Here you can notice that the [] notation is necessary only the first
time you define an array. After that, Csound knows that iArr is an array
so you can omit the brackets.

I don't know if this answers your question and sorry if I said all
things you already know.


Best Regards and Happy New Year,

---
Mauro




Il 2018-12-30 17:25 joachim heintz ha scritto:

the code below works.  i am just wondering whether it is really meant
to work, and safe, or more or less random and note recommended?

thanks -
    joachim



instr Test_i
 iArr1[] fillarray 1, 2, 3
 iArr[] = iArr1
 print lenarray(iArr)
 iArr2[] fillarray 4, 5, 6, 7
 iArr[] = iArr2
 print lenarray(iArr)
 iArr3[] fillarray 9, 10
 iArr[] = iArr3
 print lenarray(iArr)
endin
schedule "Test_i", 0, 0

instr Test_k
 kArr1[] fillarray 1, 2, 3
 kArr[] = kArr1
 printk2 lenarray(kArr)
 kArr2[] fillarray 4, 5, 6, 7
 kArr[] = kArr2
 printk2 lenarray(kArr)
 kArr3[] fillarray 9, 10
 kArr[] = kArr3
 printk2 lenarray(kArr)
 turnoff
endin
schedule "Test_k", .1, .1


output is::

new alloc for instr Test_i:
instr 1:  #i0 = 3.000
instr 1:  #i1 = 4.000
instr 1:  #i2 = 2.000

new alloc for instr Test_k:
 i2     3.00000
 i2     4.00000
 i2     2.00000

Csound mailing list
Csound@listserv.heanet.ie <mailto: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
<mailto: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

Date2019-01-02 15:49
Fromjoachim heintz
SubjectRe: [Csnd] is it safe to override an array?
AttachmentsarrayOpcodes.html  
i have added now an overview with a short description at the beginning 
of the array opcodes manual page.  it is in the sources now, and the 
html is attached.

i will also try to update the floss manual chapter about arrays in the 
next future.

best -
	joachim



On 01/01/19 13:06, Mauro Giubileo wrote:
> I didn't know John added the opcodes trim and trim_i. Nice! They address
> a problem with slicearray when used with the same array as input and
> ouput arrays.
>
> Regarding an overview of the array opcodes, there is already this page
> in the manual (are you the author of it, right?):
>
> https://csound.com/docs/manual/arrayOpcodes.html
>
> but there are some opcodes missing (like trim/trim_i) and it doesn't
> explain that many opcodes that generate arrays never reduce the output
> array size if this array was already defined and bigger than what you
> need, so lenarray could give misleading results if the user is not aware
> of this peculiar behavior. Maybe you could update this page with the
> missing info.
>
> Best Regards,
>
> ---
> Mauro
>
>
>
>
> Il 2018-12-31 20:47 joachim heintz ha scritto:
>
>> hi mauro -
>>
>> thanks for the explanation.  maybe i can add that there is now (since
>> 6.12) the opcode trim (trim_i) to adjust the size of arrays.
>>
>> we definitely need an overview about all array opcodes.  i think there
>> is none, so i will try to put it together.
>>
>> have a good new year, too -
>>
>>     joachim
>>
>>
>>
>> On 31/12/18 11:29, Mauro Giubileo wrote:
>>> Hi Joachim,
>>>
>>> your example code shows that the basic Csound assignment operator "="
>>> always reinits the destination array size (maybe the only exception is
>>> if the source and destination arrays have exactly the same size, but I
>>> don't know it for sure) and, to me, that's a good thing. But you have to
>>> be careful when you use genarray, fillarray, slicearray or similar
>>> opcodes because, unfortunately, they behave very differently from the
>>> assignment operator.
>>>
>>> For example, if you do this:
>>>
>>>  iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>>>  iArr[]      genarray    1, 3  ; <-- now we would think this generates
>>> an array of size 3...
>>>              print       lenarray(iArr) ; <-- ...but this returns 10!
>>>
>>> The output will be 10 (and I bet most programmers expect 3). From what I
>>> understand, the reason for this is that genarray and similar opcodes,
>>> actually, don't reinitialize an already defined output array, unless it
>>> is smaller than the size required to accomodate the new generated
>>> elements. In the recent past (I think some months ago) there was a
>>> discussion on this matter and genarray was modded to make it always
>>> resize the destination array (if necessary), but then the developers
>>> returned to make it work as the above example because, apparently, there
>>> was some previous Csound code that the modded genarray would break.
>>>
>>> Fortunately, there exist an opcode that (at i-time) always reinits the
>>> size of an already defined array: "init". So, instead of using a
>>> completely new destination array, you could make Csound reduce the size
>>> of an already defined array by doing something like this:
>>>
>>>  iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>>>  iArr        init        1     ; <-- this resizes iArr as a 1-element array
>>>  iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
>>> expands it
>>>              print       lenarray(iArr) ; <-- so this prints 3, as we
>>> expect :)
>>>
>>> Here you can notice that the [] notation is necessary only the first
>>> time you define an array. After that, Csound knows that iArr is an array
>>> so you can omit the brackets.
>>>
>>> I don't know if this answers your question and sorry if I said all
>>> things you already know.
>>>
>>>
>>> Best Regards and Happy New Year,
>>>
>>> ---
>>> Mauro
>>>
>>>
>>>
>>>
>>> Il 2018-12-30 17:25 joachim heintz ha scritto:
>>>
>>>> the code below works.  i am just wondering whether it is really meant
>>>> to work, and safe, or more or less random and note recommended?
>>>>
>>>> thanks -
>>>>     joachim
>>>>
>>>>
>>>>
>>>> instr Test_i
>>>>  iArr1[] fillarray 1, 2, 3
>>>>  iArr[] = iArr1
>>>>  print lenarray(iArr)
>>>>  iArr2[] fillarray 4, 5, 6, 7
>>>>  iArr[] = iArr2
>>>>  print lenarray(iArr)
>>>>  iArr3[] fillarray 9, 10
>>>>  iArr[] = iArr3
>>>>  print lenarray(iArr)
>>>> endin
>>>> schedule "Test_i", 0, 0
>>>>
>>>> instr Test_k
>>>>  kArr1[] fillarray 1, 2, 3
>>>>  kArr[] = kArr1
>>>>  printk2 lenarray(kArr)
>>>>  kArr2[] fillarray 4, 5, 6, 7
>>>>  kArr[] = kArr2
>>>>  printk2 lenarray(kArr)
>>>>  kArr3[] fillarray 9, 10
>>>>  kArr[] = kArr3
>>>>  printk2 lenarray(kArr)
>>>>  turnoff
>>>> endin
>>>> schedule "Test_k", .1, .1
>>>>
>>>>
>>>> output is::
>>>>
>>>> new alloc for instr Test_i:
>>>> instr 1:  #i0 = 3.000
>>>> instr 1:  #i1 = 4.000
>>>> instr 1:  #i2 = 2.000
>>>>
>>>> new alloc for instr Test_k:
>>>>  i2     3.00000
>>>>  i2     4.00000
>>>>  i2     2.00000
>>>>
>>>> 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

Date2019-01-02 16:23
FromAndreas Bergsland
SubjectRe: [Csnd] is it safe to override an array?
Very useful to have all the array opcodes together like that. Thanks a lot for that!
Best, Andreas

On 02/01/2019, 16:49, "A discussion list for users of Csound on behalf of joachim heintz"  wrote:

    i have added now an overview with a short description at the beginning 
    of the array opcodes manual page.  it is in the sources now, and the 
    html is attached.
    
    i will also try to update the floss manual chapter about arrays in the 
    next future.
    
    best -
    	joachim
    
    
    
    On 01/01/19 13:06, Mauro Giubileo wrote:
    > I didn't know John added the opcodes trim and trim_i. Nice! They address
    > a problem with slicearray when used with the same array as input and
    > ouput arrays.
    >
    > Regarding an overview of the array opcodes, there is already this page
    > in the manual (are you the author of it, right?):
    >
    > https://csound.com/docs/manual/arrayOpcodes.html
    >
    > but there are some opcodes missing (like trim/trim_i) and it doesn't
    > explain that many opcodes that generate arrays never reduce the output
    > array size if this array was already defined and bigger than what you
    > need, so lenarray could give misleading results if the user is not aware
    > of this peculiar behavior. Maybe you could update this page with the
    > missing info.
    >
    > Best Regards,
    >
    > ---
    > Mauro
    >
    >
    >
    >
    > Il 2018-12-31 20:47 joachim heintz ha scritto:
    >
    >> hi mauro -
    >>
    >> thanks for the explanation.  maybe i can add that there is now (since
    >> 6.12) the opcode trim (trim_i) to adjust the size of arrays.
    >>
    >> we definitely need an overview about all array opcodes.  i think there
    >> is none, so i will try to put it together.
    >>
    >> have a good new year, too -
    >>
    >>     joachim
    >>
    >>
    >>
    >> On 31/12/18 11:29, Mauro Giubileo wrote:
    >>> Hi Joachim,
    >>>
    >>> your example code shows that the basic Csound assignment operator "="
    >>> always reinits the destination array size (maybe the only exception is
    >>> if the source and destination arrays have exactly the same size, but I
    >>> don't know it for sure) and, to me, that's a good thing. But you have to
    >>> be careful when you use genarray, fillarray, slicearray or similar
    >>> opcodes because, unfortunately, they behave very differently from the
    >>> assignment operator.
    >>>
    >>> For example, if you do this:
    >>>
    >>>  iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
    >>>  iArr[]      genarray    1, 3  ; <-- now we would think this generates
    >>> an array of size 3...
    >>>              print       lenarray(iArr) ; <-- ...but this returns 10!
    >>>
    >>> The output will be 10 (and I bet most programmers expect 3). From what I
    >>> understand, the reason for this is that genarray and similar opcodes,
    >>> actually, don't reinitialize an already defined output array, unless it
    >>> is smaller than the size required to accomodate the new generated
    >>> elements. In the recent past (I think some months ago) there was a
    >>> discussion on this matter and genarray was modded to make it always
    >>> resize the destination array (if necessary), but then the developers
    >>> returned to make it work as the above example because, apparently, there
    >>> was some previous Csound code that the modded genarray would break.
    >>>
    >>> Fortunately, there exist an opcode that (at i-time) always reinits the
    >>> size of an already defined array: "init". So, instead of using a
    >>> completely new destination array, you could make Csound reduce the size
    >>> of an already defined array by doing something like this:
    >>>
    >>>  iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
    >>>  iArr        init        1     ; <-- this resizes iArr as a 1-element array
    >>>  iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
    >>> expands it
    >>>              print       lenarray(iArr) ; <-- so this prints 3, as we
    >>> expect :)
    >>>
    >>> Here you can notice that the [] notation is necessary only the first
    >>> time you define an array. After that, Csound knows that iArr is an array
    >>> so you can omit the brackets.
    >>>
    >>> I don't know if this answers your question and sorry if I said all
    >>> things you already know.
    >>>
    >>>
    >>> Best Regards and Happy New Year,
    >>>
    >>> ---
    >>> Mauro
    >>>
    >>>
    >>>
    >>>
    >>> Il 2018-12-30 17:25 joachim heintz ha scritto:
    >>>
    >>>> the code below works.  i am just wondering whether it is really meant
    >>>> to work, and safe, or more or less random and note recommended?
    >>>>
    >>>> thanks -
    >>>>     joachim
    >>>>
    >>>>
    >>>>
    >>>> instr Test_i
    >>>>  iArr1[] fillarray 1, 2, 3
    >>>>  iArr[] = iArr1
    >>>>  print lenarray(iArr)
    >>>>  iArr2[] fillarray 4, 5, 6, 7
    >>>>  iArr[] = iArr2
    >>>>  print lenarray(iArr)
    >>>>  iArr3[] fillarray 9, 10
    >>>>  iArr[] = iArr3
    >>>>  print lenarray(iArr)
    >>>> endin
    >>>> schedule "Test_i", 0, 0
    >>>>
    >>>> instr Test_k
    >>>>  kArr1[] fillarray 1, 2, 3
    >>>>  kArr[] = kArr1
    >>>>  printk2 lenarray(kArr)
    >>>>  kArr2[] fillarray 4, 5, 6, 7
    >>>>  kArr[] = kArr2
    >>>>  printk2 lenarray(kArr)
    >>>>  kArr3[] fillarray 9, 10
    >>>>  kArr[] = kArr3
    >>>>  printk2 lenarray(kArr)
    >>>>  turnoff
    >>>> endin
    >>>> schedule "Test_k", .1, .1
    >>>>
    >>>>
    >>>> output is::
    >>>>
    >>>> new alloc for instr Test_i:
    >>>> instr 1:  #i0 = 3.000
    >>>> instr 1:  #i1 = 4.000
    >>>> instr 1:  #i2 = 2.000
    >>>>
    >>>> new alloc for instr Test_k:
    >>>>  i2     3.00000
    >>>>  i2     4.00000
    >>>>  i2     2.00000
    >>>>
    >>>> 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

Date2019-01-02 18:31
FromMauro Giubileo
SubjectRe: [Csnd] is it safe to override an array?

Nice list. ;-)

Regards,

---
Mauro

 


Il 2019-01-02 16:49 joachim heintz ha scritto:

i have added now an overview with a short description at the beginning of the array opcodes manual page.  it is in the sources now, and the html is attached.

i will also try to update the floss manual chapter about arrays in the next future.

best -
    joachim



On 01/01/19 13:06, Mauro Giubileo wrote:
I didn't know John added the opcodes trim and trim_i. Nice! They address
a problem with slicearray when used with the same array as input and
ouput arrays.

Regarding an overview of the array opcodes, there is already this page
in the manual (are you the author of it, right?):

https://csound.com/docs/manual/arrayOpcodes.html

but there are some opcodes missing (like trim/trim_i) and it doesn't
explain that many opcodes that generate arrays never reduce the output
array size if this array was already defined and bigger than what you
need, so lenarray could give misleading results if the user is not aware
of this peculiar behavior. Maybe you could update this page with the
missing info.

Best Regards,

---
Mauro




Il 2018-12-31 20:47 joachim heintz ha scritto:

hi mauro -

thanks for the explanation.  maybe i can add that there is now (since
6.12) the opcode trim (trim_i) to adjust the size of arrays.

we definitely need an overview about all array opcodes.  i think there
is none, so i will try to put it together.

have a good new year, too -

    joachim



On 31/12/18 11:29, Mauro Giubileo wrote:
Hi Joachim,

your example code shows that the basic Csound assignment operator "="
always reinits the destination array size (maybe the only exception is
if the source and destination arrays have exactly the same size, but I
don't know it for sure) and, to me, that's a good thing. But you have to
be careful when you use genarray, fillarray, slicearray or similar
opcodes because, unfortunately, they behave very differently from the
assignment operator.

For example, if you do this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr[]      genarray    1, 3  ; <-- now we would think this generates
an array of size 3...
             print       lenarray(iArr) ; <-- ...but this returns 10!

The output will be 10 (and I bet most programmers expect 3). From what I
understand, the reason for this is that genarray and similar opcodes,
actually, don't reinitialize an already defined output array, unless it
is smaller than the size required to accomodate the new generated
elements. In the recent past (I think some months ago) there was a
discussion on this matter and genarray was modded to make it always
resize the destination array (if necessary), but then the developers
returned to make it work as the above example because, apparently, there
was some previous Csound code that the modded genarray would break.

Fortunately, there exist an opcode that (at i-time) always reinits the
size of an already defined array: "init". So, instead of using a
completely new destination array, you could make Csound reduce the size
of an already defined array by doing something like this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr        init        1     ; <-- this resizes iArr as a 1-element array
 iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
expands it
             print       lenarray(iArr) ; <-- so this prints 3, as we
expect :)

Here you can notice that the [] notation is necessary only the first
time you define an array. After that, Csound knows that iArr is an array
so you can omit the brackets.

I don't know if this answers your question and sorry if I said all
things you already know.


Best Regards and Happy New Year,

---
Mauro




Il 2018-12-30 17:25 joachim heintz ha scritto:

the code below works.  i am just wondering whether it is really meant
to work, and safe, or more or less random and note recommended?

thanks -
    joachim



instr Test_i
 iArr1[] fillarray 1, 2, 3
 iArr[] = iArr1
 print lenarray(iArr)
 iArr2[] fillarray 4, 5, 6, 7
 iArr[] = iArr2
 print lenarray(iArr)
 iArr3[] fillarray 9, 10
 iArr[] = iArr3
 print lenarray(iArr)
endin
schedule "Test_i", 0, 0

instr Test_k
 kArr1[] fillarray 1, 2, 3
 kArr[] = kArr1
 printk2 lenarray(kArr)
 kArr2[] fillarray 4, 5, 6, 7
 kArr[] = kArr2
 printk2 lenarray(kArr)
 kArr3[] fillarray 9, 10
 kArr[] = kArr3
 printk2 lenarray(kArr)
 turnoff
endin
schedule "Test_k", .1, .1


output is::

new alloc for instr Test_i:
instr 1:  #i0 = 3.000
instr 1:  #i1 = 4.000
instr 1:  #i2 = 2.000

new alloc for instr Test_k:
 i2     3.00000
 i2     4.00000
 i2     2.00000

Csound mailing list
Csound@listserv.heanet.ie
<mailto:Csound@listserv.heanet.ie> <mailto:Csound@listserv.heanet.ie
<mailto: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
<mailto:Csound@listserv.heanet.ie>
<mailto:Csound@listserv.heanet.ie <mailto: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 <mailto: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
<mailto: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

Date2019-01-02 21:53
Fromthorin kerr
SubjectRe: [Csnd] is it safe to override an array?
Is the overview meant to cover all opcodes that work with arrays? 

What about bpfcos, ceps, cepsinv, limit, limit1, linlin, maparray, rfft, rifft, tab2array, tab2pvs, unwrap....


Thorin

On Thu, 3 Jan. 2019, 4:31 am Mauro Giubileo <mgiubileo@computeraltafed.it wrote:

Nice list. ;-)

Regards,

---
Mauro

 


Il 2019-01-02 16:49 joachim heintz ha scritto:

i have added now an overview with a short description at the beginning of the array opcodes manual page.  it is in the sources now, and the html is attached.

i will also try to update the floss manual chapter about arrays in the next future.

best -
    joachim



On 01/01/19 13:06, Mauro Giubileo wrote:
I didn't know John added the opcodes trim and trim_i. Nice! They address
a problem with slicearray when used with the same array as input and
ouput arrays.

Regarding an overview of the array opcodes, there is already this page
in the manual (are you the author of it, right?):

https://csound.com/docs/manual/arrayOpcodes.html

but there are some opcodes missing (like trim/trim_i) and it doesn't
explain that many opcodes that generate arrays never reduce the output
array size if this array was already defined and bigger than what you
need, so lenarray could give misleading results if the user is not aware
of this peculiar behavior. Maybe you could update this page with the
missing info.

Best Regards,

---
Mauro




Il 2018-12-31 20:47 joachim heintz ha scritto:

hi mauro -

thanks for the explanation.  maybe i can add that there is now (since
6.12) the opcode trim (trim_i) to adjust the size of arrays.

we definitely need an overview about all array opcodes.  i think there
is none, so i will try to put it together.

have a good new year, too -

    joachim



On 31/12/18 11:29, Mauro Giubileo wrote:
Hi Joachim,

your example code shows that the basic Csound assignment operator "="
always reinits the destination array size (maybe the only exception is
if the source and destination arrays have exactly the same size, but I
don't know it for sure) and, to me, that's a good thing. But you have to
be careful when you use genarray, fillarray, slicearray or similar
opcodes because, unfortunately, they behave very differently from the
assignment operator.

For example, if you do this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr[]      genarray    1, 3  ; <-- now we would think this generates
an array of size 3...
             print       lenarray(iArr) ; <-- ...but this returns 10!

The output will be 10 (and I bet most programmers expect 3). From what I
understand, the reason for this is that genarray and similar opcodes,
actually, don't reinitialize an already defined output array, unless it
is smaller than the size required to accomodate the new generated
elements. In the recent past (I think some months ago) there was a
discussion on this matter and genarray was modded to make it always
resize the destination array (if necessary), but then the developers
returned to make it work as the above example because, apparently, there
was some previous Csound code that the modded genarray would break.

Fortunately, there exist an opcode that (at i-time) always reinits the
size of an already defined array: "init". So, instead of using a
completely new destination array, you could make Csound reduce the size
of an already defined array by doing something like this:

 iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
 iArr        init        1     ; <-- this resizes iArr as a 1-element array
 iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
expands it
             print       lenarray(iArr) ; <-- so this prints 3, as we
expect :)

Here you can notice that the [] notation is necessary only the first
time you define an array. After that, Csound knows that iArr is an array
so you can omit the brackets.

I don't know if this answers your question and sorry if I said all
things you already know.


Best Regards and Happy New Year,

---
Mauro




Il 2018-12-30 17:25 joachim heintz ha scritto:

the code below works.  i am just wondering whether it is really meant
to work, and safe, or more or less random and note recommended?

thanks -
    joachim



instr Test_i
 iArr1[] fillarray 1, 2, 3
 iArr[] = iArr1
 print lenarray(iArr)
 iArr2[] fillarray 4, 5, 6, 7
 iArr[] = iArr2
 print lenarray(iArr)
 iArr3[] fillarray 9, 10
 iArr[] = iArr3
 print lenarray(iArr)
endin
schedule "Test_i", 0, 0

instr Test_k
 kArr1[] fillarray 1, 2, 3
 kArr[] = kArr1
 printk2 lenarray(kArr)
 kArr2[] fillarray 4, 5, 6, 7
 kArr[] = kArr2
 printk2 lenarray(kArr)
 kArr3[] fillarray 9, 10
 kArr[] = kArr3
 printk2 lenarray(kArr)
 turnoff
endin
schedule "Test_k", .1, .1


output is::

new alloc for instr Test_i:
instr 1:  #i0 = 3.000
instr 1:  #i1 = 4.000
instr 1:  #i2 = 2.000

new alloc for instr Test_k:
 i2     3.00000
 i2     4.00000
 i2     2.00000

Csound mailing list
Csound@listserv.heanet.ie
<mailto:Csound@listserv.heanet.ie> <mailto:Csound@listserv.heanet.ie
<mailto: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
<mailto:Csound@listserv.heanet.ie>
<mailto:Csound@listserv.heanet.ie <mailto: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 <mailto: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
<mailto: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

Date2019-01-02 22:38
Fromjoachim heintz
SubjectRe: [Csnd] is it safe to override an array?
no it is meant to list the opcodes which create or modify arrays as 
control structures.  otherwise, diskin etc must be in the list, too, as 
it can output arrays.

from your list, maparray is on my list, too.

i will add limit, limit1 and tab2array.  thanks for the hint.  the 
others are better listed in another category, like ceps etc, in my 
opinion (and i think they are already).  of course it is up to the 
manual responsible persons to decide.

	joachim



On 02/01/19 22:53, thorin kerr wrote:
> Is the overview meant to cover all opcodes that work with arrays?
>
> What about bpfcos, ceps, cepsinv, limit, limit1, linlin, maparray, rfft,
> rifft, tab2array, tab2pvs, unwrap....
>
>
> Thorin
>
> On Thu, 3 Jan. 2019, 4:31 am Mauro Giubileo
>  wrote:
>
>     Nice list. ;-)
>
>     Regards,
>
>     ---
>     Mauro
>
>
>
>
>     Il 2019-01-02 16:49 joachim heintz ha scritto:
>
>>     i have added now an overview with a short description at the
>>     beginning of the array opcodes manual page.  it is in the sources
>>     now, and the html is attached.
>>
>>     i will also try to update the floss manual chapter about arrays in
>>     the next future.
>>
>>     best -
>>         joachim
>>
>>
>>
>>     On 01/01/19 13:06, Mauro Giubileo wrote:
>>>     I didn't know John added the opcodes trim and trim_i. Nice! They address
>>>     a problem with slicearray when used with the same array as input and
>>>     ouput arrays.
>>>
>>>     Regarding an overview of the array opcodes, there is already this page
>>>     in the manual (are you the author of it, right?):
>>>
>>>     https://csound.com/docs/manual/arrayOpcodes.html
>>>
>>>     but there are some opcodes missing (like trim/trim_i) and it doesn't
>>>     explain that many opcodes that generate arrays never reduce the output
>>>     array size if this array was already defined and bigger than what you
>>>     need, so lenarray could give misleading results if the user is not aware
>>>     of this peculiar behavior. Maybe you could update this page with the
>>>     missing info.
>>>
>>>     Best Regards,
>>>
>>>     ---
>>>     Mauro
>>>
>>>
>>>
>>>
>>>     Il 2018-12-31 20:47 joachim heintz ha scritto:
>>>
>>>>     hi mauro -
>>>>
>>>>     thanks for the explanation.  maybe i can add that there is now (since
>>>>     6.12) the opcode trim (trim_i) to adjust the size of arrays.
>>>>
>>>>     we definitely need an overview about all array opcodes.  i think there
>>>>     is none, so i will try to put it together.
>>>>
>>>>     have a good new year, too -
>>>>
>>>>         joachim
>>>>
>>>>
>>>>
>>>>     On 31/12/18 11:29, Mauro Giubileo wrote:
>>>>>     Hi Joachim,
>>>>>
>>>>>     your example code shows that the basic Csound assignment operator "="
>>>>>     always reinits the destination array size (maybe the only exception is
>>>>>     if the source and destination arrays have exactly the same size, but I
>>>>>     don't know it for sure) and, to me, that's a good thing. But you have to
>>>>>     be careful when you use genarray, fillarray, slicearray or similar
>>>>>     opcodes because, unfortunately, they behave very differently from the
>>>>>     assignment operator.
>>>>>
>>>>>     For example, if you do this:
>>>>>
>>>>>      iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>>>>>      iArr[]      genarray    1, 3  ; <-- now we would think this generates
>>>>>     an array of size 3...
>>>>>                  print       lenarray(iArr) ; <-- ...but this returns 10!
>>>>>
>>>>>     The output will be 10 (and I bet most programmers expect 3). From what I
>>>>>     understand, the reason for this is that genarray and similar opcodes,
>>>>>     actually, don't reinitialize an already defined output array, unless it
>>>>>     is smaller than the size required to accomodate the new generated
>>>>>     elements. In the recent past (I think some months ago) there was a
>>>>>     discussion on this matter and genarray was modded to make it always
>>>>>     resize the destination array (if necessary), but then the developers
>>>>>     returned to make it work as the above example because, apparently, there
>>>>>     was some previous Csound code that the modded genarray would break.
>>>>>
>>>>>     Fortunately, there exist an opcode that (at i-time) always reinits the
>>>>>     size of an already defined array: "init". So, instead of using a
>>>>>     completely new destination array, you could make Csound reduce the size
>>>>>     of an already defined array by doing something like this:
>>>>>
>>>>>      iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>>>>>      iArr        init        1     ; <-- this resizes iArr as a 1-element array
>>>>>      iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
>>>>>     expands it
>>>>>                  print       lenarray(iArr) ; <-- so this prints 3, as we
>>>>>     expect :)
>>>>>
>>>>>     Here you can notice that the [] notation is necessary only the first
>>>>>     time you define an array. After that, Csound knows that iArr is an array
>>>>>     so you can omit the brackets.
>>>>>
>>>>>     I don't know if this answers your question and sorry if I said all
>>>>>     things you already know.
>>>>>
>>>>>
>>>>>     Best Regards and Happy New Year,
>>>>>
>>>>>     ---
>>>>>     Mauro
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     Il 2018-12-30 17:25 joachim heintz ha scritto:
>>>>>
>>>>>>     the code below works.  i am just wondering whether it is really meant
>>>>>>     to work, and safe, or more or less random and note recommended?
>>>>>>
>>>>>>     thanks -
>>>>>>         joachim
>>>>>>
>>>>>>
>>>>>>
>>>>>>     instr Test_i
>>>>>>      iArr1[] fillarray 1, 2, 3
>>>>>>      iArr[] = iArr1
>>>>>>      print lenarray(iArr)
>>>>>>      iArr2[] fillarray 4, 5, 6, 7
>>>>>>      iArr[] = iArr2
>>>>>>      print lenarray(iArr)
>>>>>>      iArr3[] fillarray 9, 10
>>>>>>      iArr[] = iArr3
>>>>>>      print lenarray(iArr)
>>>>>>     endin
>>>>>>     schedule "Test_i", 0, 0
>>>>>>
>>>>>>     instr Test_k
>>>>>>      kArr1[] fillarray 1, 2, 3
>>>>>>      kArr[] = kArr1
>>>>>>      printk2 lenarray(kArr)
>>>>>>      kArr2[] fillarray 4, 5, 6, 7
>>>>>>      kArr[] = kArr2
>>>>>>      printk2 lenarray(kArr)
>>>>>>      kArr3[] fillarray 9, 10
>>>>>>      kArr[] = kArr3
>>>>>>      printk2 lenarray(kArr)
>>>>>>      turnoff
>>>>>>     endin
>>>>>>     schedule "Test_k", .1, .1
>>>>>>
>>>>>>
>>>>>>     output is::
>>>>>>
>>>>>>     new alloc for instr Test_i:
>>>>>>     instr 1:  #i0 = 3.000
>>>>>>     instr 1:  #i1 = 4.000
>>>>>>     instr 1:  #i2 = 2.000
>>>>>>
>>>>>>     new alloc for instr Test_k:
>>>>>>      i2     3.00000
>>>>>>      i2     4.00000
>>>>>>      i2     2.00000
>>>>>>
>>>>>>     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
>
> 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

Date2019-01-02 23:08
Fromthorin kerr
SubjectRe: [Csnd] is it safe to override an array?
Ok,

So maybe also add these?

cmp
floor
fmin
fmod
fmax
frac
getrowlin
round

Thorin


On Thu, 3 Jan. 2019, 8:38 am joachim heintz <jh@joachimheintz.de wrote:
no it is meant to list the opcodes which create or modify arrays as
control structures.  otherwise, diskin etc must be in the list, too, as
it can output arrays.

from your list, maparray is on my list, too.

i will add limit, limit1 and tab2array.  thanks for the hint.  the
others are better listed in another category, like ceps etc, in my
opinion (and i think they are already).  of course it is up to the
manual responsible persons to decide.

        joachim



On 02/01/19 22:53, thorin kerr wrote:
> Is the overview meant to cover all opcodes that work with arrays?
>
> What about bpfcos, ceps, cepsinv, limit, limit1, linlin, maparray, rfft,
> rifft, tab2array, tab2pvs, unwrap....
>
>
> Thorin
>
> On Thu, 3 Jan. 2019, 4:31 am Mauro Giubileo
> <mgiubileo@computeraltafed.it <mailto:mgiubileo@computeraltafed.it> wrote:
>
>     Nice list. ;-)
>
>     Regards,
>
>     ---
>     Mauro
>
>
>
>
>     Il 2019-01-02 16:49 joachim heintz ha scritto:
>
>>     i have added now an overview with a short description at the
>>     beginning of the array opcodes manual page.  it is in the sources
>>     now, and the html is attached.
>>
>>     i will also try to update the floss manual chapter about arrays in
>>     the next future.
>>
>>     best -
>>         joachim
>>
>>
>>
>>     On 01/01/19 13:06, Mauro Giubileo wrote:
>>>     I didn't know John added the opcodes trim and trim_i. Nice! They address
>>>     a problem with slicearray when used with the same array as input and
>>>     ouput arrays.
>>>
>>>     Regarding an overview of the array opcodes, there is already this page
>>>     in the manual (are you the author of it, right?):
>>>
>>>     https://csound.com/docs/manual/arrayOpcodes.html
>>>
>>>     but there are some opcodes missing (like trim/trim_i) and it doesn't
>>>     explain that many opcodes that generate arrays never reduce the output
>>>     array size if this array was already defined and bigger than what you
>>>     need, so lenarray could give misleading results if the user is not aware
>>>     of this peculiar behavior. Maybe you could update this page with the
>>>     missing info.
>>>
>>>     Best Regards,
>>>
>>>     ---
>>>     Mauro
>>>
>>>
>>>
>>>
>>>     Il 2018-12-31 20:47 joachim heintz ha scritto:
>>>
>>>>     hi mauro -
>>>>
>>>>     thanks for the explanation.  maybe i can add that there is now (since
>>>>     6.12) the opcode trim (trim_i) to adjust the size of arrays.
>>>>
>>>>     we definitely need an overview about all array opcodes.  i think there
>>>>     is none, so i will try to put it together.
>>>>
>>>>     have a good new year, too -
>>>>
>>>>         joachim
>>>>
>>>>
>>>>
>>>>     On 31/12/18 11:29, Mauro Giubileo wrote:
>>>>>     Hi Joachim,
>>>>>
>>>>>     your example code shows that the basic Csound assignment operator "="
>>>>>     always reinits the destination array size (maybe the only exception is
>>>>>     if the source and destination arrays have exactly the same size, but I
>>>>>     don't know it for sure) and, to me, that's a good thing. But you have to
>>>>>     be careful when you use genarray, fillarray, slicearray or similar
>>>>>     opcodes because, unfortunately, they behave very differently from the
>>>>>     assignment operator.
>>>>>
>>>>>     For example, if you do this:
>>>>>
>>>>>      iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>>>>>      iArr[]      genarray    1, 3  ; <-- now we would think this generates
>>>>>     an array of size 3...
>>>>>                  print       lenarray(iArr) ; <-- ...but this returns 10!
>>>>>
>>>>>     The output will be 10 (and I bet most programmers expect 3). From what I
>>>>>     understand, the reason for this is that genarray and similar opcodes,
>>>>>     actually, don't reinitialize an already defined output array, unless it
>>>>>     is smaller than the size required to accomodate the new generated
>>>>>     elements. In the recent past (I think some months ago) there was a
>>>>>     discussion on this matter and genarray was modded to make it always
>>>>>     resize the destination array (if necessary), but then the developers
>>>>>     returned to make it work as the above example because, apparently, there
>>>>>     was some previous Csound code that the modded genarray would break.
>>>>>
>>>>>     Fortunately, there exist an opcode that (at i-time) always reinits the
>>>>>     size of an already defined array: "init". So, instead of using a
>>>>>     completely new destination array, you could make Csound reduce the size
>>>>>     of an already defined array by doing something like this:
>>>>>
>>>>>      iArr[]      genarray    1, 10 ; <-- let's generate an array of 10 elements
>>>>>      iArr        init        1     ; <-- this resizes iArr as a 1-element array
>>>>>      iArr        genarray    1, 3  ; <-- now iArr size is < 3, so genarray
>>>>>     expands it
>>>>>                  print       lenarray(iArr) ; <-- so this prints 3, as we
>>>>>     expect :)
>>>>>
>>>>>     Here you can notice that the [] notation is necessary only the first
>>>>>     time you define an array. After that, Csound knows that iArr is an array
>>>>>     so you can omit the brackets.
>>>>>
>>>>>     I don't know if this answers your question and sorry if I said all
>>>>>     things you already know.
>>>>>
>>>>>
>>>>>     Best Regards and Happy New Year,
>>>>>
>>>>>     ---
>>>>>     Mauro
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     Il 2018-12-30 17:25 joachim heintz ha scritto:
>>>>>
>>>>>>     the code below works.  i am just wondering whether it is really meant
>>>>>>     to work, and safe, or more or less random and note recommended?
>>>>>>
>>>>>>     thanks -
>>>>>>         joachim
>>>>>>
>>>>>>
>>>>>>
>>>>>>     instr Test_i
>>>>>>      iArr1[] fillarray 1, 2, 3
>>>>>>      iArr[] = iArr1
>>>>>>      print lenarray(iArr)
>>>>>>      iArr2[] fillarray 4, 5, 6, 7
>>>>>>      iArr[] = iArr2
>>>>>>      print lenarray(iArr)
>>>>>>      iArr3[] fillarray 9, 10
>>>>>>      iArr[] = iArr3
>>>>>>      print lenarray(iArr)
>>>>>>     endin
>>>>>>     schedule "Test_i", 0, 0
>>>>>>
>>>>>>     instr Test_k
>>>>>>      kArr1[] fillarray 1, 2, 3
>>>>>>      kArr[] = kArr1
>>>>>>      printk2 lenarray(kArr)
>>>>>>      kArr2[] fillarray 4, 5, 6, 7
>>>>>>      kArr[] = kArr2
>>>>>>      printk2 lenarray(kArr)
>>>>>>      kArr3[] fillarray 9, 10
>>>>>>      kArr[] = kArr3
>>>>>>      printk2 lenarray(kArr)
>>>>>>      turnoff
>>>>>>     endin
>>>>>>     schedule "Test_k", .1, .1
>>>>>>
>>>>>>
>>>>>>     output is::
>>>>>>
>>>>>>     new alloc for instr Test_i:
>>>>>>     instr 1:  #i0 = 3.000
>>>>>>     instr 1:  #i1 = 4.000
>>>>>>     instr 1:  #i2 = 2.000
>>>>>>
>>>>>>     new alloc for instr Test_k:
>>>>>>      i2     3.00000
>>>>>>      i2     4.00000
>>>>>>      i2     2.00000
>>>>>>
>>>>>>     Csound mailing list
>>>>>>     Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>>>>>>     <mailto:Csound@listserv.heanet.ie
>>>>>>     <mailto:Csound@listserv.heanet.ie>> <mailto:Csound@listserv.heanet.ie
>>>>>>     <mailto:Csound@listserv.heanet.ie>
>>>>>>     <mailto:Csound@listserv.heanet.ie
>>>>>>     <mailto: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
>>>>>     <mailto:Csound@listserv.heanet.ie>
>>>>>     <mailto:Csound@listserv.heanet.ie
>>>>>     <mailto:Csound@listserv.heanet.ie>>
>>>>>     <mailto:Csound@listserv.heanet.ie
>>>>>     <mailto:Csound@listserv.heanet.ie> <mailto:Csound@listserv.heanet.ie
>>>>>     <mailto: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
>>>>     <mailto:Csound@listserv.heanet.ie> <mailto:Csound@listserv.heanet.ie
>>>>     <mailto: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
>>>     <mailto:Csound@listserv.heanet.ie>
>>>     <mailto:Csound@listserv.heanet.ie <mailto: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 <mailto: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
>     <mailto: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
> <mailto: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

Date2019-01-02 23:11
Fromjpff
SubjectRe: [Csnd] is it safe to override an array?
No mention of i-arrays?


On Thu, 3 Jan 2019, thorin kerr wrote:

> 
>

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

Date2019-01-02 23:19
FromJohn ff
SubjectRe: [Csnd] is it safe to override an array?
Or a-arrays?

Sent from TypeApp
On 2 Jan 2019, at 23:12, jpff <jpff@codemist.co.uk> wrote:
No mention of i-arrays?


On Thu, 3 Jan 2019, thorin kerr wrote:



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

Date2019-01-03 19:22
Fromjoachim heintz
SubjectRe: [Csnd] is it safe to override an array?
AttachmentsarrayOpcodes.html  
very good.

i have added cmp and getrowlin.

the others can go as enumeration, as it was in the release notes for 
csound 6.09:

- unary functions:
ceil, floor, round, int, frac, powoftwo, abs, log2, log10,
log, exp, sqrt, cos, sin, tan, acos, asin, atan, sinh, cosh, tanh,
cbrt, limit1
- binary functions:
atan2, pow, hypot, fmod, fmax, fmin

(i just see that this list is not quite correct; must be sininv etc 
rather than asin.)

thanks for your help.  i learned some new opcodes by this =)

i attach the new version.

	joachim




On 03/01/19 00:08, thorin kerr wrote:
> Ok,
>
> So maybe also add these?
>
> cmp
> floor
> fmin
> fmod
> fmax
> frac
> getrowlin
> round
>
> Thorin
>
>
> On Thu, 3 Jan. 2019, 8:38 am joachim heintz   wrote:
>
>     no it is meant to list the opcodes which create or modify arrays as
>     control structures.  otherwise, diskin etc must be in the list, too, as
>     it can output arrays.
>
>     from your list, maparray is on my list, too.
>
>     i will add limit, limit1 and tab2array.  thanks for the hint.  the
>     others are better listed in another category, like ceps etc, in my
>     opinion (and i think they are already).  of course it is up to the
>     manual responsible persons to decide.
>
>             joachim
>
>
>
>     On 02/01/19 22:53, thorin kerr wrote:
>     > Is the overview meant to cover all opcodes that work with arrays?
>     >
>     > What about bpfcos, ceps, cepsinv, limit, limit1, linlin, maparray,
>     rfft,
>     > rifft, tab2array, tab2pvs, unwrap....
>     >
>     >
>     > Thorin
>     >
>     > On Thu, 3 Jan. 2019, 4:31 am Mauro Giubileo
>     >      
>          > wrote:
>     >
>     >     Nice list. ;-)
>     >
>     >     Regards,
>     >
>     >     ---
>     >     Mauro
>     >
>     >
>     >
>     >
>     >     Il 2019-01-02 16:49 joachim heintz ha scritto:
>     >
>     >>     i have added now an overview with a short description at the
>     >>     beginning of the array opcodes manual page.  it is in the sources
>     >>     now, and the html is attached.
>     >>
>     >>     i will also try to update the floss manual chapter about
>     arrays in
>     >>     the next future.
>     >>
>     >>     best -
>     >>         joachim
>     >>
>     >>
>     >>
>     >>     On 01/01/19 13:06, Mauro Giubileo wrote:
>     >>>     I didn't know John added the opcodes trim and trim_i. Nice!
>     They address
>     >>>     a problem with slicearray when used with the same array as
>     input and
>     >>>     ouput arrays.
>     >>>
>     >>>     Regarding an overview of the array opcodes, there is already
>     this page
>     >>>     in the manual (are you the author of it, right?):
>     >>>
>     >>>     https://csound.com/docs/manual/arrayOpcodes.html
>     >>>
>     >>>     but there are some opcodes missing (like trim/trim_i) and it
>     doesn't
>     >>>     explain that many opcodes that generate arrays never reduce
>     the output
>     >>>     array size if this array was already defined and bigger than
>     what you
>     >>>     need, so lenarray could give misleading results if the user
>     is not aware
>     >>>     of this peculiar behavior. Maybe you could update this page
>     with the
>     >>>     missing info.
>     >>>
>     >>>     Best Regards,
>     >>>
>     >>>     ---
>     >>>     Mauro
>     >>>
>     >>>
>     >>>
>     >>>
>     >>>     Il 2018-12-31 20:47 joachim heintz ha scritto:
>     >>>
>     >>>>     hi mauro -
>     >>>>
>     >>>>     thanks for the explanation.  maybe i can add that there is
>     now (since
>     >>>>     6.12) the opcode trim (trim_i) to adjust the size of arrays.
>     >>>>
>     >>>>     we definitely need an overview about all array opcodes.  i
>     think there
>     >>>>     is none, so i will try to put it together.
>     >>>>
>     >>>>     have a good new year, too -
>     >>>>
>     >>>>         joachim
>     >>>>
>     >>>>
>     >>>>
>     >>>>     On 31/12/18 11:29, Mauro Giubileo wrote:
>     >>>>>     Hi Joachim,
>     >>>>>
>     >>>>>     your example code shows that the basic Csound assignment
>     operator "="
>     >>>>>     always reinits the destination array size (maybe the only
>     exception is
>     >>>>>     if the source and destination arrays have exactly the same
>     size, but I
>     >>>>>     don't know it for sure) and, to me, that's a good thing.
>     But you have to
>     >>>>>     be careful when you use genarray, fillarray, slicearray or
>     similar
>     >>>>>     opcodes because, unfortunately, they behave very
>     differently from the
>     >>>>>     assignment operator.
>     >>>>>
>     >>>>>     For example, if you do this:
>     >>>>>
>     >>>>>      iArr[]      genarray    1, 10 ; <-- let's generate an
>     array of 10 elements
>     >>>>>      iArr[]      genarray    1, 3  ; <-- now we would think
>     this generates
>     >>>>>     an array of size 3...
>     >>>>>                  print       lenarray(iArr) ; <-- ...but this
>     returns 10!
>     >>>>>
>     >>>>>     The output will be 10 (and I bet most programmers expect
>     3). From what I
>     >>>>>     understand, the reason for this is that genarray and
>     similar opcodes,
>     >>>>>     actually, don't reinitialize an already defined output
>     array, unless it
>     >>>>>     is smaller than the size required to accomodate the new
>     generated
>     >>>>>     elements. In the recent past (I think some months ago)
>     there was a
>     >>>>>     discussion on this matter and genarray was modded to make
>     it always
>     >>>>>     resize the destination array (if necessary), but then the
>     developers
>     >>>>>     returned to make it work as the above example because,
>     apparently, there
>     >>>>>     was some previous Csound code that the modded genarray
>     would break.
>     >>>>>
>     >>>>>     Fortunately, there exist an opcode that (at i-time) always
>     reinits the
>     >>>>>     size of an already defined array: "init". So, instead of
>     using a
>     >>>>>     completely new destination array, you could make Csound
>     reduce the size
>     >>>>>     of an already defined array by doing something like this:
>     >>>>>
>     >>>>>      iArr[]      genarray    1, 10 ; <-- let's generate an
>     array of 10 elements
>     >>>>>      iArr        init        1     ; <-- this resizes iArr as
>     a 1-element array
>     >>>>>      iArr        genarray    1, 3  ; <-- now iArr size is < 3,
>     so genarray
>     >>>>>     expands it
>     >>>>>                  print       lenarray(iArr) ; <-- so this
>     prints 3, as we
>     >>>>>     expect :)
>     >>>>>
>     >>>>>     Here you can notice that the [] notation is necessary only
>     the first
>     >>>>>     time you define an array. After that, Csound knows that
>     iArr is an array
>     >>>>>     so you can omit the brackets.
>     >>>>>
>     >>>>>     I don't know if this answers your question and sorry if I
>     said all
>     >>>>>     things you already know.
>     >>>>>
>     >>>>>
>     >>>>>     Best Regards and Happy New Year,
>     >>>>>
>     >>>>>     ---
>     >>>>>     Mauro
>     >>>>>
>     >>>>>
>     >>>>>
>     >>>>>
>     >>>>>     Il 2018-12-30 17:25 joachim heintz ha scritto:
>     >>>>>
>     >>>>>>     the code below works.  i am just wondering whether it is
>     really meant
>     >>>>>>     to work, and safe, or more or less random and note
>     recommended?
>     >>>>>>
>     >>>>>>     thanks -
>     >>>>>>         joachim
>     >>>>>>
>     >>>>>>
>     >>>>>>
>     >>>>>>     instr Test_i
>     >>>>>>      iArr1[] fillarray 1, 2, 3
>     >>>>>>      iArr[] = iArr1
>     >>>>>>      print lenarray(iArr)
>     >>>>>>      iArr2[] fillarray 4, 5, 6, 7
>     >>>>>>      iArr[] = iArr2
>     >>>>>>      print lenarray(iArr)
>     >>>>>>      iArr3[] fillarray 9, 10
>     >>>>>>      iArr[] = iArr3
>     >>>>>>      print lenarray(iArr)
>     >>>>>>     endin
>     >>>>>>     schedule "Test_i", 0, 0
>     >>>>>>
>     >>>>>>     instr Test_k
>     >>>>>>      kArr1[] fillarray 1, 2, 3
>     >>>>>>      kArr[] = kArr1
>     >>>>>>      printk2 lenarray(kArr)
>     >>>>>>      kArr2[] fillarray 4, 5, 6, 7
>     >>>>>>      kArr[] = kArr2
>     >>>>>>      printk2 lenarray(kArr)
>     >>>>>>      kArr3[] fillarray 9, 10
>     >>>>>>      kArr[] = kArr3
>     >>>>>>      printk2 lenarray(kArr)
>     >>>>>>      turnoff
>     >>>>>>     endin
>     >>>>>>     schedule "Test_k", .1, .1
>     >>>>>>
>     >>>>>>
>     >>>>>>     output is::
>     >>>>>>
>     >>>>>>     new alloc for instr Test_i:
>     >>>>>>     instr 1:  #i0 = 3.000
>     >>>>>>     instr 1:  #i1 = 4.000
>     >>>>>>     instr 1:  #i2 = 2.000
>     >>>>>>
>     >>>>>>     new alloc for instr Test_k:
>     >>>>>>      i2     3.00000
>     >>>>>>      i2     4.00000
>     >>>>>>      i2     2.00000
>     >>>>>>
>     >>>>>>     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
>     >
>     > 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