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.
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.
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.
"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
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.