Csound Csound-dev Csound-tekno Search About

reinitialising ifn in table opcode (?)

Date1997-12-21 22:08
FromJosep M* Comajuncosas
Subjectreinitialising ifn in table opcode (?)
Is it possible to change the table number in a table-tablei opcode via a
reinit pass? Till now all my efforts have not worked at all... I usually
get a message like "invalid f table number 0..." or "table no
initialized"...
I know of some other opcodes for this, like tablekt or tableikt, but
they seem not to have been implemented yet anywere but in the help files
;-), am I wrong?
Tnx in advance!

Josep M Comajuncosas

Date1997-12-27 08:43
FromRobin Whittle
SubjectTable read and k rate table numbers
"Josep M* Comajuncosas"  asked about changing 
the table number at k rate for table reading operations.

This is something I provided with two new ugens:

    tablekt
    tableikt

which enable table reading with the table number being changed
at k rate.

This is in a "new" version of ugens2.c/h (actually from 1995/6) which
is at my web site:

   http://www.firstpr.com.au/csound/

Also there, you will find a file called tabread.txt, which I have 
updated today, which describes the two new ugens and the anomalies in 
table read behaviour in the original ugens2.c/h code.

See tabread.txt for a full description, but these anomalies are 
likely to cause significant trouble for many Csound users.

The current version (3.47 beta) of Csound still uses the original 
ugens2.c/h - so if you are using table read, then be sure to read 
about the anomalies.


I believe it would be best if the old ugens2.c/h in the 
"standard" version of Csound were replaced with my new source.  This 
entails:

1 - Adding a few things to entry.c. (Easy).

2 - Adding a new function ftfindp() to fgens.c.  (This is for finding 
    tables at performance time, rather than init time.)

    A version of fgens.c with this function is at my web site. This 
    version of fgens.c also extends the maximum table number to 1000.

3 - Updating the Csound manual to include the new, precise, 
    definitions of table read behaviour, and of the tablekt and
    tableikt ugens.  Probably also a note about how previous versions
    provided behaviour which differed in four respects.


The good things about this are:

1 - Cause table read behaviour to be exactly as I have defined, 
    rather than the more erratic (and perhaps compiler dependent)
    behaviour of the old code, which was never clearly described
    in the Csound manual.

2 - Provide tablekt and tableikt so table numbers can be changed
    at k rate.

3 - Provide for more tables - eg. up to 1000, though this could
    easily be changed.


The only downside would be that some existing Csound orchestras
would not behave as they used to - but only those which relied on
what I regard as the anomalous behaviour of the original table read
code.  Since none of those anomalies were described in the manual, I
would think that few pieces really rely on these behaviours.  The
anomalies concern wrap mode, interpolation with indexes and which 
are outside the normal range of the table and offsets which did not 
point exactly at samples in the table.  They are very messy indeed.

Since table reading is so important to many Csound projects, I think 
it would be best to make a break with a buggy past and provide a 
stronger, more flexible, fully defined basis for future Csound 
projects.  The old pieces can always be run on old executables.

There has been a policy of never changing Csound in ways which 
might break older pieces, but at some point you have to call a bug a 
bug - even though it has been part of Csound for years.  Here 
are the anomalies from:

   http://www.firstpr.com.au/csound/tabread.txt

These give you some idea of the problems, but they refer to the 
example table in the above file.

- - - - - 

Bug 1 Interpolated with out of range total indexes in limit mode
----------------------------------------------------------------

In the example given, if the total index increased from -4 to 0, the
output should have remained at 0. Instead it traversed four little
sawtooth waves - each a facsimile of the proper response from 0 to 1.

The same trouble occurred for indexes above 4, when it should have
stuck at the value of the guardpoint.


Bug 2 High total indexes in limit mode, non interpolated
--------------------------------------------------------

Total indexes beween 3.0 and 3.999 (3.999 means just less then 4.0)
were working fine.  What should have happened was that anything above
3 should have resulted in a final index of 3 - to read that value for
all higher total indexes.

Instead, when it was 4, or higher than 4, it was limited to 4 and then
subjected to a binary AND with 3 - reducing the final index to 0!


Bug 3 Interpolate read with offset not at an exact table location
-----------------------------------------------------------------

Wierd things happened when xoff was not pointing exactly at a table
location.  xoff = 0 is fine.  xoff = 3 or 2 is fine.  xoff = 2.1 is
not.  0.1 of each segment (or was it 0.9) would be interpolated from
the next pair of values rather than this pair - a very messy
squarewave error added to the sawtooth result we should normally get
from this table.


Bug 4 Negative total indexes in non interpolated, wrap mode
-----------------------------------------------------------

Due to a problem rounding negative floats to integers (-2.3 was 
becoming 2 when we want it to go to the next most negative integer - -
3) the whole negative range of the output was shifted by one to the
negative.  Using the ANSI function floor() fixed it.

- - - - - 

Josep wrote to me:

> Also, is there any problem with table numbers multiple of 300? I can
> generate 1000 tables (with version 3.47), but the ones numbered 300,
> 600 and 900 give me an error.

I am not running version 3.47, so I have not tested this.

I have not had time in the last year to do any Csounding at all.  Its 
a damn nuisance, but I will eventually have a week or so clear to 
get stuck into it.  I can't do it a few hours at a time.  I am not 
up-to-date with the latest version of Csound.  

Hopefully in a few months, I will get my brains around Tcl/Tk,
Cecilia and fire up the latest version of Csound under Linux on my
Pentium Pro machine.  Then I will probably update all my code which
is not yet part of the "standard" Unix Csound, maybe bring in some
other things, such as some of Gabriel's Maldonado's opcodes:

   http://www.agora.stm.it/G.Maldonado/download.htm

which are not in the "standard" Csound.  Then I will revamp my web 
site and provide source, Linux executables and doco on how to create 
the Csound version that I want to run.

- Robin



| Robin Whittle         Consumer advocacy in telecommunications, |
|                       especially privacy.                      |
|                                                                |
| First Principles      Research and expression - music, tele-   |
|                       communications, Internet music marketing,|
|                       human factors in technology adoption.    |
|                       Consulting and technical writing.        |
|                                                                |
| Real World Interfaces Electronics and software for music.      |
|                                                                |
|   rw@firstpr.com.au   http://www.firstpr.com.au                |
|                                                                |
|   11 Miller St. Heidelberg Heights 3081 Melbourne Australia    |
|   Ph +61 3 9459 2889  Fax +61 3 9458 1736                      |