nsamp

nsamp --  Returns the number of samples loaded into a stored function table number.

Description

Returns the number of samples loaded into a stored function table number.

Syntax

nsamp(x) (init-rate args only)

Performance

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.

Examples

Here is an example of the nsamp opcode. It uses the files nsamp.orc, nsamp.sco, and mary.wav.

Example 1. Example of the nsamp opcode.

/* nsamp.orc */
/* Written by Kevin Conder */
; 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 */
/* Written by Kevin Conder */
; 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
      

See Also

ftchnls, ftlen, ftlptim, ftsr

Credits

Authors: Barry L. Vercoe

MIT

Cambridge, Massachussetts

1997

Gabriel Maldonado (ftsr, nsamp)

Italy

October, 1998

Chris McCormick (ftchnls)

Perth, Australia

December 2001