ftgenonce — Generate a score function table from within the orchestra, which is deleted at the end of the note.


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.


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


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] 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.


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

Example 294. Example of the ftgenonce opcode.

; 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

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


i 1 0 1 220 
i 1 2 1 261 


Authors: Michael Gogins