Sophie

Sophie

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

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>compress</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="combinv.html" title="combinv" />
    <link rel="next" href="connect.html" title="connect" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">compress</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="combinv.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="connect.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="compress">
      <a id="compress"></a>
      <div class="titlepage"></div>
      <a id="IndexCompress" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">compress</span>
        </h2>
        <p>compress — 
      Compress, limit, expand, duck or gate an audio signal.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp16273040"></a>
        <h2>Description</h2>
        <p> This unit functions as an audio
    compressor, limiter, expander, or noise gate, using either
    soft-knee or hard-knee mapping, and with dynamically variable
    performance characteristics.  It takes two audio input signals,
    <span class="emphasis"><em>aasig</em></span> and <span class="emphasis"><em>acsig</em></span>, the first of which is modified by a running
    analysis of the second. Both signals can be the same, or the first
    can be modified by a different controlling signal. 
    </p>
        <p>
    <span class="command"><strong>compress</strong></span> first examines the controlling <span class="emphasis"><em>acsig</em></span>
    by performing envelope detection.  This is directed by two control
    values <span class="emphasis"><em>katt</em></span> and <span class="emphasis"><em>krel</em></span>, defining the attack and release time
    constants (in seconds) of the detector.  The detector rides the
    peaks (not the RMS) of the control signal. Typical values are .01
    and .1, the latter usually being similar to <span class="emphasis"><em>ilook</em></span>.
    </p>
        <p>
The running envelope is next converted to decibels, then passed
through a mapping function to determine what compresser action (if
any) should be taken.  The mapping function is defined by four decibel
control values.  These are given as positive values, where 0 db
corresponds to an amplitude of 1, and 90 db corresponds to an
amplitude of 32768. 
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp16327504"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ar <span class="command"><strong>compress</strong></span> aasig, acsig, kthresh, kloknee, khiknee, kratio, katt, krel, ilook</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp16328632"></a>
        <h2>Initialization</h2>
        <p>

    <span class="emphasis"><em>ilook</em></span> -- lookahead time in seconds, by which an
     internal envelope release can sense what is coming.  This induces
     a delay between input and output, but a small amount of lookahead
     improves the performance of the envelope detector.  Typical value
     is .05 seconds, sufficient to sense the peaks of the lowest
     frequency in <span class="emphasis"><em>acsig</em></span>.

    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp16330008"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kthresh</em></span> -- sets the lowest decibel level that will be allowed through.  Normally 0 or less, but if higher the threshold will begin removing low-level signal energy such as background noise.
    </p>
        <p>
      <span class="emphasis"><em>kloknee</em></span>, <span class="emphasis"><em>khiknee</em></span> -- decibel break-points denoting where compression or expansion will begin. These set the boundaries of a soft-knee curve joining the low-amplitude 1:1 line and the higher-amplitude compression ratio line.  Typical values are 48 and 60 db.   If the two breakpoints are equal, a hard-knee (angled) map will result.
    </p>
        <p>
      <span class="emphasis"><em>kratio</em></span> -- ratio of compression when the signal level is above the knee. The value 2 will advance the output just one decibel for every input gain of two;  3 will advance just one in three; 20 just one in twenty, etc. Inverse ratios will cause signal expansion:  .5 gives two for one, .25 four for one, etc.  The value 1 will result in no change.
</p>
        <p>
The actions of compress will depend on the parameter settings given.  A hard-knee compressor-limiter, for instance, is obtained from a near-zero attack time, equal-value break-points, and a very high ratio (say 100).  A noise-gate plus expander is obtained from some positive threshold, and a fractional ratio above the knee.  A voice-activated music compressor (ducker) will result from feeding the music into <span class="emphasis"><em>aasig</em></span> and the speech into <span class="emphasis"><em>acsig</em></span>.  A voice de-esser will result from feeding the voice into both, with the <span class="emphasis"><em>acsig</em></span> version being preceded by a band-pass filter that emphasizes the sibilants. Each application will require some experimentation to find the best parameter settings;  these have been made k-variable to make this practical. 
</p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp16334272"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the compress opcode. It uses the file <a class="ulink" href="examples/compress.csd" target="_top"><em class="citetitle">compress.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp16335256"></a>
          <p class="title">
            <strong>Example 118. Example of the compress opcode.</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  -iadc    <span class="comment">;;;RT audio out and in</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o compress.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="oblock">instr</span> 1	<span class="comment">; uncompressed signal</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 signal.</span>
<span class="comment">; Use the "beats.wav" audio file and a mic</span>
avoice <span class="opc">in</span>
asig   <span class="opc">diskin2</span> "beats.wav", 1, 0, 1

<span class="comment">; duck the audio signal "beats.wav" with your voice.</span>
  kthresh <span class="op">=</span> 0
  kloknee <span class="op">=</span> 40
  khiknee <span class="op">=</span> 60
  kratio  <span class="op">=</span> 3
  katt    <span class="op">=</span> 0.1
  krel    <span class="op">=</span> .5
  ilook   <span class="op">=</span> .02
asig  <span class="opc">compress</span> asig, avoice, kthresh, kloknee, khiknee, kratio, katt, krel, ilook	<span class="comment">; voice-activated compressor</span>
      <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 5

<span class="stamnt">i</span> 2 6 21

<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" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp16336272"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="dam.html" title="dam"><em class="citetitle">dam</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp16337272"></a>
        <h2>Credits</h2>
        <p>Written by Barry L. Vercoe for Extended Csound and released in
    csound5.02.
</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="combinv.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="connect.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">combinv </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> connect</td>
        </tr>
      </table>
    </div>
  </body>
</html>