Sophie

Sophie

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

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>distort1</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="distort.html" title="distort" />
    <link rel="next" href="divz.html" title="divz" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">distort1</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="distort.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="divz.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="distort1">
      <a id="distort1"></a>
      <div class="titlepage"></div>
      <a id="IndexDistort1" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">distort1</span>
        </h2>
        <p>distort1 — 
      Modified hyperbolic tangent distortion.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp18498136"></a>
        <h2>Description</h2>
        <p>
      Implementation of modified hyperbolic tangent distortion. <span class="emphasis"><em>distort1</em></span> can be used to generate wave shaping distortion based on a modification of the <a class="link" href="tanh.html" title="tanh"><em class="citetitle">tanh</em></a> function.
    </p>
        <p>
      </p>
        <div class="literallayout">
          <p><br />
         exp(asig * (shape1 + pregain)) - exp(asig * (shape2 - pregain))<br />
  aout = ---------------------------------------------------------------<br />
         exp(asig * pregain)            + exp(-asig * pregain)<br />
      </p>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp18509960"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>distort1</strong></span> asig, kpregain, kpostgain, kshape1, kshape2[, imode]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp18511136"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>imode</em></span> (Csound version 5.00 and later only; optional, defaults to 0) -- scales kpregain, kpostgain, kshape1, and kshape2 for use with audio signals in the range -32768 to 32768 (imode=0), -0dbfs to 0dbfs (imode=1), or disables scaling of kpregain and kpostgain and scales kshape1 by kpregain and kshape2 by -kpregain (imode=2).
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp18546016"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>asig</em></span> -- is the input signal.
    </p>
        <p>
      <span class="emphasis"><em>kpregain</em></span> -- determines the amount of gain applied to the signal before waveshaping. A value of 1 gives slight distortion.
    </p>
        <p>
      <span class="emphasis"><em>kpostgain</em></span> -- determines the amount of gain applied to the signal after waveshaping.
    </p>
        <p>
      <span class="emphasis"><em>kshape1</em></span> -- determines the shape of the positive part of the curve. A value of 0 gives a flat clip, small positive values give sloped shaping.
    </p>
        <p>
      <span class="emphasis"><em>kshape2</em></span> -- determines the shape of the negative part of the curve.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp18549368"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the distort1 opcode. It uses the file <a class="ulink" href="examples/distort1.csd" target="_top"><em class="citetitle">distort1.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp18550328"></a>
          <p class="title">
            <strong>Example 183. Example of the distort1 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">&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 distort1.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


gadist <span class="opc">init</span> 0
  
<span class="oblock">instr</span> 1
  iamp <span class="op">=</span> p4
  ifqc <span class="op">=</span> <span class="opc">cpspch</span>(p5)
  asig <span class="opc">pluck</span> iamp, ifqc, ifqc, 0, 1
  gadist <span class="op">=</span> gadist <span class="op">+</span> asig
<span class="oblock">endin</span>
  
<span class="oblock">instr</span> 50
  kpre <span class="opc">init</span> p4
  kpost <span class="opc">init</span> p5
  kshap1 <span class="opc">init</span> p6
  kshap2 <span class="opc">init</span> p7
  aout <span class="opc">distort1</span> gadist, kpre, kpost, kshap1, kshap2, 1

  <span class="opc">outs</span> aout, aout

  gadist <span class="op">=</span> 0
<span class="oblock">endin</span>


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

<span class="comment">;   Sta  Dur  Amp    Pitch</span>
<span class="stamnt">i</span>1  0.0  3.0  0.5  6.00
<span class="stamnt">i</span>1  0.5  2.5  0.5  7.00
<span class="stamnt">i</span>1  1.0  2.0  0.5  7.07
<span class="stamnt">i</span>1  1.5  1.5  0.5  8.00
  
<span class="comment">;   Sta  Dur  PreGain PostGain Shape1 Shape2</span>
<span class="stamnt">i</span>50 0    4      2       .5       0      0
<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="Credits">
        <a id="idp18552640"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Hans Mikelson</td>
          </tr>
          <tr>
            <td>December 1998</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.50</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="distort.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="divz.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">distort </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> divz</td>
        </tr>
      </table>
    </div>
  </body>
</html>