| 1 | |
| 2 | <refentry id="chn"> |
| 3 | <indexterm id="Indexchn"><primary>chn</primary></indexterm> |
| 4 | <refentryinfo><title>Signal I/O:Software Bus</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>chn</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>chn</refname> |
| 11 | <refpurpose> |
| 12 | Declare a channel of the named software bus. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Declare a channel of the named software bus, with setting optional |
| 20 | parameters in the case of a control channel. If the channel does not |
| 21 | exist yet, it is created, with an inital value of zero or empty string. |
| 22 | Otherwise, the type (control, audio, or string) of the existing channel |
| 23 | must match the declaration, or an init error occurs. The input/output |
| 24 | mode of an existing channel is updated so that it becomes the bitwise |
| 25 | OR of the previous and the newly specified value. |
| 26 | </para> |
| 27 | </refsect1> |
| 28 | |
| 29 | <refsect1> |
| 30 | <title>Syntax</title> |
| 31 | <synopsis> <command>chn_k</command> Sname, imode[, itype, idflt, imin, ima, ix, iy, |
| 32 | iwidth, iheight, Sattributes]</synopsis> |
| 33 | <synopsis> <command>chn_a</command> Sname, imode</synopsis> |
| 34 | <synopsis> <command>chn_S</command> Sname, imode</synopsis> |
| 35 | <synopsis> <command>chn_S</command> Sname, Smode</synopsis> |
| 36 | <synopsis> <command>chn_array</command> Sname, imode, Stype, iSizes[]</synopsis> |
| 37 | </refsect1> |
| 38 | |
| 39 | <refsect1> |
| 40 | <title>Initialization</title> |
| 41 | <para> |
| 42 | <emphasis>imode</emphasis> -- sum of at least one of 1 for input and |
| 43 | 2 for output. |
| 44 | </para> |
| 45 | <para> |
| 46 | <emphasis>Smode</emphasis> -- The mode can also be set with a string: "r" for input, "w" |
| 47 | for output or "rw" for input/output |
| 48 | </para> |
| 49 | <para> |
| 50 | <emphasis>Stypes</emphasis> -- the array channel type ("k", "a", "S"). |
| 51 | </para> |
| 52 | <para> |
| 53 | <emphasis>iSizes[]</emphasis> -- the sizes for each dimension of |
| 54 | the array channel. |
| 55 | </para> |
| 56 | |
| 57 | <para> |
| 58 | <emphasis>itype</emphasis> (optional, defaults to 0) -- channel subtype |
| 59 | for control channels only. Possible values are: |
| 60 | <itemizedlist> |
| 61 | <listitem> |
| 62 | <para> |
| 63 | 0: default/unspecified (<emphasis>idflt</emphasis>, <emphasis>imin</emphasis>, |
| 64 | and <emphasis>imax</emphasis> are ignored) |
| 65 | </para> |
| 66 | </listitem> |
| 67 | <listitem> |
| 68 | <para> |
| 69 | 1: integer values only |
| 70 | </para> |
| 71 | </listitem> |
| 72 | <listitem> |
| 73 | <para> |
| 74 | 2: linear scale |
| 75 | </para> |
| 76 | </listitem> |
| 77 | <listitem> |
| 78 | <para> |
| 79 | 3: exponential scale |
| 80 | </para> |
| 81 | </listitem> |
| 82 | </itemizedlist> |
| 83 | </para> |
| 84 | <para> |
| 85 | <emphasis>idflt</emphasis> (optional, defaults to 0) -- default value, |
| 86 | for control channels with non-zero <emphasis>itype</emphasis> only. |
| 87 | Must be greater than or equal to <emphasis>imin</emphasis>, and less than |
| 88 | or equal to <emphasis>imax</emphasis>. |
| 89 | </para> |
| 90 | <para> |
| 91 | <emphasis>imin</emphasis> (optional, defaults to 0) -- minimum value, |
| 92 | for control channels with non-zero <emphasis>itype</emphasis> only. |
| 93 | Must be non-zero for exponential scale (<emphasis>itype</emphasis> = 3). |
| 94 | </para> |
| 95 | <para> |
| 96 | <emphasis>imax</emphasis> (optional, defaults to 0) -- maximum value, |
| 97 | for control channels with non-zero <emphasis>itype</emphasis> only. |
| 98 | Must be greater than <emphasis>imin</emphasis>. In the case of exponential |
| 99 | scale, it should also match the sign of <emphasis>imin</emphasis>. |
| 100 | </para> |
| 101 | <para> |
| 102 | <emphasis>ix</emphasis> -- suggested x position for controller. |
| 103 | </para> |
| 104 | <para> |
| 105 | <emphasis>iy</emphasis> -- suggested y position for controller. |
| 106 | </para> |
| 107 | <para> |
| 108 | <emphasis>iwidth</emphasis> -- suggested width position for controller. |
| 109 | </para> |
| 110 | <para> |
| 111 | <emphasis>iheight</emphasis> -- suggested height position for controller. |
| 112 | </para> |
| 113 | <para> |
| 114 | <emphasis>Sattributes</emphasis> -- attributes for controller. |
| 115 | </para> |
| 116 | |
| 117 | </refsect1> |
| 118 | |
| 119 | <refsect1> |
| 120 | <title>Notes</title> |
| 121 | <para> |
| 122 | The channel parameters (<emphasis>imode</emphasis>, <emphasis>itype</emphasis>, |
| 123 | <emphasis>idflt</emphasis>, <emphasis>imin</emphasis>, and <emphasis>imax</emphasis>) |
| 124 | are only hints for the host application or external software accessing the bus |
| 125 | through the API, and do not actually restrict reading from or writing |
| 126 | to the channel in any way. Also, the initial value of a newly created |
| 127 | control channel is zero, regardless of the setting of <emphasis>idflt</emphasis>. |
| 128 | </para> |
| 129 | <para> |
| 130 | For communication with external software, using |
| 131 | <link linkend="chnexport"><citetitle>chnexport</citetitle></link> may be |
| 132 | preferred, as it allows direct access to orchestra variables exported |
| 133 | as channels of the bus, eliminating the need for using |
| 134 | <link linkend="chnset"><citetitle>chnset</citetitle></link> and |
| 135 | <link linkend="chnget"><citetitle>chnget</citetitle></link> to send or receive data. |
| 136 | </para> |
| 137 | </refsect1> |
| 138 | |
| 139 | <refsect1> |
| 140 | <title>Performance</title> |
| 141 | <para> |
| 142 | <command>chn_k</command>, <command>chn_a</command>, and |
| 143 | <command>chn_S</command> declare a control, audio, or string channel, |
| 144 | respectively. |
| 145 | </para> |
| 146 | </refsect1> |
| 147 | |
| 148 | <refsect1> |
| 149 | <title>Example</title> |
| 150 | <para> |
| 151 | The example shows the software bus being used as an asynchronous |
| 152 | control signal to select a filter cutoff. It assumes that an |
| 153 | external program that has access to the API is feeding the values. |
| 154 | </para> |
| 155 | |
| 156 | <informalexample> |
| 157 | <programlisting> |
| 158 | <emphasis role="ohdr">sr</emphasis> <emphasis role="op">=</emphasis> 44100 |
| 159 | <emphasis role="ohdr">kr</emphasis> <emphasis role="op">=</emphasis> 100 |
| 160 | <emphasis role="ohdr">ksmps</emphasis> <emphasis role="op">=</emphasis> 1 |
| 161 | |
| 162 | <emphasis role="opc">chn_k</emphasis> "cutoff", 1, 3, 1000, 500, 2000 |
| 163 | |
| 164 | <emphasis role="oblock">instr</emphasis> 1 |
| 165 | kc <emphasis role="opc">chnget</emphasis> "cutoff" |
| 166 | a1 <emphasis role="opc">oscil</emphasis> p4, p5, 100 |
| 167 | a2 <emphasis role="opc">lowpass2</emphasis> a1, kc, 200 |
| 168 | <emphasis role="opc">out</emphasis> a2 |
| 169 | <emphasis role="oblock">endin</emphasis> |
| 170 | </programlisting> |
| 171 | </informalexample> |
| 172 | </refsect1> |
| 173 | |
| 174 | <refsect1> |
| 175 | <title>See also</title> |
| 176 | <para><link linkend="SoftwareBus"><citetitle>Software Bus</citetitle></link></para> |
| 177 | </refsect1> |
| 178 | |
| 179 | <refsect1> |
| 180 | <title>Credits</title> |
| 181 | <para> |
| 182 | <simplelist> |
| 183 | <member>Author: &nameistvan;</member> |
| 184 | <member>2005</member> |
| 185 | </simplelist> |
| 186 | </para> |
| 187 | </refsect1> |
| 188 | </refentry> |