<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>RunningSum</title>
    <link rel="stylesheet" href="styles/default/main.css" type="text/css"/>
    <meta name="generator" content="DocBook XSL Stylesheets V1.70.1"/>
    <link rel="start" href="index.xml" title="SuperCollider Reference Manual"/>
    <link rel="up" href="UGens.Analysis.xml" title="Analysis"/>
    <link rel="prev" href="RunningMin.xml" title="RunningMin"/>
    <link rel="next" href="Slope.xml" title="Slope"/>
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">RunningSum</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="RunningMin.xml">Prev</a> </td>
          <th width="60%" align="center">Analysis</th>
          <td width="20%" align="right"> <a accesskey="n" href="Slope.xml">Next</a></td>
        </tr>
      </table>
    </div>
    <div class="refentry" lang="en"><a id="RunningSum"/><div class="titlepage"/>

  <div class="refnamediv"><h2>RunningSum</h2><p>
    RunningSum
     — 
      A running sum over a user specified number of samples.
      <a id="IndexRunningSum" class="indexterm"/>
    
  </p></div>

  <div class="refsection" lang="en"><a id="id3656342"/>
    <h2>Description</h2>
    <p>
      A running sum over a user specified number of samples, useful for running
      RMS power windowing.
    </p>
    <p>
      The *rms method is equal to:
      <code class="code">
        (RunningSum.ar(in.squared, numsamp) * (numsamp.reciprocal)).sqrt;
      </code>
    </p>
  </div>

  <div class="refsection" lang="en"><a id="id3656366"/>
    <h2>Methods</h2>

    <div class="refsection" lang="en"><a id="id3656370"/>
      <h3>*ar, *kr</h3>

      <code class="methodsynopsis">RunningSum.ar<b>(</b><span class="methodparam">in</span>, <span class="methodparam">numsamp<span class="initializer">: 40</span></span><b>)</b>;</code>

      <code class="methodsynopsis">RunningSum.kr<b>(</b><span class="methodparam">in</span>, <span class="methodparam">numsamp<span class="initializer">: 40</span></span><b>)</b>;</code>

      <div class="variablelist"><table border="0"><col align="left" valign="top"/><tbody><tr><td><span class="term"><em class="parameter"><code>in</code></em></span></td><td>
            
              The input signal.
            
          </td></tr><tr><td><span class="term"><em class="parameter"><code>numsamp</code></em></span></td><td>
            
              How many samples to take the running sum over (initialisation
              time only, not modulatable).
            
          </td></tr></tbody></table></div>

    </div>

    <div class="refsection" lang="en"><a id="id3656474"/>
      <h3>*rms</h3>

      <code class="methodsynopsis">RunningSum.rms<b>(</b><span class="methodparam">in</span>, <span class="methodparam">numsamp<span class="initializer">: 40</span></span><b>)</b>;</code>

      <div class="variablelist"><table border="0"><col align="left" valign="top"/><tbody><tr><td><span class="term"><em class="parameter"><code>in</code></em></span></td><td>
            
              The input signal.
            
          </td></tr><tr><td><span class="term"><em class="parameter"><code>numsamp</code></em></span></td><td>
            
              How many samples to take the running sum over (initialisation
              time only, not modulatable).
            
          </td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns:</em></span></span></td><td>
            
              A newly created <a href="UGen.xml" title="UGen">UGen</a>.
            
          </td></tr></tbody></table></div>

    </div>
  </div>

  <div class="refsection" lang="en"><a id="id3656568"/>
    <h2>Examples</h2>

    <div class="informalexample"><a id="ex.RunningSum-1"/>
      <pre class="programlisting">//overloads of course- would need scaling	
{RunningSum.ar(AudioIn.ar)}.play		
	
//Running Average over x samples	
(
{
var x =100;

RunningSum.ar(LFSaw.ar,x)*(x.reciprocal)
}.play
)

//RMS Power
(
{
var input, numsamp;

input= LFSaw.ar;
numsamp=30;

(RunningSum.ar(input.squared,numsamp)/numsamp).sqrt
}.play
)


//shortcut in class
{RunningSum.rms(AudioIn.ar)}.play		


//play around
(
{
var input, numsamp, power;

input= AudioIn.ar;
numsamp=500;
power= MouseX.kr(0.1,4);

(RunningSum.ar(input**power,numsamp)/numsamp)**(power.reciprocal)
}.play
)
</pre>
    </div>
  </div>

  <div class="refsection" lang="en"><a id="id3656586"/>
    <h2>See Also</h2>
    <p>
      
      <a href="RunningMax.xml" title="RunningMax">RunningMax</a>,
      <a href="RunningMin.xml" title="RunningMin">RunningMin</a>.
      
    </p>
  </div>
</div>
    <div class="navfooter">
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="RunningMin.xml">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="UGens.Analysis.xml">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="Slope.xml">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">RunningMin </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.xml">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Slope</td>
        </tr>
      </table>
    </div>
  </body>
</html>
