Debian Codegraph @

opcodes/setksmps.xml

raw symbols SCIP
1
2 <refentry id="setksmps">
3 <indexterm id="IndexSetksmps"><primary>setksmps</primary></indexterm>
4 <refentryinfo><title>Signal I/O:Software Bus</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>setksmps</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>setksmps</refname>
11 <refpurpose>
12 Sets the local ksmps value in an instrument or user-defined opcode block
13 </refpurpose>
14 </refnamediv>
15
16 <refsect1>
17 <title>Description</title>
18 <para>
19 Sets the local ksmps value in an instrument or user-defined opcode block.
20 </para>
21 </refsect1>
22
23 <refsect1>
24 <title>Syntax</title>
25 <synopsis><command>setksmps</command> iksmps</synopsis>
26 </refsect1>
27
28 <refsect1>
29 <title>Initialization</title>
30 <para>
31 <emphasis>iksmps</emphasis> -- sets the local ksmps value.
32 </para>
33
34 <para>
35 If <emphasis>iksmps</emphasis> is set to zero, the <emphasis>ksmps</emphasis> of the caller instrument or opcode is used (this is the default behavior).
36 </para>
37
38 <note>
39 <title>Note</title>
40 <para>
41 The local <emphasis>ksmps</emphasis> is implemented by splitting up a control period into smaller sub-kperiods and setting up the instrument local ksmps to the new value. This also requires converting the rate of k-rate input and output arguments (input variables receive the same value in all sub-kperiods, while outputs are written only in the last one). It also means that you cannot use a local <link linkend="ksmps"><citetitle>ksmps</citetitle></link> that is higher than the global <link linkend="ksmps"><citetitle>ksmps</citetitle></link>.
42 </para>
43 </note>
44
45 <warning>
46 <title>Warning about local ksmps</title>
47 <para>
48 When the local <emphasis>ksmps</emphasis> is not the same as the orchestra level <emphasis>ksmps</emphasis> value (as specified in the orchestra header), global a-rate operations must be carefully coded to access the data in a vector according to the local ksmps. The audio rate bus channel opcodes (chnget/chnset) can be used freely, however, as they will do the necessary conversion between ksmp sizes.
49 </para>
50
51 <para>
52 Other opcodes that require some care include:
53
54 <itemizedlist>
55 <listitem><para>any access to <quote>ga</quote> variables</para></listitem>
56 <listitem><para>a-rate zak opcodes (<link linkend="zar"><citetitle>zar</citetitle></link>, <link linkend="zaw"><citetitle>zaw</citetitle></link>, etc.)</para></listitem>
57 <listitem><para><link linkend="tablera"><citetitle>tablera</citetitle></link> and <link linkend="tablewa"><citetitle>tablewa</citetitle></link> (these two opcodes may in fact work, but caution is needed)</para></listitem>
58 <listitem><para> The <emphasis>in</emphasis> and <emphasis>out</emphasis> opcode family cannot be used in local-ksmps UDOs (these read from, and write to global a-rate buffers), but are safe in local-ksmps instruments</para></listitem>
59 </itemizedlist>
60 </para>
61
62 <para>
63 In general, the local <emphasis>ksmps</emphasis> should be used with care as it is an experimental feature. Though it works correctly in most cases.
64 </para>
65 </warning>
66
67 <para>
68 The <emphasis>setksmps</emphasis> statement can be used to set the local <link linkend="ksmps"><citetitle>ksmps</citetitle></link> value of the instrument or user-defined opcode block. It has one i-time parameter specifying the new <emphasis>ksmps</emphasis> value. <emphasis>setksmps</emphasis> should be used before any other opcodes (but allowed after <link linkend="xin"><citetitle>xin</citetitle></link> in UDOs), otherwise unpredictable results may occur.
69 </para>
70 </refsect1>
71
72 <refsect1>
73 <title>Performance</title>
74 <para>
75 The syntax of a user-defined opcode block is as follows:
76
77 <programlisting>
78 <emphasis role="oblock">opcode</emphasis> name, outtypes, intypes
79 xinarg1 [, xinarg2] [, xinarg3] ... [xinargN] <emphasis role="opc">xin</emphasis>
80 [<emphasis role="opc">setksmps</emphasis> iksmps]
81 ... the rest of the instrument's code.
82 <emphasis role="opc">xout</emphasis> xoutarg1 [, xoutarg2] [, xoutarg3] ... [xoutargN]
83 <emphasis role="oblock">endop</emphasis>
84 </programlisting>
85 </para>
86
87 <para>
88 The new opcode can then be used with the usual syntax:
89
90 <literallayout>
91 [xinarg1] [, xinarg2] ... [xinargN] name [xoutarg1] [, xoutarg2] ... [xoutargN]
92 </literallayout>
93 </para>
94 </refsect1>
95
96 <refsect1>
97 <title>Examples</title>
98 <para>
99 See the example for the <link linkend="opcode"><citetitle>opcode</citetitle></link> opcode.
100 </para>
101 </refsect1>
102
103 <refsect1>
104 <title>See Also</title>
105 <para>
106 <link linkend="OrchUDO"><citetitle>User Defined Opcodes (UDO)</citetitle></link>
107 </para>
108 </refsect1>
109
110 <refsect1>
111 <title>Credits</title>
112 <para>Author: Istvan Varga, 2002; based on code by Matt J. Ingalls; Modified by V Lazzarini for Csound 6</para>
113 <para>New in version 4.22</para>
114 </refsect1>
115 </refentry>