tabmorphi
Prev | Orchestra Opcodes and Operators | Next

## tabmorphi

tabmorphi — Allow morphing between a set of tables with interpolation.

## Description

tabmorphi allows morphing between a set of tables of the same size, by means of a weighted average between two currently selected tables.

## Syntax

    kout tabmorphi kindex, kweightpoint, ktabnum1, ktabnum2, \
          ifn1, ifn2 [, ifn3, ifn4, ..., ifnN]

## Initialization

ifn1, ifn2 [, ifn3, ifn4, ..., ifnN] - function table numbers. This is a set of chosen tables the user want to use in the morphing. All tables must have the same length. Be aware that only two of these tables can be chosen for the morphing at one time. Since it is possible to use non-integer numbers for the ktabnum1 and ktabnum2 arguments, the morphing is the result from the interpolation between adjacent consecutive tables of the set.

## Performance

kout - The output value for index kindex, resulting from morphing two tables (see below).

kindex - main index index of the morphed resultant table. The range is 0 to table_length (not included).

kweightpoint - the weight of the influence of a pair of selected tables in the morphing. The range of this argument is 0 to 1. A zero makes it output the first table unaltered, a 1 makes it output the second table of the pair unaltered. All intermediate values between 0 and 1 determine the gradual morphing between the two tables of the pair.

ktabnum1 - the first table chosen for the morphing. This number doesn’t express the table number directly, but the position of the table in the set sequence (starting from 0 to N-1). If this number is an integer, the corresponding table will be chosen unaltered. If it contains fractional values, then an interpolation with the next adjacent table will result.

ktabnum2 - the second table chosen for the morphing. This number doesn’t express the table number directly, but the position of the table in the set sequence (starting from 0 to N-1). If this number is an integer, corresponding table will be chosen unaltered. If it contains fractional values, then an interpolation with the next adjacent table will result.

The tabmorphi family of opcodes is similar to the table family, but allows morphing between two tables chosen into a set of tables. Firstly the user has to provide a set of tables of equal length (ifn2 [, ifn3, ifn4, ..., ifnN]). Then he can choose a pair of tables in the set in order to perform the morphing: ktabnum1 and ktabnum2 are filled with numbers (zero represents the first table in the set, 1 the second, 2 the third and so on). Then determine the morphing between the two chosen tables with the kweightpoint parameter. After that the resulting table can be indexed with the kindex parameter like a normal table opcode. If the value of this parameter surpasses the length of tables (which must be the same for all tables), then it is wrapped around.

tabmorphi is identical to tabmorph, but it performs linear interpolation for non-integer values of kindex, much like tablei.

## Examples

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

Example 915. Example of the tabmorphi 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 tabmorphi.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    giSine   ftgen 0, 0, 8193, 10, 1				;sine wave
    giSquare ftgen 0, 0, 8193, 7, 1, 4096, 1, 0, -1, 4096, -1	;square wave
    giTri    ftgen 0, 0, 8193, 7, 0, 2048, 1, 4096, -1, 2048, 0	;triangle wave
    giSaw    ftgen 0, 0, 8193, 7, 1, 8192, -1			;sawtooth wave, downward slope

    instr    1

    iamp   = .7
    kindex phasor 440			;read table value at this index
    kindex = kindex*8192			;for all 8192 index points
    kweightpoint = 0.5			;set weightpoint
    ktabnum1 line 0, p3, 3			;morph through all tables
    ktabnum2 = 2				;set to triangle wave
    ksig tabmorphi kindex, kweightpoint, ktabnum1, ktabnum2, giSine, giSquare, giTri, giSaw
    ksig = ksig*iamp
    asig interp ksig			;convert to audio signal
    outs asig, asig

    endin
    </CsInstruments>
    <CsScore>

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

## See Also

table, tabmorph, tabmorpha, tabmorphak, ftmorf,

## Credits

Author: Gabriel Maldonado

New in version 5.06

Prev | Up | Next
tabmorphak | Home | tabplay