<?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>rms</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="rireturn.html" title="rireturn" /> <link rel="next" href="rnd.html" title="rnd" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">rms</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="rireturn.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="rnd.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="rms"> <a id="rms"></a> <div class="titlepage"></div> <a id="IndexRms" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">rms</span> </h2> <p>rms — Determines the root-mean-square amplitude of an audio signal. </p> </div> <div class="refsect1" title="Description"> <a id="idp40968632"></a> <h2>Description</h2> <p> Determines the root-mean-square amplitude of an audio signal. It low-pass filters the actual value, to average in the manner of a VU meter. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp40946168"></a> <h2>Syntax</h2> <pre class="synopsis">kres <span class="command"><strong>rms</strong></span> asig [, ihp] [, iskip]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp40947224"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ihp</em></span> (optional, default=10) -- 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="idp40991432"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>asig</em></span> -- input audio signal </p> <p> <span class="emphasis"><em>kres</em></span> -- low-pass filtered rms value of the input signal </p> <p> <span class="emphasis"><em>rms</em></span> output values <span class="emphasis"><em>kres</em></span> will trace the root-mean-square value of the audio input <span class="emphasis"><em>asig</em></span>. This unit is not a signal modifier, but functions rather as a signal power-gauge. It uses an internal low-pass filter to make the response smoother. <span class="emphasis"><em>ihp</em></span> can be used to control this smoothing. The higher the value, the "snappier" the measurement. </p> <p> This opcode can also be used as an evelope follower. </p> <p> The <span class="emphasis"><em>kres</em></span> output from this opcode is given in amplitude and depends on <a class="link" href="Zerodbfs.html" title="0dbfs"><em class="citetitle">0dbfs</em></a>. If you want the output in decibels, you can use <a class="link" href="dbamp.html" title="dbamp"><em class="citetitle">dbamp</em></a> </p> </div> <div class="refsect1" title="Examples"> <a id="idp40995792"></a> <h2>Examples</h2> <p> </p> <div class="informalexample"> <pre class="programlisting"> arms <span class="opc">rms</span> asig <span class="comment">; get rms value of signal asig</span> </pre> </div> <p> </p> <p> Here is an example of the rms opcode. It uses the file <a class="ulink" href="examples/rms.csd" target="_top"><em class="citetitle">rms.csd</em></a>. </p> <div class="example"> <a id="idp40998192"></a> <p class="title"> <strong>Example 726. Example of the rms 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> <span class="comment">; Audio out Audio in No messages</span> -odac -iadc -d -m0 <span class="comment">;;;RT audio I/O</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o rms.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">; Initialize the global variables.</span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 128 <span class="ohdr">nchnls</span> <span class="op">=</span> 1 <span class="comment">;Example by Andres Cabrera 2007</span> <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="opc">FLpanel</span> "rms", 400, 100, 50, 50 gkrmstext, gihrmstext <span class="opc">FLtext</span> "Rms", <span class="op">-</span>100, 0, 0.1, 3, 110, 30, 60, 50 gkihp, gihandle <span class="opc">FLtext</span> "ihp", 0, 10, 0.05, 1, 100, 30, 220, 50 gkrmsslider, gihrmsslider <span class="opc">FLslider</span> "", <span class="op">-</span>60, <span class="op">-</span>0.5, <span class="op">-</span>1, 5, <span class="op">-</span>1, 380, 20, 10, 10 <span class="opc">FLpanelEnd</span> <span class="opc">FLrun</span> <span class="opc">FLsetVal_i</span> 5, gihandle <span class="comment">; Instrument #1.</span> <span class="oblock">instr</span> 1 a1 <span class="opc">inch</span> 1 <span class="olabel">label</span><span class="op">:</span> kval <span class="opc">rms</span> a1, <span class="opc">i</span>(gkihp) <span class="comment">;measures rms of input channel 1</span> <span class="opc">rireturn</span> kval <span class="op">=</span> <span class="opc">dbamp</span>(kval) <span class="comment">; convert to db full scale</span> <span class="opc">printk</span> 0.5, kval <span class="opc">FLsetVal</span> 1, kval, gihrmsslider <span class="comment">;update the slider and text values</span> <span class="opc">FLsetVal</span> 1, kval, gihrmstext knewihp <span class="opc">changed</span> gkihp <span class="comment">; reinit when ihp text has changed</span> <span class="octrl">if</span> (knewihp <span class="op">==</span> 1) then <span class="opc">reinit</span> <span class="olabel">label</span> <span class="comment">;needed because ihp is an i-rate parameter</span> <span class="octrl">endif</span> <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Play Instrument #1 for one minute</span> <span class="stamnt">i</span> 1 0 60 <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="idp41000456"></a> <h2>See Also</h2> <p> <a class="link" href="balance.html" title="balance"><em class="citetitle">balance</em></a>, <a class="link" href="gain.html" title="gain"><em class="citetitle">gain</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="rireturn.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="rnd.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">rireturn </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> rnd</td> </tr> </table> </div> </body> </html>