Sophie

Sophie

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

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>pdhalfy</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="pdhalf.html" title="pdhalf" />
    <link rel="next" href="peak.html" title="peak" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">pdhalfy</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="pdhalf.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="peak.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="pdhalfy">
      <a id="pdhalfy"></a>
      <div class="titlepage"></div>
      <a id="IndexPdhalfy" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">pdhalfy</span>
        </h2>
        <p>pdhalfy — 
      Distorts a phasor for reading two unequal portions of a table in equal periods.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp35942800"></a>
        <h2>Description</h2>
        <p>
      The <span class="emphasis"><em>pdhalfy</em></span> opcode is a variation on the phase distortion synthesis method of the <a class="link" href="pdhalf.html" title="pdhalf"><em class="citetitle">pdhalf</em></a> opcode.  It is useful for distorting a phasor in order to read two unequal portions of a table in the same number of samples.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp35946504"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">aout <span class="command"><strong>pdhalfy</strong></span> ain, kShapeAmount [, ibipolar [, ifullscale]]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp35947632"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ibipolar</em></span> -- an optional parameter specifying either unipolar (0) or bipolar (1) mode.  Defaults to unipolar mode.
    </p>
        <p>
      <span class="emphasis"><em>ifullscale</em></span> -- an optional parameter specifying the range of input and output values. The maximum will be <span class="emphasis"><em>ifullscale</em></span>. The minimum depends on the mode of operation: zero for unipolar or -<span class="emphasis"><em>ifullscale</em></span> for bipolar.  Defaults to 1.0 -- you should set this parameter to the maximum expected input value.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp36002328"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ain</em></span> --  the input signal to be distorted.
    </p>
        <p>
      <span class="emphasis"><em>aout</em></span> --  the output signal.
    </p>
        <p>
      <span class="emphasis"><em>kShapeAmount</em></span> --  the amount of distortion applied to the input.  Must be between negative one and one (-1 to 1). An amount of zero means no distortion.
    </p>
        <p>
      </p>
        <div class="mediaobject">
          <img src="images/pdhalfy.png" alt="Transfer function created by pdhalfy and a negative kShapeAmount." />
          <div class="caption">
            <p>Transfer function created by pdhalfy and a negative kShapeAmount.</p>
          </div>
        </div>
        <p>

      The <span class="emphasis"><em>pdhalfy</em></span> opcode calculates a transfer function that is composed of two linear segments (see the graph).  These segments meet at a "pivot point" which always lies on the same vertical axis.  (In unipolar mode, the axis is x = 0.5, and for bipolar mode it is the y axis).  So, <span class="emphasis"><em>pdhalfy</em></span> is a variation of the <a class="link" href="pdhalf.html" title="pdhalf"><em class="citetitle">pdhalf</em></a> opcode that places the pivot point of the phase distortion pattern on a vertical axis instead of a horizontal axis.
    </p>
        <p>
      The <span class="emphasis"><em>kShapeAmount</em></span> parameter specifies where on the vertical axis this point falls.  When <span class="emphasis"><em>kShapeAmount</em></span> is zero, the pivot point is in the middle of the output range, forming a straight line for the transfer function and thus causing no change in the input signal.  As <span class="emphasis"><em>kShapeAmount</em></span> changes from zero (0) to negative one (-1), the pivot point downward towards the bottom of the graph.  As it changes from zero (0) to positive one (1), the pivot point moves upward, producing an inverted pattern.
    </p>
        <p>
      If the input to <span class="emphasis"><em>pdhalfy</em></span> is a phasor and the output is used to index a table, the use of <span class="emphasis"><em>pdhalfy</em></span> will divide the table into two segments of different sizes with each segment being mapped to half of the oscillator period.  Values for <span class="emphasis"><em>kShapeAmount</em></span> that are less than zero will cause less than half of the table to be read in the first half of the period of oscillation.  The rest of the table will be read in the second half of the period.  The reverse is true for values of <span class="emphasis"><em>kShapeAmount</em></span> greater than zero. Note that the frequency of the phasor is always unchanged.  Thus, this method of phase distortion can only produce higher partials in a harmonic series.  It cannot produce inharmonic sidebands in the way that frequency modulation does. <span class="emphasis"><em>pdhalfy</em></span> tends to have a milder quality to its distortion than <span class="emphasis"><em>pdhalf</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>pdhalfy</em></span> can work in either unipolar or bipolar modes. Unipolar mode is appropriate for signals like phasors that range between zero and some maximum value (selectable with <span class="emphasis"><em>ifullscale</em></span>). Bipolar mode is appropriate for signals that range above and below zero by roughly equal amounts such as most audio signals.  Applying <span class="emphasis"><em>pdhalfy</em></span> directly to an audio signal in this way results in a crude but adjustable sort of waveshaping/distortion.
    </p>
        <p>
      A typical example of the use of pdhalfy is

      </p>
        <div class="informalexample">
          <pre class="programlisting">
    aphase    <span class="opc">phasor</span>     ifreq
    apd       <span class="opc">pdhalfy</span>    aphase, kamount
    aout      <span class="opc">tablei</span>     apd, 1, 1</pre>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp36014128"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the pdhalfy opcode. It uses the file <a class="ulink" href="examples/pdhalfy.csd" target="_top"><em class="citetitle">pdhalfy.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp36015104"></a>
          <p class="title">
            <strong>Example 581. Example of the pdhalfy 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">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o pdhalfy.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> 5

    idur        <span class="op">=</span> p3
    iamp        <span class="op">=</span> p4
    ifreq       <span class="op">=</span> p5
    iamtinit    <span class="op">=</span> p6      <span class="comment">; initial amount of phase distortion</span>
    iatt        <span class="op">=</span> p7      <span class="comment">; attack time</span>
    isuslvl     <span class="op">=</span> p8      <span class="comment">; sustain amplitude</span>
    idistdec    <span class="op">=</span> p9      <span class="comment">; time for distortion amount to reach zero</span>
    itable      <span class="op">=</span> p10
    
    idec        <span class="op">=</span>  idistdec <span class="op">-</span> iatt
    irel        <span class="op">=</span>  .05
    isus        <span class="op">=</span>  idur <span class="op">-</span> (idistdec <span class="op">+</span> irel)
    
    aenv        <span class="opc">linseg</span>      0, iatt, 1.0, idec, isuslvl, isus, isuslvl, irel, 0, 0, 0
    kamount     <span class="opc">linseg</span>      <span class="op">-</span>iamtinit, idistdec, 0.0, idur<span class="op">-</span>idistdec, 0.0
    aosc        <span class="opc">phasor</span>      ifreq
    apd         <span class="opc">pdhalfy</span>     aosc, kamount
    aout        <span class="opc">tablei</span>      apd, itable, 1
    
                <span class="opc">outs</span>        aenv<span class="op">*</span>aout<span class="op">*</span>iamp, aenv<span class="op">*</span>aout<span class="op">*</span>iamp       
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1 0 16385 10 1                 <span class="comment">; sine</span>
<span class="stamnt">f</span>3 0 16385  9 1 1 270           <span class="comment">; inverted cosine</span>

<span class="comment">; descending "just blues" scale</span>

<span class="comment">; pdhalfy with cosine table</span>
<span class="stamnt">t</span> 0 100
<span class="stamnt">i</span>5 0 .333 .6    512     1.0   .02  0.5  .12   3
<span class="stamnt">i</span>. + .    .     448     &lt;
<span class="stamnt">i</span>. + .    .     384     &lt;
<span class="stamnt">i</span>. + .    .     358.4   &lt;
<span class="stamnt">i</span>. + .    .     341.33  &lt;
<span class="stamnt">i</span>. + .    .     298.67  &lt;
<span class="stamnt">i</span>. + 2    .     256     0.5
<span class="stamnt">s</span>

<span class="comment">; pdhalfy with sine table</span>
<span class="stamnt">t</span> 0 100
<span class="stamnt">i</span>5 0 .333 .6    512     1.0   .001 0.1  .07   1
<span class="stamnt">i</span>. + .    .     448     &lt;
<span class="stamnt">i</span>. + .    .     384     &lt;
<span class="stamnt">i</span>. + .    .     358.4   &lt;
<span class="stamnt">i</span>. + .    .     341.33  &lt;
<span class="stamnt">i</span>. + .    .     298.67  &lt;
<span class="stamnt">i</span>. + 2    .     256     0.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" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp36017384"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="pdhalf.html" title="pdhalf"><em class="citetitle">pdhalf</em></a>,
      <a class="link" href="pdclip.html" title="pdclip"><em class="citetitle">pdclip</em></a> 
          </p>
        <p> More information about phase distortion on Wikipedia: <a class="ulink" href="http://en.wikipedia.org/wiki/Phase_distortion_synthesis" target="_top"><em class="citetitle">http://en.wikipedia.org/wiki/Phase_distortion_synthesis</em></a></p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp36019576"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Anthony Kozar</td>
          </tr>
          <tr>
            <td>January 2008</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 5.08</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="pdhalf.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="peak.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">pdhalf </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> peak</td>
        </tr>
      </table>
    </div>
  </body>
</html>