Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 513

csound-doc-5.19.01-10.mga5.noarch.rpm

<?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>dam</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="cuserrnd.html" title="cuserrnd" />
    <link rel="next" href="date.html" title="date" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">dam</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="cuserrnd.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="date.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="dam">
      <a id="dam"></a>
      <div class="titlepage"></div>
      <a id="IndexDam" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">dam</span>
        </h2>
        <p>dam — 
      A dynamic compressor/expander.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp17480976"></a>
        <h2>Description</h2>
        <p>
      This opcode dynamically modifies a gain value applied to the input sound <span class="emphasis"><em>ain</em></span> by comparing its power level to a given threshold level. The signal will be compressed/expanded with different factors regarding that it is over or under the threshold.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp17481864"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>dam</strong></span> asig, kthreshold, icomp1, icomp2, irtime, iftime</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp17556440"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>icomp1</em></span> -- compression ratio for upper zone.
    </p>
        <p>
      <span class="emphasis"><em>icomp2</em></span> -- compression ratio for lower zone
    </p>
        <p>
      <span class="emphasis"><em>irtime</em></span> -- gain rise time in seconds. Time over which the gain factor is allowed to raise of one unit.
    </p>
        <p>
      <span class="emphasis"><em>iftime</em></span> -- gain fall time in seconds. Time over which the gain factor is allowed to decrease of one unit.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp17559120"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>asig</em></span> -- input signal to be modified
    </p>
        <p>
      <span class="emphasis"><em>kthreshold</em></span> -- level of input signal which acts as the threshold. Can be changed at k-time (e.g. for ducking)
    </p>
        <p>
      Note on the compression factors: A compression ratio of one leaves the sound unchanged. Setting the ratio to a value smaller than one will compress the signal (reduce its volume) while setting the ratio to a value greater than one will expand the signal (augment its volume).
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp17561440"></a>
        <h2>Examples</h2>
        <p>
      Because the results of the <span class="emphasis"><em>dam</em></span> opcode can be subtle, I recommend looking at them in a graphical audio editor program like <span class="emphasis"><em>audacity</em></span>. <span class="emphasis"><em>audacity</em></span> is available for Linux, Windows, and the MacOS and may be downloaded from <a class="ulink" href="http://audacity.sourceforge.net/" target="_top"><em class="citetitle">http://audacity.sourceforge.net</em></a>.
    </p>
        <p>
      Here is an example of the dam opcode. It uses the file <a class="ulink" href="examples/dam.csd" target="_top"><em class="citetitle">dam.csd</em></a>, and <a class="ulink" href="examples/beats.wav" target="_top"><em class="citetitle">beats.wav</em></a>.
      </p>
        <div class="example">
          <a id="idp17564368"></a>
          <p class="title">
            <strong>Example 149. An example of the dam opcode compressing an audio signal.</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">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</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 dam.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</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">;normal audio</span>

asig <span class="opc">diskin2</span> "beats.wav", 1, 0, 1
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>


<span class="oblock">instr</span> 2	<span class="comment">; compressed audio</span>

kthreshold <span class="op">=</span> 0.2
icomp1 <span class="op">=</span> 0.8
icomp2 <span class="op">=</span> 0.2
irtime <span class="op">=</span> 0.01
iftime <span class="op">=</span> 0.5
asig <span class="opc">diskin2</span> "beats.wav", 1, 0, 1
asig <span class="opc">dam</span> asig, kthreshold, icomp1, icomp2, irtime, iftime
    <span class="opc">outs</span> asig, asig
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 2
<span class="stamnt">i</span> 2 2.5 8.5

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />

      This example compresses the audio file <span class="quote">“<span class="quote">beats.wav</span>”</span>. You should hear a drum pattern repeat twice. The second time, the sound should be quieter (compressed) than the first. 
    </p>
        <p>
      Here is another example of the dam opcode. It uses the file <a class="ulink" href="examples/dam_expanded.csd" target="_top"><em class="citetitle">dam_expanded.csd</em></a>, and <a class="ulink" href="examples/beats.wav" target="_top"><em class="citetitle">beats.wav</em></a>.

      </p>
        <div class="example">
          <a id="idp17568144"></a>
          <p class="title">
            <strong>Example 150. An example of the dam opcode expanding an audio signal.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</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 dam_expanded.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</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	

asig <span class="opc">diskin2</span> "beats.wav", 1, 0, 1
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>

<span class="oblock">instr</span> 2	<span class="comment">;expanded audio</span>

kthreshold <span class="op">=</span> .5
icomp1 <span class="op">=</span> 2
icomp2 <span class="op">=</span> 3
irtime <span class="op">=</span> 0.01
iftime <span class="op">=</span> 0.1

asig <span class="opc">diskin2</span> "beats.wav", 1, 0, 1
asig <span class="opc">dam</span> asig, kthreshold, icomp1, icomp2, irtime, iftime
     <span class="opc">outs</span> asig<span class="op">*</span>.2, asig<span class="op">*</span>.2	<span class="comment">;adjust volume of expanded beat</span>

<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 2
<span class="stamnt">i</span> 2 2.5 6.5

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />

      This example expands the audio file <span class="quote">“<span class="quote">beats.wav</span>”</span>. You should hear a drum pattern repeat twice. The second time, the sound should be louder (expanded) than the first. To prevent distortion the volume of the signal has been lowered.
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp17569856"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="compress.html" title="compress"><em class="citetitle">compress</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp17570912"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Marc Resibois</td>
          </tr>
          <tr>
            <td>Belgium</td>
          </tr>
          <tr>
            <td>1997</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 3.47</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="cuserrnd.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="date.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">cuserrnd </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> date</td>
        </tr>
      </table>
    </div>
  </body>
</html>