| 1 | |
| 2 | <refentry id="pdclip"> |
| 3 | <indexterm id="IndexPdclip"><primary>pdclip</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Modifiers:Waveshaping</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>pdclip</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>pdclip</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Performs linear clipping on an audio signal or a phasor. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | The <emphasis>pdclip</emphasis> opcode allows a percentage of the input range of a signal to be clipped to fullscale. It is similar to simply multiplying the signal and limiting the range of the result, but <emphasis>pdclip</emphasis> allows you to think about how much of the signal range is being distorted instead of the scalar factor and has a offset parameter for assymetric clipping of the signal range. <emphasis>pdclip</emphasis> is also useful for remapping phasors for phase distortion synthesis. |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | |
| 26 | <refsect1> |
| 27 | <title>Syntax</title> |
| 28 | <synopsis>aout <command>pdclip</command> ain, kWidth, kCenter [, ibipolar [, ifullscale]]</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>ibipolar</emphasis> -- an optional parameter specifying either unipolar (0) or bipolar (1) mode. Defaults to unipolar mode. |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>ifullscale</emphasis> -- an optional parameter specifying the range of input and output values. The maximum will be <emphasis>ifullscale</emphasis>. The minimum depends on the mode of operation: zero for unipolar or -<emphasis>ifullscale</emphasis> for bipolar. Defaults to 1.0 -- you should set this parameter to the maximum expected input value. |
| 39 | </para> |
| 40 | </refsect1> |
| 41 | |
| 42 | <refsect1> |
| 43 | <title>Performance</title> |
| 44 | <para> |
| 45 | <emphasis>ain</emphasis> -- the input signal to be clipped. |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | <emphasis>aout</emphasis> -- the output signal. |
| 50 | </para> |
| 51 | |
| 52 | <para> |
| 53 | <emphasis>kWidth</emphasis> -- the percentage of the signal range that is clipped (must be between 0 and 1). |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | <emphasis>kCenter</emphasis> -- an offset for shifting the unclipped window of the signal higher or lower in the range (essentially a DC offset). Values should be in the range [-1, 1] with a value of zero representing no shift (regardless of whether bipolar or unipolar mode is used). |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | The <emphasis>pdclip</emphasis> opcode performs linear clipping on the input signal ain. <emphasis>kWidth</emphasis> specifies the percentage of the signal range that is clipped. The rest of the input range is mapped linearly from zero to ifullscale in unipolar mode and from -ifullscale to ifullscale in bipolar mode. When <emphasis>kCenter</emphasis> is zero, equal amounts of the top and bottom of the signal range are clipped. A negative value shifts the unclipped range more towards the bottom of the input range and a positive value shifts it more towards the top. ibipolar should be 1 for bipolar operation and 0 for unipolar mode. The default is unipolar mode (ibipolar = 0). ifullscale sets the maximum amplitude of the input and output signals (defaults to 1.0). |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | This amounts to waveshaping the input with the following transfer function (normalized to ifullscale=1.0 in bipolar mode): |
| 66 | </para> |
| 67 | |
| 68 | <para> |
| 69 | <literallayout> |
| 70 | 1| _______ x-axis is input range, y-axis is output |
| 71 | | / |
| 72 | | / width of clipped region is 2*kWidth |
| 73 | -1 |/ 1 width of unclipped region is 2*(1 - kWidth) |
| 74 | -------------------- kCenter shifts the unclipped region |
| 75 | /| left or right (up to kWidth) |
| 76 | / | |
| 77 | / | |
| 78 | ------ |-1 |
| 79 | </literallayout> |
| 80 | </para> |
| 81 | |
| 82 | <para> |
| 83 | Bipolar mode can be used for direct, linear distortion of an audio signal. Alternatively, unipolar mode is useful for modifying the output of a phasor before it is used to index a function table, effectively making this a phase distortion technique. |
| 84 | </para> |
| 85 | </refsect1> |
| 86 | |
| 87 | <refsect1> |
| 88 | <title>Examples</title> |
| 89 | <para> |
| 90 | Here is an example of the pdclip opcode. It uses the file <ulink url="examples/pdclip.csd"><citetitle>pdclip.csd</citetitle></ulink>. |
| 91 | <example> |
| 92 | <title>Example of the pdclip opcode.</title> |
| 93 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 94 | <xi:include href="examples-xml/pdclip.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 95 | </example> |
| 96 | </para> |
| 97 | </refsect1> |
| 98 | |
| 99 | <refsect1> |
| 100 | <title>See also</title> |
| 101 | <para><link linkend="SigmodWavshape"><citetitle>Phase Distortion</citetitle></link></para> |
| 102 | </refsect1> |
| 103 | |
| 104 | <refsect1> |
| 105 | <title>Credits</title> |
| 106 | <para> |
| 107 | <simplelist> |
| 108 | <member>Author: &nameanthony;</member> |
| 109 | <member>January 2008</member> |
| 110 | </simplelist> |
| 111 | </para> |
| 112 | |
| 113 | <para>New in Csound version 5.08</para> |
| 114 | </refsect1> |
| 115 | </refentry> |