Trying to continue this discussion, which apparently happened in the wrong place :
https://github.com/csound/csound/issues/1607
Thank you Victor for writing, but your remark didn’t really answer our question. Perheaps it was not clear enough in our first message.
It could be rephrased like this : “Is there a direct way to init a k-rate array with values of an i-rate array (initialization only) ? And if no, wouldn’t ‘init’ keyword be a good candidate for such a task ?”
Because of course, if I write :
iArr fillarray 1, 2, 3, 4
kArr[] = iArr
The content of iArr will be copied in kArr at k-rate, because, as you wrote, it is a k-rate expression.
And “fillarray” (you mentionned in your previous answer) cannot be used to copy an array. So this solution is not relevant.
I know init is used to initialize an array with a scalar argument (size). But couldn’t the compiler do the job to just know if the argument is scalar or array, and then initialize with size (if scalar), or initialize and copy at initialization only (if array argument) ?
Let’s take a simple example :
opocode chord_manipulation, k[], i[]k
iArr[] , ktrig xin
// Here I want to copy the array at initialization only, because I need to manipulate it at k-rate (I don’t want the copy to happen every k-pass).
// So the only solution I found, was this :
isize lenarray iArr
kArr init isize
icnt init 0
while icnt < isize do
kArr[icnt] init iArr[icnt]
icnt += 1
od
// Where the language design would intuitively lead me to write :
kArr[] init iArr // which won’t build, but could be great
if(ktrig == 1) then
// Do some chord reversal here
endif
xout kArr
endop
instr 1
iChord1[] fillarray 50, 53, 55, 57
kReversed[] = chord_manipulation(iChord1, metro:k(1) )
endin
Finally, maybe there already is a simpler/smarter solution, which I don’t know.
Regards
Johann Philippe
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