<?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>balance</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="babo.html" title="babo" /> <link rel="next" href="bamboo.html" title="bamboo" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">balance</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="babo.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="bamboo.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="balance"> <a id="balance"></a> <div class="titlepage"></div> <a id="IndexBalance" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">balance</span> </h2> <p>balance — Adjust one audio signal according to the values of another. </p> </div> <div class="refsect1" title="Description"> <a id="idp14347128"></a> <h2>Description</h2> <p> The rms power of asig can be interrogated, set, or adjusted to match that of a comparator signal. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp14395704"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>balance</strong></span> asig, acomp [, ihp] [, iskip]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp14396816"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ihp</em></span> (optional) -- half-power point (in Hz) of a special internal low-pass filter. The default value is 10. </p> <p> <span class="emphasis"><em>iskip</em></span> (optional, default=0) -- initial disposition of internal data space (see <a class="link" href="reson.html" title="reson"><em class="citetitle">reson</em></a>). The default value is 0. </p> </div> <div class="refsect1" title="Performance"> <a id="idp14398880"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>asig</em></span> -- input audio signal </p> <p> <span class="emphasis"><em>acomp</em></span> -- the comparator signal </p> <p> <span class="emphasis"><em>balance</em></span> outputs a version of <span class="emphasis"><em>asig</em></span>, amplitude-modified so that its rms power is equal to that of a comparator signal <span class="emphasis"><em>acomp</em></span>. Thus a signal that has suffered loss of power (eg., in passing through a filter bank) can be restored by matching it with, for instance, its own source. It should be noted that <a class="link" href="gain.html" title="gain"><em class="citetitle">gain</em></a> and <span class="emphasis"><em>balance</em></span> provide amplitude modification only - output signals are not altered in any other respect. </p> </div> <div class="refsect1" title="Examples"> <a id="idp14402280"></a> <h2>Examples</h2> <p> Here is an example of the balance opcode. It uses the file <a class="ulink" href="examples/balance.csd" target="_top"><em class="citetitle">balance.csd</em></a>. </p> <div class="example"> <a id="idp14403264"></a> <p class="title"> <strong>Example 67. Example of the balance opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <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">;;;RT audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o balance.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></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">; Generate a band-limited pulse train.</span> asrc <span class="opc">buzz</span> 0.9, 440, <span class="ohdr">sr</span><span class="op">/</span>440, 1 <span class="comment">; Send the source signal through 2 filters.</span> a1 <span class="opc">reson</span> asrc, 1000, 100 a2 <span class="opc">reson</span> a1, 3000, 500 <span class="comment">; Balance the filtered signal with the source.</span> afin <span class="opc">balance</span> a2, asrc <span class="opc">outs</span> afin, afin <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">;sine wave.</span> <span class="stamnt">f</span> 1 0 16384 10 1 <span class="stamnt">i</span> 1 0 2 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="See Also"> <a id="idp14405576"></a> <h2>See Also</h2> <p> <a class="link" href="gain.html" title="gain"><em class="citetitle">gain</em></a>, <a class="link" href="rms.html" title="rms"><em class="citetitle">rms</em></a> </p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="babo.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="bamboo.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">babo </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> bamboo</td> </tr> </table> </div> </body> </html>