Debian Codegraph @

opcodes/clip.xml

raw symbols SCIP
1
2 <refentry id="clip">
3 <indexterm id="IndexClip"><primary>clip</primary></indexterm>
4 <refentryinfo><title>Signal Modifiers:Amplitude Modifiers</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>clip</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>clip</refname>
11 <refpurpose>
12 Clips a signal to a predefined limit.
13 </refpurpose>
14 </refnamediv>
15
16 <refsect1>
17 <title>Description</title>
18 <para>
19 Clips an a-rate signal to a predefined limit, in a <quote>soft</quote> manner, using one of three methods.
20 </para>
21 </refsect1>
22
23 <refsect1>
24 <title>Syntax</title>
25 <synopsis>ares <command>clip</command> asig, imeth, ilimit [, iarg]</synopsis>
26 </refsect1>
27
28 <refsect1>
29 <title>Initialization</title>
30 <para>
31 <emphasis>imeth</emphasis> -- selects the clipping method. The default is 0. The methods are:
32 <itemizedlist>
33 <listitem>
34 <para>0 = Bram de Jong method (default)</para>
35 </listitem>
36
37 <listitem>
38 <para>1 = sine clipping</para>
39 </listitem>
40
41 <listitem>
42 <para>2 = tanh clipping</para>
43 </listitem>
44 </itemizedlist>
45 </para>
46
47 <para>
48 <emphasis>ilimit</emphasis> -- limiting value
49 </para>
50
51 <para>
52 <emphasis>iarg</emphasis> (optional, default=0.5) -- when <emphasis>imeth</emphasis> = 0, indicates the point at which clipping starts, in the range 0 - 1. Not used when <emphasis>imeth</emphasis> = 1 or <emphasis>imeth</emphasis> = 2. Default is 0.5.
53 </para>
54 </refsect1>
55
56 <refsect1>
57 <title>Performance</title>
58 <para>
59 <emphasis>asig</emphasis> -- a-rate input signal
60 </para>
61
62 <para>
63 The Bram de Jong method (<emphasis>imeth</emphasis> = 0) applies the algorithm (denoting <emphasis>ilimit</emphasis> as <emphasis>limit</emphasis> and <emphasis>iarg</emphasis> as <emphasis>a</emphasis>):
64 </para>
65
66 <para>
67 <informalexample>
68 <programlisting>
69 |<emphasis>x</emphasis>| &gt;= 0 and |<emphasis>x</emphasis>| &lt;= (<emphasis>limit*a</emphasis>): f(<emphasis>x</emphasis>) = f(<emphasis>x</emphasis>)
70 |<emphasis>x</emphasis>| &gt; (<emphasis>limit*a</emphasis>) and |<emphasis>x</emphasis>| &lt;= <emphasis>limit</emphasis>: f(<emphasis>x</emphasis>) = sign(<emphasis>x</emphasis>) * (<emphasis>limit*a</emphasis>+(<emphasis>x-limit*a</emphasis>)/(1+((<emphasis>x-limit*a</emphasis>)/(<emphasis>limit</emphasis>*(1-<emphasis>a</emphasis>)))<superscript>2</superscript>))
71 |<emphasis>x</emphasis>| &gt; <emphasis>limit</emphasis>: f(<emphasis>x</emphasis>) = sign(<emphasis>x</emphasis>) * (<emphasis>limit</emphasis>*(<emphasis>1+a</emphasis>))/2</programlisting>
72 </informalexample>
73 </para>
74
75 <!--<para>
76 This method requires that <emphasis>asig</emphasis> be normalized to 1.
77 </para>-->
78
79 <para>
80 The second method (<emphasis>imeth</emphasis> = 1) is the sine clip:
81 </para>
82
83 <para>
84 <informalexample>
85 <programlisting>
86 |<emphasis>x</emphasis>| &lt; <emphasis>limit</emphasis>: f(<emphasis>x</emphasis>) = <emphasis>limit</emphasis> * sin(&pi;*<emphasis>x</emphasis>/(2*<emphasis>limit</emphasis>)), |<emphasis>x</emphasis>| &gt;= <emphasis>limit</emphasis>: f(<emphasis>x</emphasis>) = <emphasis>limit</emphasis> * sign(<emphasis>x</emphasis>)</programlisting>
87 </informalexample>
88 </para>
89
90 <para>
91 The third method (<emphasis>imeth = 2</emphasis>) is the tanh clip:
92 </para>
93
94 <para>
95 <informalexample>
96 <programlisting>
97 |<emphasis>x</emphasis>| &lt; <emphasis>limit</emphasis>: f(<emphasis>x</emphasis>) = <emphasis>limit</emphasis> * tanh(<emphasis>x/limit</emphasis>)/tanh(1), |<emphasis>x</emphasis>| &gt;= <emphasis>limit</emphasis>: f(<emphasis>x</emphasis>) = <emphasis>limit</emphasis> * sign(<emphasis>x</emphasis>)</programlisting>
98 </informalexample>
99 </para>
100
101 <note>
102 <title>Note</title>
103 <para>
104 Method 1 appears to be non-functional at release of Csound version 4.07.
105 </para>
106 </note>
107 </refsect1>
108
109 <refsect1>
110 <title>Examples</title>
111 <para>
112 Here is an example of the clip opcode. It uses the file <ulink url="examples/clip.csd"><citetitle>clip.csd</citetitle></ulink>.
113
114 <example>
115 <title>Example of the clip opcode.</title>
116 <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>
117 <xi:include href="examples-xml/clip.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
118 </example>
119 </para>
120 </refsect1>
121
122 <refsect1>
123 <title>See also</title>
124 <para><link linkend="SigProcAmpMod"><citetitle>Amplitude Modifiers and Dynamic processing</citetitle></link></para>
125 <para><link linkend="SigmodWavshape"><citetitle>Waveshaping</citetitle></link></para>
126 </refsect1>
127
128 <refsect1>
129 <title>Credits</title>
130 <para>
131 <simplelist>
132 <member>Author: &namejohn;</member>
133 <member>University of Bath, Codemist Ltd.</member>
134 <member>Bath, UK</member>
135 <member>August, 2000</member>
136 </simplelist>
137 </para>
138
139 <para>New in Csound version 4.07</para>
140 <para>September 2009: Thanks to a note from Paolo Dell'Osso, corrected the formula.</para>
141 </refsect1>
142 </refentry>