| 1 | |
| 2 | <refentry id="pconvolve"> |
| 3 | <indexterm id="IndexPconvolve"><primary>pconvolve</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Modifiers:Convolution and Morphing</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>pconvolve</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>convolve</refname> |
| 11 | <refpurpose> |
| 12 | Convolution based on a uniformly partitioned overlap-save algorithm |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Convolution based on a uniformly partitioned overlap-save algorithm. Compared to the <link linkend="convolve"><citetitle>convolve</citetitle></link> opcode, <emphasis>pconvolve</emphasis> has these benefits: |
| 20 | </para> |
| 21 | |
| 22 | <itemizedlist> |
| 23 | |
| 24 | <listitem> |
| 25 | <para>small delay</para> |
| 26 | </listitem> |
| 27 | |
| 28 | <listitem> |
| 29 | <para>possible to run in real-time for shorter impulse files</para> |
| 30 | </listitem> |
| 31 | |
| 32 | <listitem> |
| 33 | <para>no pre-process analysis pass</para> |
| 34 | </listitem> |
| 35 | |
| 36 | <listitem> |
| 37 | <para>can often render faster than <emphasis>convolve</emphasis></para> |
| 38 | </listitem> |
| 39 | |
| 40 | </itemizedlist> |
| 41 | </refsect1> |
| 42 | |
| 43 | <refsect1> |
| 44 | <title>Syntax</title> |
| 45 | <synopsis>ar1 [, ar2] [, ar3] [, ar4] <command>pconvolve</command> ain, ifilcod [, ipartitionsize, ichannel]</synopsis> |
| 46 | </refsect1> |
| 47 | |
| 48 | <refsect1> |
| 49 | <title>Initialization</title> |
| 50 | <para> |
| 51 | <emphasis>ifilcod</emphasis> |
| 52 | -- integer or character-string denoting an impulse response soundfile. Multichannel files are supported, the file must have the same sample-rate as the orc. [Note: <emphasis>cvanal</emphasis> files cannot be used!] Keep in mind that longer files require more calculation time [and probably larger partition sizes and more latency]. At current processor speeds, files longer than a few seconds may not render in real-time. |
| 53 | </para> |
| 54 | |
| 55 | <para> |
| 56 | <emphasis>ipartitionsize</emphasis> |
| 57 | (optional, defaults to the output buffersize [-b]) -- the size in samples of each partition of the impulse file. This is the parameter that needs tweaking for best performance depending on the impulse file size. Generally, a small size means smaller latency but more computation time. If you specify a value that is not a power-of-2 the opcode will find the next power-of-2 greater and use that as the actual partition size. |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | <emphasis>ichannel</emphasis> |
| 62 | (optional) -- which channel to use from the impulse response data |
| 63 | file. |
| 64 | </para> |
| 65 | |
| 66 | </refsect1> |
| 67 | |
| 68 | <refsect1> |
| 69 | <title>Performance</title> |
| 70 | <para> |
| 71 | <emphasis>ain</emphasis> -- input audio signal. |
| 72 | </para> |
| 73 | |
| 74 | <para> |
| 75 | The overall latency of the opcode can be calculated as such [assuming <emphasis>ipartitionsize</emphasis> is a power of 2] |
| 76 | </para> |
| 77 | |
| 78 | <programlisting> |
| 79 | ilatency = (ksmps < ipartitionsize ? ipartitionsize + ksmps : ipartitionsize)/sr</programlisting> |
| 80 | </refsect1> |
| 81 | |
| 82 | <refsect1> |
| 83 | <title>Examples</title> |
| 84 | <para> |
| 85 | Instrument 1 shows an example of real-time convolution. |
| 86 | </para> |
| 87 | |
| 88 | <para> |
| 89 | Instrument 2 shows how to do file-based convolution with a 'look ahead' method to remove all delay. |
| 90 | </para> |
| 91 | |
| 92 | <note> |
| 93 | <title>NOTE</title> |
| 94 | <para> |
| 95 | You can download impulse response files from noisevault.com |
| 96 | or replace the filenames with your own impulse files. |
| 97 | </para> |
| 98 | </note> |
| 99 | <para> |
| 100 | Here is an example of the pconvolve opcode. It uses the file <ulink url="examples/pconvolve.csd"><citetitle>pconvolve.csd</citetitle></ulink>. |
| 101 | <example> |
| 102 | <title>Example of the pconvolve opcode.</title> |
| 103 | <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> |
| 104 | <xi:include href="examples-xml/pconvolve.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 105 | </example> |
| 106 | </para> |
| 107 | </refsect1> |
| 108 | |
| 109 | <refsect1> |
| 110 | <title>See also</title> |
| 111 | <para><link linkend="SigProcConmorph"><citetitle>Convolution and Morphing</citetitle></link></para> |
| 112 | </refsect1> |
| 113 | |
| 114 | <refsect1> |
| 115 | <title>Credits</title> |
| 116 | <para> |
| 117 | <simplelist> |
| 118 | <member>Author: Matt Ingalls</member> |
| 119 | <member>2004</member> |
| 120 | </simplelist> |
| 121 | </para> |
| 122 | </refsect1> |
| 123 | </refentry> |