[Csnd] Some array issues

Helloo!

I’m having a couple of array issues that I think might be bugs, but wanted to check if I’m doing something wrong before filing an issue. I’m running Csound 6.18 from November 2022 (commit a1580f9cdf331c35dceb486f4231871ce0b00266).

First is an issue with using the fillarray opcode in a functional way with 2d arrays:

This works:
giArr[][] init 2,3
giArr fillarray 1, 2, 3, -1, -2, -3

but this doesnt:
giArr[][] init 2,3
giArr = fillarray(1, 2, 3, -1, -2, -3)

producing the error:
INIT ERROR in instr 0 (opcode =.J) line 14: array-variable dimensions do not match

The other issue is that printarray doesn’t work in i-time on string-arrays. Like Joachims example 03E04 from the Floss manual under arrays (https://flossmanual.csound.com/csound-language/arrays) - it prints the number of files, but not the name of the files (the array with the strings):

-odac -d

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr Files
S_array[] directory “.”
iNumFiles lenarray S_array
prints “Number of files in %s = %d\n”, pwd(), iNumFiles
printarray S_array
endin

i "Files" 0 0 ;example by joachim heintz

i can confirm that the floss manual example does not give any output for the string array for me either. i think it did before.

I think the first issue is a limitation of the current parser, and as we are moving to a new parser in Csound 7, I don’t think we will do anything about it. No improvements to 6.x, only bugfixes.

The second seems to be a bona fide bug, can you open a ticket? We can look into it.

printarray using strings works fine for me provided the score duration is not 0

Try changing that.

There sno code to prinrt a styring array at i-time sas far as ~I can tell. This is Eduaro's problem. The ony case of printarray that matches the line in 03E04.csd (" printarray S_array") is

     { "printarray", S(ARRAYPRINTK), 0, 3, "", "S[]J",
       (SUBR)arrayprint_init, (SUBR)arrayprint_perf},
and arrayprint_init prepares for a k-rate call.

This could be a manual issie but a printarray for strings at i-time would brre useful.

==John ff

First issue is not a big problem, but maybe fillarray should have a note in the manual regarding its limitation in functional syntax?

I have opened a ticket for the second issue. I guess it must have been working before somehow since Joachim has used it in his example.

ST: yes, but the problem is that its not running in init time. When the score is bigger than 0, it can run in perf time.

I getcha, thanks for the clarification Bernt. I’m sure there are legitimate reasons for one wanting printarray S at init time that elude me; as the array itself is functional at init I guess I’ve never had an issue with waiting 1 k-cycle for it to print.

I agree it should be documented, but I also note that this is not limited to one opcode. I don’t think there is a way to add type annotations to indicate a multidimensional array in Csound 6.

Steven might be able to clarify this.

Prof. Victor Lazzarini
Maynooth University
Ireland

I think there’s a problem with type annotation for arrays and function return types in CS6. I want to say Hlodver had worked on something like this in a PR on CS7 but he’d have to chime in.