| 1 | |
| 2 | <refentry id="powershape"> |
| 3 | <indexterm id="IndexPowershape"><primary>powershape</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Modifiers:Waveshaping</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>powershape</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>powershape</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Waveshapes a signal by raising it to a variable exponent. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | The <emphasis>powershape</emphasis> opcode raises an input signal to a power with pre- and post-scaling of the signal so that the output will be in a predictable range. It also processes negative inputs in a symmetrical way to positive inputs, calculating a dynamic transfer function that is useful for waveshaping. |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | |
| 26 | <refsect1> |
| 27 | <title>Syntax</title> |
| 28 | <synopsis>aout <command>powershape</command> ain, kShapeAmount [, ifullscale]</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>ifullscale</emphasis> -- optional parameter specifying the range of input values from -<emphasis>ifullscale</emphasis> to <emphasis>ifullscale</emphasis>. Defaults to 1.0 -- you should set this parameter to the maximum expected input value. |
| 35 | </para> |
| 36 | </refsect1> |
| 37 | |
| 38 | <refsect1> |
| 39 | <title>Performance</title> |
| 40 | <para> |
| 41 | <emphasis>ain</emphasis> -- the input signal to be shaped. |
| 42 | </para> |
| 43 | |
| 44 | <para> |
| 45 | <emphasis>aout</emphasis> -- the output signal. |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | <emphasis>kShapeAmount</emphasis> -- the amount of the shaping effect applied to the input; equal to the power that the input signal is raised. |
| 50 | </para> |
| 51 | |
| 52 | <para> |
| 53 | The <emphasis>powershape</emphasis> opcode is very similar to the <emphasis>pow</emphasis> unit generators for calculating the mathematical "power of" operation. However, it introduces a couple of twists that can make it much more useful for waveshaping audio-rate signals. The <emphasis>kShapeAmount</emphasis> parameter is the exponent to which the input signal is raised. |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | To avoid discontinuities, the <emphasis>powershape</emphasis> opcode treats all input values as positive (by taking their absolute value) but preserves their original sign in the output signal. This allows for smooth shaping of any input signal while varying the exponent over any range. (<emphasis>powershape</emphasis> also (hopefully) deals intelligently with discontinuities that could arise when the exponent and input are both zero. Note though that negative exponents will usually cause the signal to exceed the maximum amplitude specified by the ifullscale parameter and should normally be avoided). |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | The other adaptation involves the <emphasis>ifullscale</emphasis> parameter. The input signal is divided by <emphasis>ifullscale</emphasis> before being raised to <emphasis>kShapeAmount</emphasis> and then multiplied by <emphasis>ifullscale</emphasis> before being output. This normalizes the input signal to the interval [-1,1], guaranteeing that the output (before final scaling) will also be within this range for positive shaping amounts and providing a smoothly evolving transfer function while varying the amount of shaping. Values of <emphasis>kShapeAmount</emphasis> between (0,1) will make the signal more "convex" while values greater than 1 will make it more "concave". A value of exactly 1.0 will produce no change in the input signal. |
| 62 | </para> |
| 63 | </refsect1> |
| 64 | |
| 65 | <refsect1> |
| 66 | <title>See Also</title> |
| 67 | <para> |
| 68 | <link linkend="pow"><citetitle>pow</citetitle></link>, |
| 69 | <link linkend="powoftwo"><citetitle>powoftwo</citetitle></link> |
| 70 | </para> |
| 71 | </refsect1> |
| 72 | |
| 73 | <refsect1> |
| 74 | <title>Examples</title> |
| 75 | <para> |
| 76 | Here is an example of the powershape opcode. It uses the file <ulink url="examples/powershape.csd"><citetitle>powershape.csd</citetitle></ulink>. |
| 77 | <example> |
| 78 | <title>Example of the powershape opcode.</title> |
| 79 | <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> |
| 80 | <xi:include href="examples-xml/powershape.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 81 | </example> |
| 82 | </para> |
| 83 | </refsect1> |
| 84 | |
| 85 | <refsect1> |
| 86 | <title>See also</title> |
| 87 | <para><link linkend="SigmodWavshape"><citetitle>Waveshaping</citetitle></link></para> |
| 88 | <para><link linkend="MathMatfunc"><citetitle>Mathematical Functions</citetitle></link></para> |
| 89 | </refsect1> |
| 90 | |
| 91 | <refsect1> |
| 92 | <title>Credits</title> |
| 93 | <para> |
| 94 | <simplelist> |
| 95 | <member>Author: &nameanthony;</member> |
| 96 | <member>January 2008</member> |
| 97 | </simplelist> |
| 98 | </para> |
| 99 | |
| 100 | <para>New in Csound version 5.08</para> |
| 101 | </refsect1> |
| 102 | </refentry> |