Csound Csound-dev Csound-tekno Search About

[Csnd] k rate getrow from i-rate array

Date2022-10-22 11:27
FromOeyvind Brandtsegg
Subject[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

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>


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

Date2022-10-22 11:37
FromOeyvind Brandtsegg
SubjectRe: [Csnd] k rate getrow from i-rate array
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



<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>

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 i[]k
       kRow getrow iArr ...
''''

Am I doing something wrong?
Simplified example below

all best
Øyvind

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>


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

Date2022-10-22 13:06
FromDave Seidel
SubjectRe: [Csnd] k rate getrow from i-rate array
Perhaps you need to use the form "getrow:k(...)", might make the copy unnecessary.

On Sat, Oct 22, 2022 at 6:38 AM Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
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



<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>

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 i[]k
       kRow getrow iArr ...
''''

Am I doing something wrong?
Simplified example below

all best
Øyvind

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>


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

Date2022-10-23 18:14
FromOeyvind Brandtsegg
SubjectRe: [Csnd] k rate getrow from i-rate array
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 ...
'''

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>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.

On Sat, Oct 22, 2022 at 6:38 AM Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
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



<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>

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 i[]k
       kRow getrow iArr ...
''''

Am I doing something wrong?
Simplified example below

all best
Øyvind

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

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

</CsInstruments>  
<CsScore>
i1 0 1
</CsScore>
</CsoundSynthesizer>


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

Date2022-10-23 21:02
FromEduardo Moguillansky
SubjectRe: [Csnd] k rate getrow from i-rate array
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

On 22.10.22 12:27, Oeyvind Brandtsegg wrote:
> 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 

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

Date2022-10-24 10:52
FromOeyvind Brandtsegg
SubjectRe: [Csnd] k rate getrow from i-rate array
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

søn. 23. okt. 2022 kl. 22:04 skrev Eduardo Moguillansky <eduardo.moguillansky@gmail.com>:
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

On 22.10.22 12:27, Oeyvind Brandtsegg wrote:
> 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
>
> <CsoundSynthesizer>
> <CsOptions>
> </CsOptions>
> <CsInstruments>
>
> 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
>
> </CsInstruments>
> <CsScore>
> i1 0 1
> </CsScore>
> </CsoundSynthesizer>
>
>
> 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

Date2022-10-24 11:34
FromEduardo Moguillansky
SubjectRe: [Csnd] k rate getrow from i-rate array

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];
        }
    }

On 24.10.22 11:52, Oeyvind Brandtsegg wrote:

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

søn. 23. okt. 2022 kl. 22:04 skrev Eduardo Moguillansky <eduardo.moguillansky@gmail.com>:
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

On 22.10.22 12:27, Oeyvind Brandtsegg wrote:
> 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
>
> <CsoundSynthesizer>
> <CsOptions>
> </CsOptions>
> <CsInstruments>
>
> 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
>
> </CsInstruments>
> <CsScore>
> i1 0 1
> </CsScore>
> </CsoundSynthesizer>
>
>
> 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

Date2022-10-24 15:05
FromOeyvind Brandtsegg
SubjectRe: [Csnd] k rate getrow from i-rate array
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];
        }
    }

On 24.10.22 11:52, Oeyvind Brandtsegg wrote:

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

søn. 23. okt. 2022 kl. 22:04 skrev Eduardo Moguillansky <eduardo.moguillansky@gmail.com>:
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

On 22.10.22 12:27, Oeyvind Brandtsegg wrote:
> 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
>
> <CsoundSynthesizer>
> <CsOptions>
> </CsOptions>
> <CsInstruments>
>
> 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
>
> </CsInstruments>
> <CsScore>
> i1 0 1
> </CsScore>
> </CsoundSynthesizer>
>
>
> 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