| 1 | |
| 2 | <refentry id="zfilter2"> |
| 3 | <indexterm id="IndexZfilter2"><primary>zfilter2</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Modifiers:Specialized Filters</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>zfilter2</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>zfilter2</refname> |
| 11 | <refpurpose> |
| 12 | Performs filtering using a transposed form-II digital filter lattice with radial pole-shearing and angular pole-warping. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | General purpose custom filter with time-varying pole control. The filter coefficients implement the following difference equation: |
| 20 | <literallayout> |
| 21 | (1)*y(n) = b0*x[n] + b1*x[n-1] +...+ bM*x[n-M] - a1*y[n-1] -...- aN*y[n-N] |
| 22 | </literallayout> |
| 23 | </para> |
| 24 | |
| 25 | <para> |
| 26 | the system function for which is represented by: |
| 27 | <literallayout> |
| 28 | B(Z) b0 + b1*Z<superscript>-1</superscript> + ... + bM*Z<superscript>-M</superscript> |
| 29 | H(Z) = ---- = -------------------------- |
| 30 | A(Z) 1 + a1*Z<superscript>-1</superscript> + ... + aN*Z<superscript>-N</superscript> |
| 31 | </literallayout> |
| 32 | </para> |
| 33 | </refsect1> |
| 34 | |
| 35 | <refsect1> |
| 36 | <title>Syntax</title> |
| 37 | <synopsis>ares <command>zfilter2</command> asig, kdamp, kfreq, iM, iN, ib0, ib1, ..., ibM, \ |
| 38 | ia1,ia2, ..., iaN</synopsis> |
| 39 | </refsect1> |
| 40 | |
| 41 | <refsect1> |
| 42 | <title>Initialization</title> |
| 43 | <para> |
| 44 | At initialization the number of zeros and poles of the filter are specified along with the corresponding zero and pole coefficients. The coefficients must be obtained by an external filter-design application such as Matlab or Octave (GPL) and specified directly or loaded into a table via <link linkend="GEN01"><citetitle>GEN01</citetitle></link>. With <emphasis>zfilter2</emphasis>, the roots of the characteristic polynomials are solved at initialization so that the pole-control operations can be implemented efficiently. |
| 45 | </para> |
| 46 | </refsect1> |
| 47 | |
| 48 | <refsect1> |
| 49 | <title>Performance</title> |
| 50 | <para> |
| 51 | The <link linkend="filter2"><citetitle>filter2</citetitle></link> opcodes perform filtering using a transposed form-II digital filter lattice with no time-varying control. <emphasis>zfilter2</emphasis> uses the additional operations of radial pole-shearing and angular pole-warping in the Z plane. |
| 52 | </para> |
| 53 | |
| 54 | <para> |
| 55 | Pole shearing increases the magnitude of poles along radial lines in the Z-plane. This has the affect of altering filter ring times. The k-rate variable <emphasis>kdamp</emphasis> is the damping parameter. Positive values (0.01 to 0.99) increase the ring-time of the filter (hi-Q), negative values (-0.01 to -0.99) decrease the ring-time of the filter, (lo-Q). |
| 56 | </para> |
| 57 | |
| 58 | <para> |
| 59 | Pole warping changes the frequency of poles by moving them along angular paths in the Z plane. This operation leaves the shape of the magnitude response unchanged but alters the frequencies by a constant factor (preserving 0 and p). The k-rate variable <emphasis>kfreq</emphasis> determines the frequency warp factor. Positive values (0.01 to 0.99) increase frequencies toward p and negative values (-0.01 to -0.99) decrease frequencies toward 0. |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | Since <emphasis>filter2</emphasis> implements generalized recursive filters, it can be used to specify a large range of general DSP algorithms. For example, a digital waveguide can be implemented for musical instrument modeling using a pair of <link linkend="delayr"><citetitle>delayr</citetitle></link> and <link linkend="delayw"><citetitle>delayw</citetitle></link> opcodes in conjunction with the <emphasis>filter2</emphasis> opcode. |
| 64 | </para> |
| 65 | </refsect1> |
| 66 | |
| 67 | <refsect1> |
| 68 | <title>Examples</title> |
| 69 | <para> |
| 70 | A controllable second-order IIR filter operating on an a-rate signal: |
| 71 | <informalexample> |
| 72 | <programlisting> |
| 73 | a1 <emphasis role="opc">zfilter2</emphasis> asig, kdamp, kfreq, 1, 2, 1, ia1, ia2 <emphasis role="comment">;; controllable a-rate IIR filter</emphasis></programlisting> |
| 74 | </informalexample> |
| 75 | </para> |
| 76 | <para> |
| 77 | Here is an example of the zfilter2 opcode. It uses the files <ulink url="examples/zfilter2.csd"><citetitle>zfilter2.csd</citetitle></ulink>. |
| 78 | <example> |
| 79 | <title>Example of the zfilter2 opcode.</title> |
| 80 | <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> |
| 81 | <xi:include href="examples-xml/zfilter2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 82 | </example> |
| 83 | </para> |
| 84 | </refsect1> |
| 85 | |
| 86 | <refsect1> |
| 87 | <title>See also</title> |
| 88 | <para><link linkend="SigmodSpeciali"><citetitle>Specialized Filters: Other filters</citetitle></link></para> |
| 89 | </refsect1> |
| 90 | |
| 91 | <refsect1> |
| 92 | <title>Credits</title> |
| 93 | <para> |
| 94 | <simplelist> |
| 95 | <member>Author: Michael A. Casey</member> |
| 96 | <member>M.I.T.</member> |
| 97 | <member>Cambridge, Mass.</member> |
| 98 | <member>1997</member> |
| 99 | </simplelist> |
| 100 | </para> |
| 101 | <para>New in Version 3.47</para> |
| 102 | </refsect1> |
| 103 | </refentry> |