[Csnd] k rate getrow from i-rate array

Hi

I am trying to read a row from a 2-dimensional array,
reading at k-rate from an i-rate array.
It seems it is not allowed (parser throws an error about argument types)
‘’’
Unable to find opcode entry for ‘getrow’ with matching argument types:
Found: k[] getrow i[]k
kRow getrow iArr …
‘’‘’

Am I doing something wrong?
Simplified example below

all best
Øyvind

instr 1
iArr[] init 3,3
iArr genarray 1,9
kRow[] init 3
ktrig metro 1
kindex = 0
while kindex < 3 do
kRow getrow iArr, kindex
printarray kRow
kindex += 1
od
endin

i1 0 1

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

Ah, got it.
Just so I can remember later, why do I need to copy from iArr to kArr here?
kArr = iArr ; in the 3rd line of instrument 1

all best
Øyvind

instr 1
iArr init 3,3
iArr genarray 1,9
kArr = iArr
kRow init 3
ktrig metro 1
kindex = 0
while kindex < 3 do
kRow getrow kArr, kindex
printarray kRow
kindex += 1
od
endin

i1 0 1

lør. 22. okt. 2022 kl. 12:27 skrev Oeyvind Brandtsegg <obrandts@gmail.com>:

Hi

I am trying to read a row from a 2-dimensional array,
reading at k-rate from an i-rate array.
It seems it is not allowed (parser throws an error about argument types)
‘’’
Unable to find opcode entry for ‘getrow’ with matching argument types:
Found: k getrow ik
kRow getrow iArr …
‘’‘’

Am I doing something wrong?
Simplified example below

all best
Øyvind

instr 1
iArr init 3,3
iArr genarray 1,9
kRow init 3
ktrig metro 1
kindex = 0
while kindex < 3 do
kRow getrow iArr, kindex
printarray kRow
kindex += 1
od
endin

i1 0 1

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

Perhaps you need to use the form “getrow:k(…)”, might make the copy unnecessary.

Hi Dave,

Thanks for your reply, it makes sense, but when I try it I get an error
‘’’
Unable to find opcode entry for ‘=’ with matching argument types:
Found: k = @
kRow = getrow …

‘’’

instr 1

iArr init 3,3
iArr genarray 1,9
kRow init 3
ktrig metro 1
kindex = 0
while kindex < 3 do
kRow = getrow:k(iArr, kindex)
printarray kRow
kindex += 1
od

endin

i1 0 1 endin

lør. 22. okt. 2022 kl. 14:08 skrev Dave Seidel <dave.seidel@gmail.com>:

Perhaps you need to use the form “getrow:k(…)”, might make the copy unnecessary.

Ah, got it.
Just so I can remember later, why do I need to copy from iArr to kArr here?
kArr = iArr ; in the 3rd line of instrument 1

all best
Øyvind

instr 1
iArr init 3,3
iArr genarray 1,9
kArr = iArr
kRow init 3
ktrig metro 1
kindex = 0
while kindex < 3 do
kRow getrow kArr, kindex
printarray kRow
kindex += 1
od
endin

i1 0 1

lør. 22. okt. 2022 kl. 12:27 skrev Oeyvind Brandtsegg <obrandts@gmail.com>:

Hi

I am trying to read a row from a 2-dimensional array,
reading at k-rate from an i-rate array.
It seems it is not allowed (parser throws an error about argument types)
‘’’
Unable to find opcode entry for ‘getrow’ with matching argument types:
Found: k getrow ik
kRow getrow iArr …
‘’‘’

Am I doing something wrong?
Simplified example below

all best
Øyvind

instr 1
iArr init 3,3
iArr genarray 1,9
kRow init 3
ktrig metro 1
kindex = 0
while kindex < 3 do
kRow getrow iArr, kindex
printarray kRow
kindex += 1
od
endin

i1 0 1

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

Hi, Oeyvind,

You can use getrowlin (getrowlin - Csound Plugins). When given an integer index it is exactly the same as getrow

getrowlin used to be included in csound but now needs to be installed as an external plugin:

risset install beosc

cheers, Eduardo

Ok. Thanks.
I assumed that it might be slightly more expensive in terms of CPU usage, since it enables interpolation.
Does it fully disable interpolation if the index is an int, or is it so that it just gives the same result?
(still interpolating, but giving the current index full weight, so that the result will be an exact copy)?

all best
Øyvind

Before looping over the items in the row it checks if the index is an integer and in that case it skips any interpolation. This is the main loop after checking bounds:

    MYFLT delta = row - floor(row);

    MYFLT *out = p->outarr->data;
    MYFLT *in  = p->inarr->data;

    int idx0 = numcols * row0 + start;
    int idx1 = idx0 + numitems;
    MYFLT x0, x1;
    int i, j = 0;
    if (delta != 0) {
        for (i=idx0; i<idx1; i+=step) {
            x0 = in[i];
            x1 = in[i + numcols];
            out[j++] = x0 + (x1-x0)*delta;
        }
    }
    else {
        for (i=idx0; i<idx1; i+=step) {
            out[j++] = in[i];
        }
    }

All good. Thanks.

man. 24. okt. 2022 kl. 12:35 skrev Eduardo Moguillansky <eduardo.moguillansky@gmail.com>:

Before looping over the items in the row it checks if the index is an integer and in that case it skips any interpolation. This is the main loop after checking bounds:

    MYFLT delta = row - floor(row);

    MYFLT *out = p->outarr->data;
    MYFLT *in  = p->inarr->data;

    int idx0 = numcols * row0 + start;
    int idx1 = idx0 + numitems;
    MYFLT x0, x1;
    int i, j = 0;
    if (delta != 0) {
        for (i=idx0; i<idx1; i+=step) {
            x0 = in[i];
            x1 = in[i + numcols];
            out[j++] = x0 + (x1-x0)*delta;
        }
    }
    else {
        for (i=idx0; i<idx1; i+=step) {
            out[j++] = in[i];
        }
    }

Ok. Thanks.
I assumed that it might be slightly more expensive in terms of CPU usage, since it enables interpolation.
Does it fully disable interpolation if the index is an int, or is it so that it just gives the same result?
(still interpolating, but giving the current index full weight, so that the result will be an exact copy)?

all best
Øyvind

Hi, Oeyvind,

You can use getrowlin
(https://csound-plugins.github.io/csound-plugins/opcodes/getrowlin.html).
When given an integer index it is exactly the same as getrow

getrowlin used to be included in csound but now needs to be installed as
an external plugin:

risset install beosc

cheers, Eduardo

Hi

I am trying to read a row from a 2-dimensional array,
reading at k-rate from an i-rate array.
It seems it is not allowed (parser throws an error about argument types)
‘’’
Unable to find opcode entry for ‘getrow’ with matching argument types:
Found: k getrow ik
kRow getrow iArr …
‘’‘’

Am I doing something wrong?
Simplified example below

all best
Øyvind

instr 1
iArr init 3,3
iArr genarray 1,9
kRow init 3
ktrig metro 1
kindex = 0
while kindex < 3 do
kRow getrow iArr, kindex
printarray kRow
kindex += 1
od
endin

i1 0 1

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