summaryrefslogtreecommitdiff
path: root/opcodes/cpstuni.xml
blob: d923be8249f4a1cfc237b41948a4a6ae3e314f42 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<refentry id="cpstuni">
<indexterm id="IndexCpstuni"><primary>cpstuni</primary></indexterm>
  <refentryinfo><title>Pitch Converters:Tuning Opcodes</title></refentryinfo>
  <refmeta>
    <refentrytitle>cpstuni</refentrytitle>
  </refmeta>



  <refnamediv>
    <refname>cpstuni</refname>
    <refpurpose>
      Returns micro-tuning values at init-rate.
    </refpurpose>
  </refnamediv>
  
  <refsect1>
    <title>Description</title>
    <para>
      Returns micro-tuning values at init-rate.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>icps <command>cpstuni</command> index, ifn</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>icps</emphasis> -- Return value in cycles per second.
    </para>

    <para>
      <emphasis>index</emphasis> -- An integer number denoting an index of scale.
    </para>

    <para>
      <emphasis>ifn</emphasis> -- Function table containing the parameters (numgrades, interval, basefreq, basekeymidi) and the tuning ratios.
    </para>
  </refsect1>

  <refsect1>
    <title>Performance</title>
    <para>
      These opcodes are similar to <link linkend="cpstmid"><citetitle>cpstmid</citetitle></link>, but work without necessity of MIDI.
    </para>

    <para>
      <emphasis>cpstuni</emphasis> works at init-rate. It allows fully customized micro-tuning scales. It requires a function table number containing the tuning ratios, and some other parameters stored in the function table itself.
    </para>

    <para>
      The <emphasis>index</emphasis> argument should be filled with integer numbers expressing the grade of given scale to be converted in cps. The function table <emphasis>ifn</emphasis> should be generated by <link linkend="GEN02"><citetitle>GEN02</citetitle></link> and the first four values stored in this function are parameters that express:
      <itemizedlist>
        <listitem><para>numgrades -- The number of grades of the micro-tuning scale.</para></listitem>

        <listitem><para>interval -- The frequency range covered before repeating the grade ratios, for example 2 for one octave, 1.5 for a fifth etcetera.</para></listitem>

        <listitem><para>basefreq -- The base frequency of the scale in cycles per second.</para></listitem>

        <listitem><para>basekey -- The integer index of the scale to which to assign basefreq unmodified.</para></listitem>
      </itemizedlist>
    </para>

    <para>
      After these four values, the user can begin to insert the tuning ratios.  For example, for a standard 12-grade scale with the base-frequency of 261 cps assigned to the key-number 60, the corresponding f-statement in the score to generate the table should be:

      <informalexample>
        <programlisting>
<emphasis role="comment">;           numgrades    basefreq     tuning-ratios (eq.temp) .......</emphasis>
<emphasis role="comment">;                  interval    basekey</emphasis>
<emphasis role="stamnt">f</emphasis>1 0 64 -2  12     2     261   60     1   1.059463 1.12246 1.18920 ..etc...</programlisting>
      </informalexample>
    </para>

    <para>
Another example with a 24-grade scale with a base frequency of 440 assigned
to the key-number 48, and a repetition interval of 1.5:

      <informalexample>
        <programlisting>
<emphasis role="comment">;                  numgrades       basefreq      tuning-ratios .......</emphasis>
<emphasis role="comment">;                          interval       basekey</emphasis>
<emphasis role="stamnt">f</emphasis>1 0 64 -2         24      1.5     440    48     1   1.01  1.02  1.03   ..etc...</programlisting>
      </informalexample>
    </para>
  </refsect1>

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

      <example>
        <title>Example of the cpstuni 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/cpstuni.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
      </example>

      Its output should include lines like this:
      <screen>instr 1:  i1 = 440.110</screen>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="cpstmid"><citetitle>cpstmid</citetitle></link>,
      <link linkend="cpstun"><citetitle>cpstun</citetitle></link>,
      <link linkend="GEN02"><citetitle>GEN02</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>Written by &namegabriel;.</para>
    <para>Example written by &namekevin;.</para>
  </refsect1>
</refentry>