summaryrefslogtreecommitdiff
path: root/opcodes/nsamp.xml
blob: f802532dd93e6a51e02cb07f565d4c0b3d0fafe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<refentry id="nsamp">
<indexterm id="IndexNsamp"><primary>nsamp</primary></indexterm>
  <refentryinfo><title>Table Control:Table Queries</title></refentryinfo>
  <refmeta>
    <refentrytitle>nsamp</refentrytitle>
  </refmeta>


 
  <refnamediv>
    <refname>nsamp</refname>
    <refpurpose>
      Returns the number of samples loaded into a stored function table number.
          </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      Returns the number of samples loaded into a stored function table number.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis><command>nsamp</command>(x) (init-rate args only)</synopsis>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      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.
    </para>
    <para>
      As of Csound version 5.02, <emphasis>ftlen</emphasis> works with deferred-length function tables (see
      GEN01).
    </para>
    <para>
      <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.
    </para>
  </refsect1>

  <refsect1>
    <title>Examples</title>
    <para>
      Here is an example of the nsamp opcode. It uses the file <ulink url="examples/nsamp.csd"><citetitle>nsamp.csd</citetitle></ulink>, and <ulink url="examples/mary.wav"><citetitle>mary.wav</citetitle></ulink>.

      <example>
        <title>Example of the nsamp opcode.</title>

        

        <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>
          <xi:include href="examples-xml/nsamp.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
      </example>

      Since the audio file <quote>mary.wav</quote> has 154390 samples, its output should include a line like this:
      <screen>
instr 1:  isz = 154390.000
      </screen>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="ftchnls"><citetitle>ftchnls</citetitle></link>,
      <link linkend="ftlen"><citetitle>ftlen</citetitle></link>,
      <link linkend="ftlptim"><citetitle>ftlptim</citetitle></link>,
      <link linkend="ftsr"><citetitle>ftsr</citetitle></link>
    </para>
  </refsect1>
 
  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: &namegabriel;</member>
        <member>Italy</member>
        <member>October 1998</member>
      </simplelist>
    </para>
    <para>Example written by &namekevin;.</para>
  </refsect1>
</refentry>