ftlen

ftlen — Returns the size of a stored function table.

Description

Returns the size of a stored function table.

Syntax

ftlen(x) (init-rate args only)

Performance

Returns the size (number of points, excluding guard point) of stored function table, number x. While most units referencing a stored table will automatically take its size into account (so tables can be of arbitrary length), this function reports the actual size if that is needed. Note that ftlen will always return a power-of-2 value, i.e. the function table guard point (see f Statement) is not included.As of Csound version 3.53, ftlen works with deferred function tables (see GEN01).

ftlen differs from nsamp in that nsamp gives the number of sample frames loaded, while ftlen gives the total number of samples without the guard point. For example, with a stereo sound file of 10000 samples, ftlen() would return 19999 (i.e. a total of 20000 mono samples, not including a guard point), but nsamp() returns 10000.

Examples

Here is an example of the ftlen opcode. It uses the file ftlen.csd, fox.wav and drumsMlp.wav.

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

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

instr 1

ift  = ftlen(p4)
     print ift
aout loscil3 .8, 4, p4
     outs aout, aout

endin 
</CsInstruments> 
<CsScore> 
f 1 0 0 1 "fox.wav" 0 0 0 ;Csound computes tablesize
f 2 0 0 1 "drumsMlp.wav" 0 0 0 ;Csound computes tablesize

i 1 0 3 1 ;"fox.wav"
i 1 3 3 2 ;"drumsMlp.wav"

e
</CsScore>
</CsoundSynthesizer>


The audio file fox.wav is 121569 samples long, drumsMlp.wav has a length of 88200 samples. The ftlen opcode reports them as 121568 and 88199 samples, because it reserves 1 point for the guard point. Its output should include lines like these:

instr 1:  ift = 121568.000
instr 1:  ift = 88199.000
      

See also

Table Control:Table Queries

Credits

Author: Barry L. Vercoe
MIT
Cambridge, Massachussetts
1997