| 1 |
|
| 2 |
<refentry id="chnexport"> |
| 3 |
<indexterm id="Indexchnexport"><primary>chnexport</primary></indexterm> |
| 4 |
<refentryinfo><title>Signal I/O:Software Bus</title></refentryinfo> |
| 5 |
<refmeta> |
| 6 |
<refentrytitle>chnexport</refentrytitle> |
| 7 |
</refmeta> |
| 8 |
|
| 9 |
<refnamediv> |
| 10 |
<refname>chnexport</refname> |
| 11 |
<refpurpose> |
| 12 |
Export a global variable as a channel of the bus. |
| 13 |
</refpurpose> |
| 14 |
</refnamediv> |
| 15 |
|
| 16 |
<refsect1> |
| 17 |
<title>Description</title> |
| 18 |
<para> |
| 19 |
Export a global variable as a channel of the bus; the channel |
| 20 |
should not already exist, otherwise an init error occurs. |
| 21 |
This opcode is normally called from the orchestra header, and allows |
| 22 |
the host application to read or write orchestra variables directly, |
| 23 |
without having to use |
| 24 |
<link linkend="chnget"><citetitle>chnget</citetitle></link> or |
| 25 |
<link linkend="chnset"><citetitle>chnset</citetitle></link> to copy data. |
| 26 |
</para> |
| 27 |
</refsect1> |
| 28 |
|
| 29 |
<refsect1> |
| 30 |
<title>Syntax</title> |
| 31 |
<synopsis>gival <command>chnexport</command> Sname, imode[, itype, idflt, imin, imax]</synopsis> |
| 32 |
<synopsis>gkval <command>chnexport</command> Sname, imode[, itype, idflt, imin, imax]</synopsis> |
| 33 |
<synopsis>gaval <command>chnexport</command> Sname, imode</synopsis> |
| 34 |
<synopsis>gSval <command>chnexport</command> Sname, imode</synopsis> |
| 35 |
</refsect1> |
| 36 |
|
| 37 |
<refsect1> |
| 38 |
<title>Initialization</title> |
| 39 |
<para> |
| 40 |
<emphasis>imode</emphasis> -- sum of at least one of 1 for input and |
| 41 |
2 for output. |
| 42 |
</para> |
| 43 |
<para> |
| 44 |
<emphasis>itype</emphasis> (optional, defaults to 0) -- channel subtype |
| 45 |
for control channels only. Possible values are: |
| 46 |
<itemizedlist> |
| 47 |
<listitem> |
| 48 |
<para> |
| 49 |
0: default/unspecified (<emphasis>idflt</emphasis>, <emphasis>imin</emphasis>, |
| 50 |
and <emphasis>imax</emphasis> are ignored) |
| 51 |
</para> |
| 52 |
</listitem> |
| 53 |
<listitem> |
| 54 |
<para> |
| 55 |
1: integer values only |
| 56 |
</para> |
| 57 |
</listitem> |
| 58 |
<listitem> |
| 59 |
<para> |
| 60 |
2: linear scale |
| 61 |
</para> |
| 62 |
</listitem> |
| 63 |
<listitem> |
| 64 |
<para> |
| 65 |
3: exponential scale |
| 66 |
</para> |
| 67 |
</listitem> |
| 68 |
</itemizedlist> |
| 69 |
</para> |
| 70 |
<para> |
| 71 |
<emphasis>idflt</emphasis> (optional, defaults to 0) -- default value, |
| 72 |
for control channels with non-zero <emphasis>itype</emphasis> only. |
| 73 |
Must be greater than or equal to <emphasis>imin</emphasis>, and less than |
| 74 |
or equal to <emphasis>imax</emphasis>. |
| 75 |
</para> |
| 76 |
<para> |
| 77 |
<emphasis>imin</emphasis> (optional, defaults to 0) -- minimum value, |
| 78 |
for control channels with non-zero <emphasis>itype</emphasis> only. |
| 79 |
Must be non-zero for exponential scale (<emphasis>itype</emphasis> = 3). |
| 80 |
</para> |
| 81 |
<para> |
| 82 |
<emphasis>imax</emphasis> (optional, defaults to 0) -- maximum value, |
| 83 |
for control channels with non-zero <emphasis>itype</emphasis> only. |
| 84 |
Must be greater than <emphasis>imin</emphasis>. In the case of exponential |
| 85 |
scale, it should also match the sign of <emphasis>imin</emphasis>. |
| 86 |
</para> |
| 87 |
|
| 88 |
</refsect1> |
| 89 |
|
| 90 |
<refsect1> |
| 91 |
<title>Notes</title> |
| 92 |
<para> |
| 93 |
The channel parameters (<emphasis>imode</emphasis>, <emphasis>itype</emphasis>, |
| 94 |
<emphasis>idflt</emphasis>, <emphasis>imin</emphasis>, and <emphasis>imax</emphasis>) |
| 95 |
are only hints for the host application or external software accessing the bus |
| 96 |
through the API, and do not actually restrict reading from or writing |
| 97 |
to the channel in any way. |
| 98 |
</para> |
| 99 |
<para> |
| 100 |
While the global variable is used as output argument, <emphasis>chnexport</emphasis> |
| 101 |
does not actually change it, and always runs at i-time only. If the variable |
| 102 |
is not previously declared, it is created by Csound with an initial |
| 103 |
value of zero or empty string. |
| 104 |
</para> |
| 105 |
</refsect1> |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
<refsect1> |
| 114 |
<title>Example</title> |
| 115 |
<para> |
| 116 |
The example shows the software bus being used as an asynchronous |
| 117 |
control signal to select a filter cutoff. It assumes that an |
| 118 |
external program that has access to the API is feeding the values. |
| 119 |
</para> |
| 120 |
|
| 121 |
<informalexample> |
| 122 |
<programlisting> |
| 123 |
<emphasis role="ohdr">sr</emphasis> <emphasis role="op">=</emphasis> 44100 |
| 124 |
<emphasis role="ohdr">kr</emphasis> <emphasis role="op">=</emphasis> 100 |
| 125 |
<emphasis role="ohdr">ksmps</emphasis> <emphasis role="op">=</emphasis> 1 |
| 126 |
|
| 127 |
gkc <emphasis role="opc">init</emphasis> 1000 <emphasis role="comment">; set default value</emphasis> |
| 128 |
gkc <emphasis role="opc">chnexport</emphasis> "cutoff", 1, 3, <emphasis role="opc">i</emphasis>(gkc), 500, 2000 |
| 129 |
|
| 130 |
<emphasis role="oblock">instr</emphasis> 1 |
| 131 |
a1 <emphasis role="opc">oscil</emphasis> p4, p5, 100 |
| 132 |
a2 <emphasis role="opc">lowpass2</emphasis> a1, gkc, 200 |
| 133 |
<emphasis role="opc">out</emphasis> a2 |
| 134 |
<emphasis role="oblock">endin</emphasis> |
| 135 |
</programlisting> |
| 136 |
</informalexample> |
| 137 |
</refsect1> |
| 138 |
|
| 139 |
<refsect1> |
| 140 |
<title>See also</title> |
| 141 |
<para><link linkend="SoftwareBus"><citetitle>Software Bus</citetitle></link></para> |
| 142 |
</refsect1> |
| 143 |
|
| 144 |
<refsect1> |
| 145 |
<title>Credits</title> |
| 146 |
<para> |
| 147 |
<simplelist> |
| 148 |
<member>Author: &nameistvan;</member> |
| 149 |
<member>2005</member> |
| 150 |
</simplelist> |
| 151 |
</para> |
| 152 |
</refsect1> |
| 153 |
</refentry> |