| 1 | |
| 2 | <refentry id="nsamp"> |
| 3 | <indexterm id="IndexNsamp"><primary>nsamp</primary></indexterm> |
| 4 | <refentryinfo><title>Table Control:Table Queries</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>nsamp</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>nsamp</refname> |
| 11 | <refpurpose> |
| 12 | Returns the number of samples loaded into a stored function table number. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Returns the number of samples loaded into a stored function table number. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis><command>nsamp</command>(x) (init-rate args only)</synopsis> |
| 26 | </refsect1> |
| 27 | |
| 28 | <refsect1> |
| 29 | <title>Performance</title> |
| 30 | <para> |
| 31 | Returns the number of samples loaded into stored function table number <emphasis>x</emphasis> 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. |
| 32 | </para> |
| 33 | <para> |
| 34 | As of Csound version 5.02, <emphasis>nsamp</emphasis> works with deferred-length function tables (see |
| 35 | <link linkend="GEN01"><citetitle>GEN01</citetitle></link>). |
| 36 | </para> |
| 37 | <para> |
| 38 | <emphasis>nsamp</emphasis> differs from <emphasis>ftlen</emphasis> in that <emphasis>nsamp</emphasis> gives the number of sample frames loaded, while <emphasis>ftlen</emphasis> 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. |
| 39 | </para> |
| 40 | </refsect1> |
| 41 | |
| 42 | <refsect1> |
| 43 | <title>Examples</title> |
| 44 | <para> |
| 45 | Here is an example of the nsamp opcode. It uses the file <ulink url="examples/nsamp.csd"><citetitle>nsamp.csd</citetitle></ulink>, <ulink url="examples/drumsSlp.wav"><citetitle>drumsSlp.wav</citetitle></ulink>. and <ulink url="examples/fox.wav"><citetitle>fox.wav</citetitle></ulink>. |
| 46 | <example> |
| 47 | <title>Example of the nsamp opcode.</title> |
| 48 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 49 | <xi:include href="examples-xml/nsamp.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 50 | </example> |
| 51 | Since the stereo audio file <quote>drumsSlp.wav</quote> has 176400 samples and the mono file <quote>fox.wav</quote> has 121569 samples, its output should include lines like these: |
| 52 | <screen> |
| 53 | actual numbers of samples = 176400 |
| 54 | actual numbers of samples = 121569</screen> |
| 55 | </para> |
| 56 | </refsect1> |
| 57 | |
| 58 | <refsect1> |
| 59 | <title>See also</title> |
| 60 | <para><link linkend="TableQueries"><citetitle>Table Control:Table Queries</citetitle></link></para> |
| 61 | </refsect1> |
| 62 | |
| 63 | <refsect1> |
| 64 | <title>Credits</title> |
| 65 | <para> |
| 66 | <simplelist> |
| 67 | <member>Author: &namegabriel;</member> |
| 68 | <member>Italy</member> |
| 69 | <member>October 1998</member> |
| 70 | </simplelist> |
| 71 | </para> |
| 72 | </refsect1> |
| 73 | </refentry> |