ftgenonce
Prev | Orchestra Opcodes and Operators | Next

## ftgenonce

ftgenonce — Generate a function table from within an instrument definition, without duplication of data.

## Description

Plugin opcode in signalflowgraph.

Enables the creation of function tables entirely inside instrument definitions, without any duplication of data.

The ftgenonce opcode is designed to simplify writing instrument definitions that can be re-used in different orchestras simply by #including them and plugging them into some output instrument. There is no need to define function tables either in the score, or in the orchestra header.

The ftgenonce opcode is similar to ftgentmp, and has identical arguments. However, function tables are neither duplicated nor deleted. Instead, all of the arguments to the opcode are concatenated to form the key to a lookup table that points to the function table number. Thus, every request to ftgenonce with the same arguments receives the same instance of the function table data. Every change in the value of any ftgenonce argument causes the creation of a new function table.

## Syntax

    ifno ftgenonce ip1, ip2dummy, isize, igen, iarga, iargb, ...

## Initialization

ifno -- an automatically assigned table number.

ip1 -- the number of the table to be generated or 0 if the number is to be assigned.

ip2dummy -- ignored.

isize -- table size. Corresponds to p3 of the score f statement.

igen -- function table GEN routine. Corresponds to p4 of the score f statement.

iarga, iargb, ... -- function table arguments. Correspond to p5 through pn of the score f statement.

| Note
Csound was originally designed to support tables with power of two sizes only. Though this has changed in recent versions (you can use any size by using a negative number), many opcodes will not accept them.

## Examples

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

Example 387. Example of the ftgenonce opcode.

    <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 ftgenonce.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1
    ; Use ftgenonce instead of ftgen, ftgentmp, or f statement
    iHz	= p4
    isine	ftgenonce 0, 0, 1024, 10, 1
    aoscili	pluck .7, iHz, 100, isine, 1
    aadsr 	adsr 0.015, 0.07, 0.6, 0.3
    asig 	= aoscili * aadsr
            outs asig, asig
    endin

    </CsInstruments>
    <CsScore>

    i 1 0 1 220
    i 1 2 1 261
    e
    </CsScore>
    </CsoundSynthesizer>

## Credits

Authors: Michael Gogins
2009

Prev | Up | Next
ftgen | Home | ftgentmp