<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>chnget</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="chnexport.html" title="chnexport" /> <link rel="next" href="chnmix.html" title="chnmix" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">chnget</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="chnexport.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="chnmix.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="chnget"> <a id="chnget"></a> <div class="titlepage"></div> <a id="Indexchnget" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">chnget</span> </h2> <p>chnget — Reads data from the software bus. </p> </div> <div class="refsect1" title="Description"> <a id="idp15666104"></a> <h2>Description</h2> <p> Reads data from a channel of the inward named software bus. Implies declaring the channel with <span class="emphasis"><em>imode</em></span>=1 (see also <a class="link" href="chn.html" title="chn"><em class="citetitle">chn_k, chn_a, and chn_S</em></a>). </p> </div> <div class="refsect1" title="Syntax"> <a id="idp15667504"></a> <h2>Syntax</h2> <pre class="synopsis">ival <span class="command"><strong>chnget</strong></span> Sname</pre> <pre class="synopsis">kval <span class="command"><strong>chnget</strong></span> Sname</pre> <pre class="synopsis">aval <span class="command"><strong>chnget</strong></span> Sname</pre> <pre class="synopsis">Sval <span class="command"><strong>chnget</strong></span> Sname</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp15750512"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>Sname</em></span> -- a string that identifies a channel of the named software bus to read. </p> <p> <span class="emphasis"><em>ival</em></span> -- the control value read at i-time. </p> <p> <span class="emphasis"><em>Sval</em></span> -- the string value read at i-time. </p> </div> <div class="refsect1" title="Performance"> <a id="idp15752312"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kval</em></span> -- the control value read at performance time. </p> <p> <span class="emphasis"><em>aval</em></span> -- the audio signal read at performance time. </p> </div> <div class="refsect1" title="Example"> <a id="idp15753632"></a> <h2>Example</h2> <p> The example shows the software bus being used as an asynchronous control signal to select a filter cutoff. It assumes that an external program that has access to the API is feeding the values. </p> <div class="informalexample"> <pre class="programlisting"> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">kr</span> <span class="op">=</span> 100 <span class="ohdr">ksmps</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1 kc <span class="opc">chnget</span> "cutoff" a1 <span class="opc">oscil</span> p4, p5, 100 a2 <span class="opc">lowpass2</span> a1, kc, 200 <span class="opc">out</span> a2 <span class="oblock">endin</span> </pre> </div> <p> Here is another example of the chnget opcode. It uses the file <a class="ulink" href="examples/chnget.csd" target="_top"><em class="citetitle">chnget.csd</em></a>. </p> <div class="example"> <a id="idp15759728"></a> <p class="title"> <strong>Example 103. Example of the chnget opcode.</strong> </p> <div class="example-contents"> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> -odac <span class="comment">;;;realtime audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o chnget.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">;Example by Joachim Heintz</span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 32 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1<span class="comment">; send i-values</span> <span class="opc">chnset</span> 1, "sio" <span class="opc">chnset</span> <span class="op">-</span>1, "non" <span class="oblock">endin</span> <span class="oblock">instr</span> 2<span class="comment">; send k-values</span> kfreq <span class="opc">randomi</span> 100, 300, 1 <span class="opc">chnset</span> kfreq, "cntrfreq" kbw <span class="op">=</span> kfreq<span class="op">/</span>10 <span class="opc">chnset</span> kbw, "bandw" <span class="oblock">endin</span> <span class="oblock">instr</span> 3<span class="comment">; send a-values</span> anois <span class="opc">rand</span> .1 <span class="opc">chnset</span> anois, "noise" loop<span class="op">:</span> idur <span class="opc">random</span> .3, 1.5 <span class="octrl">timout</span> 0, idur, do <span class="opc">reinit</span> loop do<span class="op">:</span> ifreq <span class="opc">random</span> 400, 1200 iamp <span class="opc">random</span> .1, .3 asig <span class="opc">oscils</span> iamp, ifreq, 0 aenv <span class="opc">transeg</span> 1, idur, <span class="op">-</span>10, 0 asine <span class="op">=</span> asig <span class="op">*</span> aenv <span class="opc">chnset</span> asine, "sine" <span class="oblock">endin</span> <span class="oblock">instr</span> 11<span class="comment">; receive some chn values and send again</span> ival1 <span class="opc">chnget</span> "sio" ival2 <span class="opc">chnget</span> "non" <span class="opc">print</span> ival1, ival2 kcntfreq <span class="opc">chnget</span> "cntrfreq" kbandw <span class="opc">chnget</span> "bandw" anoise <span class="opc">chnget</span> "noise" afilt <span class="opc">reson</span> anoise, kcntfreq, kbandw afilt <span class="opc">balance</span> afilt, anoise <span class="opc">chnset</span> afilt, "filtered" <span class="oblock">endin</span> <span class="oblock">instr</span> 12<span class="comment">; mix the two audio signals</span> amix1 <span class="opc">chnget</span> "sine" amix2 <span class="opc">chnget</span> "filtered" <span class="opc">chnmix</span> amix1, "mix" <span class="opc">chnmix</span> amix2, "mix" <span class="oblock">endin</span> <span class="oblock">instr</span> 20<span class="comment">; receive and reverb</span> amix <span class="opc">chnget</span> "mix" aL, aR <span class="opc">freeverb</span> amix, amix, .8, .5 <span class="opc">outs</span> aL, aR <span class="oblock">endin</span> <span class="oblock">instr</span> 100<span class="comment">; clear</span> <span class="opc">chnclear</span> "mix" <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">i</span> 1 0 20 <span class="stamnt">i</span> 2 0 20 <span class="stamnt">i</span> 3 0 20 <span class="stamnt">i</span> 11 0 20 <span class="stamnt">i</span> 12 0 20 <span class="stamnt">i</span> 20 0 20 <span class="stamnt">i</span> 100 0 20 <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="Credits"> <a id="idp15760736"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Istvan Varga</td> </tr> <tr> <td>2005</td> </tr> </table> <p> </p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="chnexport.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="chnmix.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">chnexport </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> chnmix</td> </tr> </table> </div> </body> </html>