Use Non-Frames Version Previous Page Next Page
Function Table Control: Read/Write Operations

tablegpw, tablemix, tablecopy, tableigpw, tableimix, tableicopy

          tablegpw   kfn
          tablemix   kdft, kdoff, klen, ks1ft, ks1off, ks1g, ks2ft, ks2off, ks2g
          tablecopy  kdft, ksft
          tableigpw  ifn
          tableimix  idft, idoff, ilen, is1ft, is1off, is1g, is2ft, is2off, is2g
          tableicopy idft, isft

Description

These opcodes allow tables to be copied and mixed.

Initialization

ifn – Table number to be interrogated

Performance

kfn – Table number to be interrogated

kdft – Destination function table.

kdoff – Offset to start writing from. Can be negative.

kdft – Number of destination function table.

ksft – Number of source function table.

klen – Number of write operations to perform. Negative means work backwards.

ks1ft, ks2ft – Source function tables. These can be the same as the destination table, if care is exercised about direction of copying data.

ks1off, ks2off -Offsets to start reading from in source tables.

ks1g, ks2g – Gains to apply when reading from the source tables. The results are added and the sum is written to the destination table.

tableng – These return the length of the specified table. This will be a power of two number in most circumstances - it will not show whether a table has a guardpoint or not - it seems this information is not available in the table's data structure. If table is not found, then 0 will be returned.

Likely to be useful for setting up code for table manipulation operations, such as tablemix and tablecopy.

tablgpw – For writing the table's guard point, with the value which is in location 0. Does nothing if table does not exist.

Likely to be useful after manipulating a table with tablemix or tablecopy.

tablemix – This opcode mixes from two tables, with separate gains into the destination table. Writing is done for klen locations, usually stepping forward through the table - if klen is positive. If it is negative, then the writing and reading order is backwards - towards lower indexes in the tables. This bi-directional option makes it easy to shift the contents of a table sideways by reading from it and writing back to it with a different offset.

If klen is 0, no writing occurs. Note that the internal integer value of klen is derived from the ANSI C floor() function - which returns the next most negative integer. Hence a fractional negative klen value of -2.3 would create an internal length of 3, and cause the copying to start from the offset locations and proceed for two locations to the left.

The total index for table reading and writing is calculated from the starting offset for each table, plus the index value, which starts at 0 and then increments (or decrements) by 1 as mixing proceeds.

These total indexes can potentially be very large, since there is no restriction on the offset or the klen. However each total index for each table is ANDed with a length mask (such as 0000 0111 for a table of length 8) to form a final index which is actually used for reading or writing. So no reading or writing can occur outside the tables. This is the same as "wrap" mode in table read and write. These opcodes do not read or write the guardpoint. If a table has been rewritten with one of these, then if it has a guardpoint which is supposed to contain the same value as the location 0, then call tablegpw afterwards.

The indexes and offsets are all in table steps - they are not normalized to 0 - 1. So for a table of length 256, klen should be set to 256 if all the table was to be read or written.

The tables do not need to be the same length - wrapping occurs individually for each table.

tablecopy – Simple, fast table copy opcodes. Takes the table length from the destination table, and reads from the start of the source table. For speed reasons, does not check the source length - just copies regardless - in "wrap" mode. This may read through the source table several times. A source table with length 1 will cause all values in the destination table to be written to its value.

tablecopy cannot read or write the guardpoint. To read it use table, with ndx = the table length. Likewise use table write to write it.

To write the guardpoint to the value in location 0, use tablegpw.

This is primarily to change function tables quickly in a real-time situation.

Name Changes

As of Csound version 3.52, the names of the opcodes itablegpw, itablemix, and itablecopy, have been changed to tableigpw, tableimix, and tableicopy, respectively.

Author

Robin Whittle
Australia
May 1997


Use Non-Frames Version Previous Page Next Page
Function Table Control: Read/Write Operations