[Csnd] Array Limit

Hello everybody!

In my current composition i work with algorithmically generated arrays which are fed to csound for composition parameters.
No i have the problem that inside csound there is a limit to the length of arrays (1999). Which annoys me a lot. And i’m asking myself if this is necessary at all?
Is there a reason for this? and is there a workaround?

Best,
Philipp
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Hi Philipp, that indeed seems odd. I don’t seem to have that issue.

-odac ;================================

sr = 48000
ksmps = 32
nchnls = 1
0dbfs = 1

instr 1
iArr[] init 5000
kArr[] init 5000
iLen = lenarray(iArr)
print iLen
iNdx init 0

while iNdx < 5000 do
iArr[iNdx] = iNdx
iNdx += 1
od
printarray iArr
kTrig = metro(1)
printarray kArr, kTrig
endin

;================================ i1 0 .1

Am I using them differently than you perhaps?

Best,
Scott

Hey Scott!

I use ‚fillarray‘ to create and fill the arrays at the same time. Maybe just this opcode has problems with it. I will investigate it. Thanks for trying out!

ok. The problem is indeed the ‚fillarray‘ opcode, which doesn’t accept more values then 1999.
Is there a way to fill a array in a other way?

i create textfiles which holds the array and in csound i use #include to call them.

Here’s one possibility. This is a bit of a mess below & probably needs to be modified to suit your needs.

instr 1
iIter init 0
SArr[] init 1
iArr[] init 1
while iIter < 1000 do
Sline, iLineNum readfi “/sdcard/text.txt”
SArr[iIter] = “10”
trim_i SArr, iIter + 2
trim_i iArr, iIter + 2
print iIter
iArr[iIter] = strtod(SArr[0])
print iArr[iIter]
iIter += 1
if iLineNum == -1 then
iIter = 1000
endif
od
trim_i iArr, lenarray(iArr) - 1
printarray iArr
endin

You might have to use delimit and/or strsub as well, depending on how your files are formatted. So basically read the text as strings, line by line, and convert to a float or int.

This seems like a workaround. But could just the ‚fillarray‘ opcode could be modified? Could a developer say something why this opcode is limited to 1999 values?

There is a boundary at 2000 when there is a strategy change to extended argument form. Looks as if extended structyhas not been programmed for fillarray. Will look when awake
⁣==John ffitch ​

if you use a textfile as actual input, you might be able to do this:
- use GEN23 to read the text file in a function table
- and if you prefer arrays over tables, use copyf2array.

  j

This sounds like a really good solution! Thank you Joachim! I will try it.