1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
6<title>axvpb.pb.biquad</title>
7<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
8<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 6.5.0.0 for Windows">
9<META http-equiv="Content-Style-Type" content="text/css">
10</head>
11
12<body>
13
14<h1 align="left">axvpb.pb.biquad</h1>
15
16<h2>Syntax</h2>
17<dl><dd><pre class="construction">
18#define AX_PB_BIQUAD_OFF        0x0000  // Biquad IIR filter switch
19#define AX_PB_BIQUAD_ON         0x0002
20
21typedef struct _AXPBBIQUAD
22{
23
24    u16     on;   // Filter switch. Valid when <CODE>AX_PB_BIQUAD_ON(2)</CODE>.  Invalid when <CODE>AX_PB_BIQUAD_OFF(0)</CODE>.
25    u16     xn1;  //  History data. Must be initialized to zero.
26    u16     xn2;  // History data. Must be initialized to zero.
27    u16     yn1;  // History data. Must be initialized to zero.
28    u16     yn2;  // History data. Must be initialized to zero.
29    u16     b0;   // Filter coefficient
30    u16     b1;   // Filter coefficient
31    u16     b2;   // Filter coefficient
32    u16     a1;   // Filter coefficient
33    u16     a2;   // Filter coefficient
34
35} AXPBBIQUAD;
36</pre></dd></dl>
37
38<h2>Description</h2>
39<p>With AX, a Biquad filter can be applied to each voice independently. Moreover, the Biquad filter can be used with a conventional LPF filter. The <SPAN class="argument">biquad</SPAN> value controls these Biquad filters.</p>
40
41<p>The <SPAN class="argument">on</SPAN> value is the Biquad filter switch. Biquad filters are enabled when <code>AX_PB_BIQUAD_ON(2)</code> is set to <SPAN class="argument">on</SPAN>; the filters are invalid when <code>AX_PB_BIQUAD_OFF(0)</code> is set.</p>
42
43<p>The <SPAN class="argument">xn1</SPAN>, <SPAN class="argument">xn2</SPAN>, <SPAN class="argument">yn1</SPAN>, and <SPAN class="argument">yn2</SPAN> values are history data used by Biquad filters. These values must be initialized to zero when Biquad filters are enabled. Once Biquad filters become valid, the AX library manages these values. After the data have been initialized, the application must not make any changes to them.</p>
44
45<p>In the diagram below, the <SPAN class="argument">b0</SPAN>, <SPAN class="argument">b1</SPAN>, <SPAN class="argument">b2</SPAN>, <SPAN class="argument">a1</SPAN>, and <SPAN class="argument">a2</SPAN> values are coefficients of the Biquad filter. The application must set the coefficients in these members to correspond to the filter type and cutoff frequency. Note that these values can be changed at any time.</p>
46
47<BLOCKQUOTE><pre><code>
48    y(n) = b0 * x(n) + b1 * x(n-1) + b2 * x(n-2) + a1 * y(n-1) + a2 * y(n-2)
49
50    IN---&gt;[+]--------------&gt;+---&gt;[ x b0 ]--&gt;[+]---&gt;OUT
51           |                |                |
52           |             [ Z^-1 ]            |
53           |                |                |
54           +&lt;---[ x a1 ]&lt;---+---&gt;[ x b1 ]---&gt;+
55           |                |                |
56           |             [ Z^-1 ]            |
57           |                |                |
58           +&lt;---[ x a2 ]&lt;---+---&gt;[ x b2 ]---&gt;+
59
60
61                    b0 + b1(Z^-1) + b2(Z^-2)
62           H(z) = ----------------------------
63                    1  - a1(Z^-1) - a2(Z^-2)
64</code></pre></BLOCKQUOTE>
65
66<p>Each filter coefficient is a 16-bit fixed-point value with a 2-bit integer part and a 14-bit decimal fraction (<code>-2.0 &lt;= coef &lt; 2.0</code>). Using a general-purpose filter design tool, convert the requested filter coefficients to fixed-point values, and set them for <SPAN class="argument">b0</SPAN> - <SPAN class="argument">a2</SPAN>.</p>
67
68<p>For the <code>/build/demos/axdemo/include/lpfdemo.h</code> sample, the following coefficient table has been prepared:</p>
69
70<BLOCKQUOTE><pre><CODE>
71typedef struct
72{
73    u16  b0;
74    u16  b1;
75    u16  b2;
76    u16  a1;
77    u16  a2;
78    char *text;
79
80} __BIQUAD_COEF;
81
82// low-pass
83static __BIQUAD_COEF __biquad_lpf_coefs[] =
84{
85    { 0x36fa, 0x6df4, 0x36fa, 0x8c47, 0xcaca, &quot;16000 Hz&quot;}, // actually 15000 Hz
86    { 0x2bf0, 0x57e0, 0x2bf0, 0xa967, 0xdc70, &quot;12800 Hz&quot;},
87    { 0x2071, 0x40e3, 0x2071, 0xcd87, 0xe904, &quot;10240 Hz&quot;},
88    { 0x173d, 0x2e7b, 0x173d, 0xef3d, 0xee4c, &quot; 8000 Hz&quot;},
89    { 0x110d, 0x221a, 0x110d, 0x0903, 0xeec0, &quot; 6400 Hz&quot;},
90    { 0x0c59, 0x18b3, 0x0c59, 0x1eee, 0xecbf, &quot; 5120 Hz&quot;},
91    { 0x087e, 0x10fc, 0x087e, 0x332c, 0xe8d8, &quot; 4000 Hz&quot;},
92    { 0x05f5, 0x0bea, 0x05f5, 0x423b, 0xe487, &quot; 3200 Hz&quot;},
93    { 0x041f, 0x083d, 0x041f, 0x4e96, 0xdff6, &quot; 2560 Hz&quot;},
94    { 0x02b3, 0x0565, 0x02b3, 0x598e, 0xdb05, &quot; 2000 Hz&quot;},
95    { 0x01d1, 0x03a3, 0x01d1, 0x616d, 0xd6df, &quot; 1600 Hz&quot;},
96    { 0x0137, 0x026e, 0x0137, 0x67b7, 0xd325, &quot; 1280 Hz&quot;},
97    { 0x00c5, 0x018a, 0x00c5, 0x6d2e, 0xcf90, &quot; 1000 Hz&quot;},
98    { 0x0082, 0x0103, 0x0082, 0x710d, 0xccce, &quot;  800 Hz&quot;},
99    { 0x0055, 0x00a9, 0x0055, 0x741f, 0xca7b, &quot;  640 Hz&quot;},
100    { 0x0035, 0x0069, 0x0035, 0x76c7, 0xc85a, &quot;  500 Hz&quot;},
101    { 0x0022, 0x0044, 0x0022, 0x78a9, 0xc6c7, &quot;  400 Hz&quot;},
102    { 0x0016, 0x002c, 0x0016, 0x7a27, 0xc57c, &quot;  320 Hz&quot;},
103    { 0x000e, 0x001d, 0x000e, 0x7b57, 0xc46d, &quot;  256 Hz&quot;},
104    { 0x0009, 0x0012, 0x0009, 0x7c5f, 0xc37c, &quot;  200 Hz&quot;},
105    { 0x0006, 0x000b, 0x0006, 0x7d1b, 0xc2ce, &quot;  160 Hz&quot;},
106    { 0x0004, 0x0007, 0x0004, 0x7db0, 0xc241, &quot;  128 Hz&quot;},
107    { 0x0002, 0x0004, 0x0002, 0x7e32, 0xc1c5, &quot;  100 Hz&quot;},
108    { 0x0001, 0x0003, 0x0001, 0x7e8f, 0xc16b, &quot;   80 Hz&quot;}
109};
110
111// high-pass
112static __BIQUAD_COEF __biquad_hpf_coefs[] =
113{
114    { 0x3bf9, 0x880e, 0x3bf9, 0x7f0d, 0xc0f1, &quot;   80 Hz&quot;},
115    { 0x3bdd, 0x8846, 0x3bdd, 0x7ed0, 0xc12c, &quot;  100 Hz&quot;},
116    { 0x3bb5, 0x8896, 0x3bb5, 0x7e7b, 0xc17f, &quot;  128 Hz&quot;},
117    { 0x3b88, 0x88f1, 0x3b88, 0x7e19, 0xc1dd, &quot;  160 Hz&quot;},
118    { 0x3b4f, 0x8962, 0x3b4f, 0x7d9e, 0xc252, &quot;  200 Hz&quot;},
119    { 0x3b00, 0x8a00, 0x3b00, 0x7cf1, 0xc2f5, &quot;  256 Hz&quot;},
120    { 0x3aa6, 0x8ab4, 0x3aa6, 0x7c2b, 0xc3ac, &quot;  320 Hz&quot;},
121    { 0x3a36, 0x8b95, 0x3a36, 0x7b31, 0xc48f, &quot;  400 Hz&quot;},
122    { 0x39aa, 0x8cac, 0x39aa, 0x79f8, 0xc5a5, &quot;  500 Hz&quot;},
123    { 0x38e8, 0x8e31, 0x38e8, 0x783d, 0xc722, &quot;  640 Hz&quot;},
124    { 0x380b, 0x8fea, 0x380b, 0x763e, 0xc8ca, &quot;  800 Hz&quot;},
125    { 0x36fa, 0x920c, 0x36fa, 0x73b9, 0xcaca, &quot; 1000 Hz&quot;},
126    { 0x3580, 0x9500, 0x3580, 0x7027, 0xcd77, &quot; 1280 Hz&quot;},
127    { 0x33d7, 0x9852, 0x33d7, 0x6c03, 0xd05c, &quot; 1600 Hz&quot;},
128    { 0x31ce, 0x9c64, 0x31ce, 0x66c2, 0xd3bc, &quot; 2000 Hz&quot;},
129    { 0x2f06, 0xa1f5, 0x2f06, 0x5f4a, 0xd80d, &quot; 2560 Hz&quot;},
130    { 0x2bf0, 0xa821, 0x2bf0, 0x569a, 0xdc70, &quot; 3200 Hz&quot;},
131    { 0x2836, 0xaf95, 0x2836, 0x4b8b, 0xe12e, &quot; 4000 Hz&quot;},
132    { 0x2334, 0xb998, 0x2334, 0x3bb7, 0xe68e, &quot; 5120 Hz&quot;},
133    { 0x1dbf, 0xc483, 0x1dbf, 0x2913, 0xeb0d, &quot; 6400 Hz&quot;},
134    { 0x173d, 0xd186, 0x173d, 0x10c3, 0xee4c, &quot; 8000 Hz&quot;},
135    { 0x0eab, 0xe2ab, 0x0eab, 0xec30, 0xee0b, &quot;10240 Hz&quot;},
136    { 0x05f5, 0xf416, 0x05f5, 0xbdc5, 0xe487, &quot;12800 Hz&quot;},
137    { 0x00c5, 0xfe77, 0x00c5, 0x92d2, 0xcf90, &quot;16000 Hz&quot;}  // actually 15000 Hz
138};
139
140// band-pass
141static __BIQUAD_COEF __biquad_bpf_coefs[] =
142{
143    { 0x3ff5, 0x0000, 0xc00c, 0x0000, 0x3fea, &quot;   0 - 16000 Hz&quot;},
144    { 0x3c9d, 0x0000, 0xc364, 0x061c, 0x393a, &quot;  80 - 14464 Hz&quot;},
145    { 0x398b, 0x0000, 0xc676, 0x0c2a, 0x3315, &quot;  95 - 12928 Hz&quot;},
146    { 0x36c4, 0x0000, 0xc93d, 0x11b5, 0x2d88, &quot; 101 - 11520 Hz&quot;},
147    { 0x3427, 0x0000, 0xcbd9, 0x16e1, 0x284e, &quot; 113 - 10240 Hz&quot;},
148    { 0x31cc, 0x0000, 0xce35, 0x1b88, 0x2398, &quot; 127 -  9152 Hz&quot;},
149    { 0x2f65, 0x0000, 0xd09b, 0x2044, 0x1eca, &quot; 143 -  8128 Hz&quot;},
150    { 0x2d16, 0x0000, 0xd2eb, 0x24d3, 0x1a2b, &quot; 160 -  7232 Hz&quot;},
151    { 0x2ae2, 0x0000, 0xd51f, 0x2927, 0x15c3, &quot; 180 -  6464 Hz&quot;},
152    { 0x28a0, 0x0000, 0xd760, 0x2d96, 0x1141, &quot; 202 -  5760 Hz&quot;},
153    { 0x2652, 0x0000, 0xd9af, 0x3220, 0x0ca3, &quot; 226 -  5120 Hz&quot;},
154    { 0x2418, 0x0000, 0xdbe9, 0x367d, 0x082f, &quot; 254 -  4576 Hz&quot;},
155    { 0x21b7, 0x0000, 0xde49, 0x3b26, 0x036f, &quot; 286 -  4064 Hz&quot;},
156    { 0x1f59, 0x0000, 0xe0a7, 0x3fcd, 0xfeb3, &quot; 320 -  3616 Hz&quot;},
157    { 0x1d03, 0x0000, 0xe2fd, 0x445e, 0xfa07, &quot; 360 -  3232 Hz&quot;},
158    { 0x1a92, 0x0000, 0xe56e, 0x4927, 0xf525, &quot; 404 -  2880 Hz&quot;},
159    { 0x1807, 0x0000, 0xe7fa, 0x4e25, 0xf00e, &quot; 452 -  2560 Hz&quot;},
160    { 0x157d, 0x0000, 0xea84, 0x531c, 0xeafa, &quot; 508 -  2288 Hz&quot;},
161    { 0x12b6, 0x0000, 0xed4a, 0x588a, 0xe56d, &quot; 572 -  2032 Hz&quot;},
162    { 0x0fdf, 0x0000, 0xf022, 0x5e1d, 0xdfbe, &quot; 640 -  1808 Hz&quot;},
163    { 0x0ce7, 0x0000, 0xf31a, 0x63e8, 0xd9ce, &quot; 720 -  1616 Hz&quot;},
164    { 0x09aa, 0x0000, 0xf657, 0x6a3e, 0xd354, &quot; 808 -  1440 Hz&quot;},
165    { 0x061f, 0x0000, 0xf9e2, 0x7130, 0xcc3e, &quot; 904 -  1280 Hz&quot;},
166    { 0x0239, 0x0000, 0xfdc8, 0x78cc, 0xc472, &quot;1016 -  1144 Hz&quot;}
167};
168</CODE></pre></BLOCKQUOTE>
169
170<p>To reflect changes to the filter coefficients <SPAN class="argument">b0</SPAN> - <SPAN class="argument">a2</SPAN> in DSP, the application must assert the <CODE>AX_SYNC_USER_BIAQUAD_COEF</CODE> bit in the <CODE>axvpb.sync</CODE> member. If the Biquad filter switch <SPAN class="argument">on</SPAN> value is changed and the overall <code>AXPBBIQUAD</code> structure needs to be reflected in the DSP, the application must assert the <code>AX_SYNC_USER_BIQUAD</code> bit.</p>
171
172<p><strong>If an extremely small value is set for a filter coefficient (<code>__biquad_lpf_coefs[]</code> of 80Hz in the above sample), some sounds may exhibit noticeable pop.</strong></p>
173
174<p><strong>The load placed on DSP by Biquad filters is three times greater than by conventional LPF filters. The load is about the same as for a mixer with one AUX bus.</strong></p>
175
176<h2>See Also</h2>
177<p class="reference">
178<a href="../Voice_Parameter_Blocks/sync.html">axvpb.sync</a>, <a href="../Voice_Parameters/AXSetVoiceBiquad.html">AXSetVoiceBiquad</a>, <a href="../Voice_Parameters/AXSetVoiceBiquadCoefs.html">AXSetVoiceBiquadCoefs</a>
179</p>
180
181<h2>Revision History</h2>
182<P>
1832006/11/14 Initial version.<br>
184</P>
185
186<hr><p>CONFIDENTIAL</p></body>
187</html>
188
189