| 1 | |
| 2 | <refentry id="chnset"> |
| 3 | <indexterm id="Indexchnset"><primary>chnset</primary></indexterm> |
| 4 | <refentryinfo><title>Signal I/O:Software Bus</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>chnset</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>chnset</refname> |
| 11 | <refpurpose> |
| 12 | Writes data to the named software bus. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Write to a channel of the named software bus. Implies declaring the |
| 20 | channel with <emphasis>imod</emphasis>=2 (see also |
| 21 | <link linkend="chn"><citetitle>chn_k, chn_a, and chn_S</citetitle></link>). |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis><command>chnset</command> ival, Sname</synopsis> |
| 28 | <synopsis><command>chnset</command> kval, Sname</synopsis> |
| 29 | <synopsis><command>chnset</command> aval, Sname</synopsis> |
| 30 | <synopsis><command>chnset</command> Sval, Sname</synopsis> |
| 31 | <synopsis><command>chnsetks</command> Sval, Sname</synopsis> |
| 32 | <synopsis><command>chnseti</command> ival[], []Sname</synopsis> |
| 33 | <synopsis><command>chnsetk</command> kval[], []Sname</synopsis> |
| 34 | <synopsis><command>chnseta</command> aval[], []Sname</synopsis> |
| 35 | <synopsis><command>chnsets</command> Sval[], []Sname</synopsis> |
| 36 | </refsect1> |
| 37 | |
| 38 | <refsect1> |
| 39 | <title>Initialization</title> |
| 40 | <para> |
| 41 | <emphasis>Sname</emphasis> -- a string that indicates which |
| 42 | named channel of the software bus to write. |
| 43 | </para> |
| 44 | <para> |
| 45 | <emphasis>Sname[]</emphasis> -- an array of string that indicates which |
| 46 | named channels of the software bus to write to. |
| 47 | </para> |
| 48 | <para> |
| 49 | <emphasis>ival</emphasis> -- the control value to write at i-time. |
| 50 | </para> |
| 51 | <para> |
| 52 | <emphasis>ival[]</emphasis> -- an array of control values to write at i-time. |
| 53 | </para> |
| 54 | <para> |
| 55 | <emphasis>Sval</emphasis> -- the string value to write at i-time. |
| 56 | </para> |
| 57 | <para> |
| 58 | <emphasis>Sval[]</emphasis> -- an array of string values to write at i-time. |
| 59 | </para> |
| 60 | </refsect1> |
| 61 | |
| 62 | <refsect1> |
| 63 | <title>Performance</title> |
| 64 | <para> |
| 65 | <emphasis>kval</emphasis> -- the control value to write at performance |
| 66 | time. |
| 67 | </para> |
| 68 | <para> |
| 69 | <emphasis>aval</emphasis> -- the audio signal to write at performance |
| 70 | time. |
| 71 | </para> |
| 72 | <para> |
| 73 | <emphasis>Sval</emphasis> -- the string value to write at |
| 74 | perf-time. The opcode chnset with strings works at both i- and |
| 75 | perf-time, whereas chnsetks works only a perf-time. Channel |
| 76 | contents are only updated if the string variable is modified. |
| 77 | </para> |
| 78 | <para> |
| 79 | <emphasis>kval[]</emphasis> -- an array of control values to write at performance |
| 80 | time. |
| 81 | </para> |
| 82 | <para> |
| 83 | <emphasis>aval[]</emphasis> -- an array of audio vectors to write at performance |
| 84 | time. |
| 85 | </para> |
| 86 | </refsect1> |
| 87 | |
| 88 | <note> |
| 89 | <para> |
| 90 | Although it is possible to loop through channel names from an array with <emphasis>chnget</emphasis> and <emphasis>chnset</emphasis>, |
| 91 | using the array based channel opcodes is more efficient. |
| 92 | </para> |
| 93 | </note> |
| 94 | |
| 95 | <refsect1> |
| 96 | <title>Example</title> |
| 97 | <para> |
| 98 | The example shows the software bus being used to write pitch |
| 99 | information to a controlling program. |
| 100 | </para> |
| 101 | |
| 102 | <informalexample> |
| 103 | <programlisting> |
| 104 | <emphasis role="ohdr">sr</emphasis> <emphasis role="op">=</emphasis> 44100 |
| 105 | <emphasis role="ohdr">kr</emphasis> <emphasis role="op">=</emphasis> 100 |
| 106 | <emphasis role="ohdr">ksmps</emphasis> <emphasis role="op">=</emphasis> 1 |
| 107 | |
| 108 | <emphasis role="oblock">instr</emphasis> 1 |
| 109 | a1 <emphasis role="opc">in</emphasis> |
| 110 | kp,ka <emphasis role="opc">pitchamdf</emphasis> a1 |
| 111 | <emphasis role="opc">chnset</emphasis> kp, "pitch" |
| 112 | <emphasis role="oblock">endin</emphasis> |
| 113 | </programlisting> |
| 114 | </informalexample> |
| 115 | <para> |
| 116 | Here is another example of the chnset opcode. It uses the file <ulink url="examples/chnset.csd"><citetitle>chnset.csd</citetitle></ulink>. |
| 117 | <example> |
| 118 | <title>Example of the chnset opcode.</title> |
| 119 | <xi:include href="examples-xml/chnset.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 120 | </example> |
| 121 | </para> |
| 122 | </refsect1> |
| 123 | |
| 124 | <refsect1> |
| 125 | <title>See also</title> |
| 126 | <para><link linkend="SoftwareBus"><citetitle>Software Bus</citetitle></link></para> |
| 127 | </refsect1> |
| 128 | |
| 129 | <refsect1> |
| 130 | <title>Credits</title> |
| 131 | <para> |
| 132 | <simplelist> |
| 133 | <member>Author: &nameistvan;</member> |
| 134 | <member>2005</member> |
| 135 | <member>Array based channel opcodes added in version 6.14 - Rory Walsh</member> |
| 136 | </simplelist> |
| 137 | </para> |
| 138 | </refsect1> |
| 139 | </refentry> |