Returns the number of samples loaded into stored function table number x by GEN01. This is useful when a sample is shorter than the power-of-two function table that holds it. New in Csound version 3.49.
As of Csound version 5.02, ftlen works with deferred-length function tables (see GEN01).
nsamp differs from ftlen in that nsamp gives the number of sample frames loaded, while ftlen gives the total number of samples. 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.
Here is an example of the nsamp opcode. It uses the files nsamp.orc, nsamp.sco, and mary.wav.
Example 241. Example of the nsamp opcode.
/* nsamp.orc */ ; Initialize the global variables. sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 ; Instrument #1. instr 1 ; Print out the size (in samples) of Table #1. isz = nsamp(1) print isz endin /* nsamp.orc */
/* nsamp.sco */ ; Table #1: Use an audio file. f 1 0 262144 1 "mary.wav" 0 0 0 ; Play Instrument #1 for 1 second. i 1 0 1 e /* nsamp.sco */
Since the audio file “mary.wav” has 154390 samples, its output should include a line like this:
instr 1: isz = 154390.000