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