tableimix
Prev | Orchestra Opcodes and Operators | Next

## tableimix

tableimix — Mixes two tables.

## Description

Mixes two tables.

## Syntax

    tableimix idft, idoff, ilen, is1ft, is1off, is1g, is2ft, is2off, is2g

## Initialization

idft -- Destination function table.

idoff -- Offset to start writing from. Can be negative.

ilen -- Number of write operations to perform. Negative means work backwards.

is1ft, is2ft -- Source function tables. These can be the same as the destination table, if care is exercised about direction of copying data.

is1off, is2off -- Offsets to start reading from in source tables.

is1g, is2g -- Gains to apply when reading from the source tables. The results are added and the sum is written to the destination table.

## Performance

tableimix -- This opcode mixes from two tables, with separate gains into the destination table. Writing is done for ilen locations, usually stepping forward through the table - if ilen 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 ilen is 0, no writing occurs. Note that the internal integer value of ilen is derived from the ANSI C floor() function - which returns the next most negative integer. Hence a fractional negative ilen 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 ilen. 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 tableigpw afterwards.

The indexes and offsets are all in table steps - they are not normalized to 0 - 1. So for a table of length 256, ilen 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.

## Examples

Here is an example of the tableimix opcode. It uses the file tableimix.csd.

Example 1030. Example of the tableimix opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac   ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o tableimix.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    gisine ftgen 1, 0, 256, 10, 1, 0, 0, .4		;sinoid
    gisaw  ftgen 2, 0, 1024, 7, 0, 256, 1		;saw
    gimix  ftgen 100, 0, 256, 7, 0, 256, 1		;used to mix

    instr 1

          tableimix 100, 0, 256, 1, 0, 1, 2, 0, .5
    asig  poscil .5, 110, gimix			;mix table 1 & 2
          outs   asig, asig

    endin
    </CsInstruments>
    <CsScore>

    i1 0 5
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

tablecopy, tablegpw, tablemix, tableicopy, tableigpw

## Credits

Author: Robin Whittle
Australia
May 1997

New in version 3.47

Prev | Up | Next
tableikt | Home | tablekt