[Csnd] Table oddities

Hello all,

I’ve got a program that I have several tables that get passed to an instrument, which uses these tables to extract it’s performance data. My problem is that in my first example program, everything seems to work fine. But with the second, the difference being there are four tables, instead of two, but the odd sized tables are now one element shorter, and even sized.

Thanks,

Mike

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

table1.csd (790 Bytes)

table2.csd (1.27 KB)

I should have mentioned that the sizes being returned by ftlen in the second program are not right. The odd sizes are one smaller than they should be.

I think it’s because 5 and 3 are power of 2 + 1 sizes. These particular lengths set the table size to a power of two and set guard point to extend the curve. Not sure how this extension applies to GEN2 (need to check) but the size is set to size - 1 in this case afaik.

best

Prof. Victor Lazzarini
Maynooth University
Ireland

Hello Mike!
Feb 5 2023, Mike McGonagle has written:
...

But with the second, the difference being there are four tables, instead of
two, but the odd sized tables are now one element shorter, and even sized.

...
Make the table sizes negative. I think this is recommended for all non
power-of-two or power-of-two plus one table sizes. This should be
changed in the most recent Csound versions. I ran your second example as
is and got the same issue. Then I changed all table sizes to negative
values, which caused all sizes to be printed correctly.

Best wishes,

Jeanette

I did some other tests changing the sizes to other odd values, and some seemed to work, while others didn’t.

I was thinking as a work-around that I could just double the sizes of these tables, and then duplicate the data. It might make it awkward to do certain things, but I just want to get this running.

Not in that particular case, see

https://csound.com/manual/f.html

"For arrays whose length is a power of 2, space allocation always provides for 2n points plus an additional guard point. The guard point value, used during interpolated lookup, can be automatically set to reflect the table’s purpose: If size is an exact power of 2, the guard point will be a copy of the first point; this is appropriate for interpolated wrap-around lookup as in oscili, etc., and should even be used for non-interpolating oscil for safe consistency. If size is set to 2 n + 1, the guard point value automatically extends the contour of table values; this is appropriate for single-scan functions such in envplx, oscil1, oscil1i, etc.

The size of the table is used as a code to tell Csound how to fill this guard-point. If the size is exactly power-of-two, then the guard point contains a copy of the first point on the table. If the size is power-of-two plus one, Csound will extend the contour of the function stored in the table for one extra point."

That page also needs to be updated in that negative numbers are not used anymore to allow for any size (since Csound 6).

This issue is not well resolved I think and we’ll
need to tackle it on 7.x

Prof. Victor Lazzarini
Maynooth University
Ireland

FREAKING AWESOME, Jeanette! Works for me now!

Ah, I see while you don't need to make it negative, for this particular case, it switches off the guardpoint thing.

Prof. Victor Lazzarini
Maynooth University
Ireland

So, should I NOT use the negative sizes? They do seem to work with 6.18, but it sounds like this is a point of contention for version 7, right?

Anyway, I think I will continue with Jeanette’s recommendation until I find another solution.

Mike

I posted the relevant manual reference for you. Jeanette also gave a good solution.

3, 5, 9, 17, 33 etc will always report sizes of 2, 4, 8, 16, 32

Other lengths will not.

Prof. Victor Lazzarini
Maynooth University
Ireland

You don’t need to use negative sizes except in the case where you want to switch off the extended guardpoint mechanism, which uses the power of 2 + 1 size.

A size 7 will always create a table reporting size 7, no need for negative numbers since 6.0.

Prof. Victor Lazzarini
Maynooth University
Ireland

FWIW the -2 worked fine for me when the table sizes were set to 0. Although for some reason the canonical manual doesn’t seem to mention it, GEN02 will set the table size automatically depending on how many indices (values) there are if you set table size to 0.

Scott Daughtrey

table2a.csd (1.16 KB)

yes, because 0 is not power of 2 + 1

Prof. Victor Lazzarini
Maynooth University
Ireland