Csound Csound-dev Csound-tekno Search About

[Csnd] Question re: tab vs tab_i

Date2023-04-25 02:58
FromScott Daughtrey
Subject[Csnd] Question re: tab vs tab_i
If I have a table, for example:
iFrq ftgen 1, 0, -5, -2, 100, 200, 300, 400, 500

then

iFrq1 = tab_i(0, 1)

works fine, but 

kFrq1 = tab(0, 1)

gives an error message "tab off end". I'm curious as to why, as the index isn't changing.

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

Date2023-04-25 08:03
From"Jeanette C."
SubjectRe: [Csnd] Question re: tab vs tab_i
Hi Scott,
I copied your code into an instrument as is. Using either statement
worked fine, as did using both.

I wouldn't know why this happens. Perhaps you could post the complete
code of your instrument?

As an aside: it makes for better reading if you write:
iFreq1 = tab_i(0, iFreq)

Best wishes,

Jeanette

Apr 25 2023, Scott Daughtrey has written:

> If I have a table, for example:
> iFrq ftgen 1, 0, -5, -2, 100, 200, 300, 400, 500
>
> then
>
> iFrq1 = tab_i(0, 1)
>
> works fine, but
>
> kFrq1 = tab(0, 1)
>
> gives an error message "tab off end". I'm curious as to why, as the index isn't changing.
>
> 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
>

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

For whatever reason,
I feel like I've been wanting you all my life <3
(Britney Spears)

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

Date2023-04-25 09:36
FromST Music
SubjectRe: [Csnd] Question re: tab vs tab_i
Hi Jeanette, thanks for taking the time to test & reply. 

The instr is getting big so just posting an example. It's a formant/vowel type thing, so ultimately probably using a morph opcode anyways & the issue will be moot; that's also why I didn't use iFreq = tab_i(0, iFrq) as I was testing different vowel freq tables using p4 to select the table. But your point was well taken =)

Nonetheless when I come across these issues I like to follow up for future reference or in case I need to report a bug.

So here's a short example:

<CsoundSynthesizer>
<CsOptions>
-o dac
</CsOptions>
<CsInstruments>

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

iFrq    ftgen 1, 0, -4, -2, 100, 200, 300, 400, 500

instr 1
    iFrq1 = tab_i(2, 1)
    kNdx = 0
    kFrq1 = tab(0, 1)
    aSig  = oscil(.8, iFrq1)
            out aSig
endin

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

This gives the error:
PERF ERROR in instr 1 (opcode tab) line 17: tab off end 2147483647 from file *string* (1) #a1 tab 0 1 0

If I comment out kFrq1 = tab(0, 1) it runs fine. Where it gets even weirder is if I instead use kFrq1 = tab(kNdx, 1), then still an error but instead it's:
PERF ERROR in instr 1 (opcode tab) line 17: tab off end 100 from file *string* (1) #a1 tab kNdx 1 0

In that case it's reporting the right value for index 0 (tab off end 100) as opposed to tab off end 2147483647. As to why I haven't got a clue. Likewise if I use kNdx = 1, then "tab off end 200" etc. But always an error & code won't run.

So not sure if I'm doing something wrong or whether this is a Csound for Android specific problem

Best & thanks again, 

Scott

On Tue, Apr 25, 2023, 3:03 AM Jeanette C., <julien@mail.upb.de> wrote:
Hi Scott,
I copied your code into an instrument as is. Using either statement
worked fine, as did using both.

I wouldn't know why this happens. Perhaps you could post the complete
code of your instrument?

As an aside: it makes for better reading if you write:
iFreq1 = tab_i(0, iFreq)

Best wishes,

Jeanette

Apr 25 2023, Scott Daughtrey has written:

> If I have a table, for example:
> iFrq ftgen 1, 0, -5, -2, 100, 200, 300, 400, 500
>
> then
>
> iFrq1 = tab_i(0, 1)
>
> works fine, but
>
> kFrq1 = tab(0, 1)
>
> gives an error message "tab off end". I'm curious as to why, as the index isn't changing.
>
> 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
>

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

For whatever reason,
I feel like I've been wanting you all my life <3
(Britney Spears)

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

Date2023-04-25 11:33
From"Jeanette C."
SubjectRe: [Csnd] Question re: tab vs tab_i
Apr 25 2023, ST Music has written:
...
Hm, the error output citing #a1 tab ... makes me think. Have you tried:
kFrq1 = tab:k(0, 1)
tab can return both an a-rate or k-rate signal. It should not happen, I
think, but this error suggests that it might have used the a-rate
version, which might cause issues.

HTH.

Best wishes,

Jeanette
>    kFrq1 = tab(0, 1)

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

There's no time to loose
And next week,
You might not see me here <3
(Britney Spears)

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

Date2023-04-25 20:50
FromPete Goodeve
SubjectRe: [Csnd] Question re: tab vs tab_i
AttachmentsNone  

Date2023-04-25 21:29
FromST Music
SubjectRe: [Csnd] Question re: tab vs tab_i
Thanks Pete, appeciate the feedback. Appears it may be specific to either the Csound for Android app or library version 6.16 which I think it uses.

Jeanette, good catch, you were right (no surprise there =) ). Although it's fairly rare that type annotations are required in this type of situation I occasionally come across them. I can see why with function(al) syntax in Csound it might be useful to always use type annotations as a general practice but seems like a pain, guess I'm lazy.

So turns out either:
kFrq1 = tab:k(kNdx, 1)

or old school

kFrq1   tab kNdx, 1


On Tue, Apr 25, 2023, 3:50 PM Pete Goodeve, <pete.goodeve@computer.org> wrote:
Hi Scott,
FYI, Your example below runs without error on my system (v6.14 on Haiku OS).

        -- Pete --

On Tue, Apr 25, 2023 at 04:36:39AM -0400, ST Music wrote:
> Hi Jeanette, thanks for taking the time to test & reply.
>
> The instr is getting big so just posting an example. It's a formant/vowel
> type thing, so ultimately probably using a morph opcode anyways & the issue
> will be moot; that's also why I didn't use iFreq = tab_i(0, iFrq) as I was
> testing different vowel freq tables using p4 to select the table. But your
> point was well taken =)
>
> Nonetheless when I come across these issues I like to follow up for future
> reference or in case I need to report a bug.
>
> So here's a short example:
>
> <CsoundSynthesizer>
> <CsOptions>
> -o dac
> </CsOptions>
> <CsInstruments>
>
> sr = 48000
> ksmps = 32
> nchnls = 1
> 0dbfs  = 1
>
> iFrq    ftgen 1, 0, -4, -2, 100, 200, 300, 400, 500
>
> instr 1
>     iFrq1 = tab_i(2, 1)
>     kNdx = 0
>     kFrq1 = tab(0, 1)
>     aSig  = oscil(.8, iFrq1)
>             out aSig
> endin
>
> </CsInstruments>
> <CsScore>
> i1 0 3
> </CsScore>
> </CsoundSynthesizer>
>
> This gives the error:
> PERF ERROR in instr 1 (opcode tab) line 17: tab off end 2147483647 from
> file *string* (1) #a1 tab 0 1 0
>
> If I comment out kFrq1 = tab(0, 1) it runs fine. Where it gets even weirder
> is if I instead use kFrq1 = tab(kNdx, 1), then still an error but instead
> it's:
> PERF ERROR in instr 1 (opcode tab) line 17: tab off end 100 from file
> *string* (1) #a1 tab kNdx 1 0
>
> In that case it's reporting the right value for index 0 (tab off end 100)
> as opposed to tab off end 2147483647. As to why I haven't got a clue.
> Likewise if I use kNdx = 1, then "tab off end 200" etc. But always an error
> & code won't run.
>
> So not sure if I'm doing something wrong or whether this is a Csound for
> Android specific problem
>
> Best & thanks again,
>
> Scott
>
> ST Music
> https://soundcloud.com/st-csound
> https://soundcloud.com/stoons-1
>
> https://youtube.com/channel/UCGhwmkS1uWmX6mhTIQ0IDsg
>
> On Tue, Apr 25, 2023, 3:03 AM Jeanette C., <julien@mail.upb.de> wrote:
>
> > Hi Scott,
> > I copied your code into an instrument as is. Using either statement
> > worked fine, as did using both.
> >
> > I wouldn't know why this happens. Perhaps you could post the complete
> > code of your instrument?
> >
> > As an aside: it makes for better reading if you write:
> > iFreq1 = tab_i(0, iFreq)
> >
> > Best wishes,
> >
> > Jeanette
> >
> > Apr 25 2023, Scott Daughtrey has written:
> >
> > > If I have a table, for example:
> > > iFrq ftgen 1, 0, -5, -2, 100, 200, 300, 400, 500
> > >
> > > then
> > >
> > > iFrq1 = tab_i(0, 1)
> > >
> > > works fine, but
> > >
> > > kFrq1 = tab(0, 1)
> > >
> > > gives an error message "tab off end". I'm curious as to why, as the
> > index isn't changing.
> > >
> > > 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
> > >
> >
> > --
> >   * Website: http://juliencoder.de - for summer is a state of sound
> >   * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
> >   * Audiobombs: https://www.audiobombs.com/users/jeanette_c
> >   * GitHub: https://github.com/jeanette-c
> >
> > For whatever reason,
> > I feel like I've been wanting you all my life <3
> > (Britney Spears)
> >
> > 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