| 1 | |
| 2 | <refentry id="lpcfilter"> |
| 3 | <indexterm id="IndexLpcfilter"><primary>lpcfilter</primary></indexterm> |
| 4 | <refentryinfo><title>Spectral Processing:LPC</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>lpcfilter</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>lpcfilter</refname> |
| 11 | <refpurpose> |
| 12 | Streaming linear prediction all-pole filter. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | This opcode implements an all-pole filter whose coefficients are |
| 20 | obtained from streaming linear prediction analysis. Two versions |
| 21 | exist, one taking input from an audio signal, and the other from |
| 22 | a function table. |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | |
| 26 | <refsect1> |
| 27 | <title>Syntax</title> |
| 28 | <synopsis>ares <command>lpcfilter</command> asig, asrc, kflg, |
| 29 | kprd, isiz, iord[,iwin] </synopsis> |
| 30 | <synopsis>ares <command>lpcfilter</command> asig, koff, kflg, |
| 31 | ifn, isiz, iord[,iwin] </synopsis> |
| 32 | |
| 33 | </refsect1> |
| 34 | <refsect1> |
| 35 | <title>Initialization</title> |
| 36 | <para> |
| 37 | <emphasis>isiz</emphasis> -- size of lpc input frame in samples. |
| 38 | </para> |
| 39 | |
| 40 | <para> |
| 41 | <emphasis>iord</emphasis> -- linear predictor order. |
| 42 | </para> |
| 43 | |
| 44 | <para> |
| 45 | <emphasis>ifn</emphasis> -- streaming LPC analysis source function table |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | <emphasis>iwin</emphasis> -- window function table number (optional) |
| 50 | </para> |
| 51 | |
| 52 | </refsect1> |
| 53 | |
| 54 | <refsect1> |
| 55 | <title>Performance</title> |
| 56 | <para> |
| 57 | <emphasis>ares</emphasis> -- output |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | <emphasis>asig</emphasis> - audio input |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | <emphasis>asrc</emphasis> -- streaming LPC analysis source signal |
| 66 | </para> |
| 67 | |
| 68 | <para> |
| 69 | <emphasis>kflg</emphasis> -- compute flag, non-zero values |
| 70 | switch on linear prediction analysis replacing filter coefficients, zero switch it off, |
| 71 | keeping current filter coefficients. |
| 72 | </para> |
| 73 | |
| 74 | <para> |
| 75 | <emphasis>kprd</emphasis> -- analysis period in samples, |
| 76 | determining how often new coefficients are computed. |
| 77 | </para> |
| 78 | |
| 79 | <para> |
| 80 | <emphasis>koff</emphasis> -- function table position offset, in |
| 81 | samples, determining the start position of analysis frame. |
| 82 | </para> |
| 83 | </refsect1> |
| 84 | |
| 85 | <refsect1> |
| 86 | <para> |
| 87 | This opcode is part of a suite of streaming linear prediction |
| 88 | opcodes. It analyses an input signal, either as an audio input |
| 89 | or stored in a function table and produces a set of |
| 90 | coefficients for an all-pole filter that models the signal's |
| 91 | spectral envelope. This filter is then applied to an arbitrary |
| 92 | input, producing a cross-synthesis result. |
| 93 | </para> |
| 94 | |
| 95 | <para> |
| 96 | The fundamental analysis parameters are input frame size and |
| 97 | filter order. Longer input frames will produce a more accurate |
| 98 | result in terms of frequency resolution, but will also involve |
| 99 | more computation. This is due to the computation of the |
| 100 | autocorrelation function, which is then used in the coefficient |
| 101 | computation. This part is more efficient and depends only |
| 102 | on the linear prediction order, which is also the number of |
| 103 | coefficients computed. Typical lp orders may range from |
| 104 | about 30 to 100 coefficients, but larger values can also |
| 105 | be used. |
| 106 | </para> |
| 107 | |
| 108 | <para> |
| 109 | If the LPC source signal is derived from an audio input, then |
| 110 | the computation of coefficients is dependent on two parameters, |
| 111 | kflg and kprd. The first is an on/off switch that determines |
| 112 | whether coefficients are replaced by newly-computed ones |
| 113 | or the coefficients are kept fixed to their last value. The |
| 114 | other determines the frequency of analyses, by setting a |
| 115 | time interval (in samples) between new coefficient computation. |
| 116 | This ranges from coefficients being replaced every sample, |
| 117 | to never replaced (if the period is larger than the synthesis duration). |
| 118 | Overlapped analyses will take place if the value of kprd is less |
| 119 | than the input size. Decreasng the spacing of analyses will |
| 120 | also increase computation demands. |
| 121 | </para> |
| 122 | <para> |
| 123 | If the LPC source signal is derived from a function table, |
| 124 | then kflg determines wheter an analysis should be performed |
| 125 | or not (1 or 0). The value of koff is then used as an offset |
| 126 | (in samples) into the function table determining the position |
| 127 | of the analysis frame. For example, if kflg is permanently set |
| 128 | to 1 and koff is set to ksmps, then at every kcycle an |
| 129 | analysis frame will be taken from successive positions in the |
| 130 | function table. Changing koff to fewer samples will produce |
| 131 | a timestretched result and increasing it will time compress. |
| 132 | </para> |
| 133 | <para> |
| 134 | Once the signal is extracted from either an audio input or |
| 135 | function table then it can be optionally windowed if a function |
| 136 | table is provided. While this is optional, it is a recommended |
| 137 | procedure (GEN20 can provide the most common windows). |
| 138 | The signal is then analysed and coefficients replaced. The |
| 139 | all-pole filter is computed as a direct convolution in the |
| 140 | time domain. |
| 141 | </para> |
| 142 | |
| 143 | </refsect1> |
| 144 | |
| 145 | <refsect1> |
| 146 | <title>Examples</title> |
| 147 | <para> |
| 148 | Here is an example of the lpcfilter opcode using an audio input |
| 149 | signal as lpc source. It uses the file <ulink url="examples/lpcfilter.csd"><citetitle>lpcfilter.csd</citetitle></ulink>. |
| 150 | <example> |
| 151 | <title>Example of the lpcfilter opcode.</title> |
| 152 | <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> |
| 153 | <xi:include href="examples-xml/lpcfilter.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 154 | </example> |
| 155 | </para> |
| 156 | <para> |
| 157 | Here is another example of the lpcfilter opcode, now using a |
| 158 | function table as lpc source. It uses the file <ulink url="examples/lpcfilter-2.csd"><citetitle>lpcfilter-2.csd</citetitle></ulink>. |
| 159 | <example> |
| 160 | <title>Another example of the lpcfilter opcode.</title> |
| 161 | <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> |
| 162 | <xi:include href="examples-xml/lpcfilter-2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 163 | </example> |
| 164 | </para> |
| 165 | </refsect1> |
| 166 | |
| 167 | <refsect1> |
| 168 | <title>See also</title> |
| 169 | <para><link linkend="SpectralLpcresyn"><citetitle>Streaming Linear Predictive Coding (SLPC) Resynthesis</citetitle></link></para> |
| 170 | </refsect1> |
| 171 | |
| 172 | </refentry> |