1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<TITLE>How to Use IIR_FilterBuilder</TITLE>
8<LINK rel="stylesheet" href="../../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">How to Use IIR_FilterBuilder <IMG src="../../../image/TWL.gif"></H1>
12<P>One extended TWL feature is the ability to apply an IIR filter to microphone sampling data and speaker output data. See <A href="../SNDEX_SetIirFilter.html"><CODE>SNDEX_SetIirFilter[Async]</CODE></A> for information on setting IIR filters. This document explains how to use IIR_FilterBuilder, which is included with the TWL-SDK.</P>
13	<H2>Description</H2>
14	<P>The <CODE>$TwlSDK/docs/TechnicalNotes/IIR_FilterBuilder.xls</CODE> Excel spreadsheet is designed to calculate IIR filter parameters. The calculated parameters can be used as parameters for the <A href="../SNDEX_SetIirFilter.html"><CODE>SNDEX_SetIirFilter[Async]</CODE></A> functions.</P>
15
16	<P>To use this sheet, you need to enable the <B>Analysis ToolPak</B> from <B>Tools</B> &gt; <B>Add-Ins</B> in the Excel main menu. (Excel 2003)</P>
17
18	<H2>Using the Tool</H2>
19	<P>Choose one of the following three sheets to use.</P>
20	<TABLE>
21		<TBODY>
22		<TR>
23			<TH width="20%">Sheet name</TH>
24			<TH width="80%">Filter types that can be calculated</TH>
25		</TR>
26		<TR>
27			<TD width="20%">Shelf Filters</TD>
28			<TD width="80%">Bass Shelf Filter, Treble Shelf Filter</TD>
29		</TR>
30		<TR>
31			<TD width="20%">EQ Filters</TD>
32			<TD width="80%">Band Pass Filter, Band Eliminate Filter</TD>
33		</TR>
34		<TR>
35			<TD width="20%">Butterworth Filters</TD>
36			<TD width="80%">High Pass Filter, Low Pass Filter</TD>
37		</TR>
38		</TBODY>
39	</TABLE>
40
41	<P>Usually, the light blue items in the following figure are the only items on the sheet for which entries are required. Each sheet has slightly different input items.</P>
42	<IMG src="img/TableForUserInput.gif">
43	<P>The following tables shows the values that can be entered in each sheet.</P>
44	<DL>
45		<DT>Shelf Filters</DT>
46		<DD><TABLE>
47			<TR>
48				<TH width="25%">Input items</TH>
49				<TH width="75%">Description</TH>
50			</TR>
51			<TR>
52				<TD width="25%">Gain (dB)</TD>
53				<TD width="75%">Specify the amplitude gain.</TD>
54			</TR>
55			<TR>
56				<TD width="25%">fc (Hz)</TD>
57				<TD width="75%">Specify the cutoff frequency (frequency at which a 3 dB change occurs).</TD>
58			</TR>
59			<TR>
60				<TD width="25%">Fs (Hz)</TD>
61				<TD width="75%">Specify the sound sampling rate (47,610 or 32,730).</TD>
62			</TR>
63			<TR>
64				<TD width="25%">Bass/Treble</TD>
65				<TD width="75%">Specify &quot;B&quot; for a Bass Shelf Filter and &quot;T&quot; for a Treble Shelf Filter.</TD>
66			</TR>
67			</TABLE>
68		</DD>
69
70		<DT>EQ Filters</DT>
71		<DD><TABLE>
72			<TR>
73				<TH width="25%">Input items</TH>
74				<TH width="75%">Description</TH>
75			</TR>
76			<TR>
77				<TD width="25%">Gain (dB)</TD>
78				<TD width="75%">Specify the amplitude gain.</TD>
79			</TR>
80			<TR>
81				<TD width="25%">BW (Hz)</TD>
82				<TD width="75%">Specify the frequency bandwidth from the center frequency to the frequency at which a 3 dB change occurs.</TD>
83			</TR>
84			<TR>
85				<TD width="25%">fc (Hz)</TD>
86				<TD width="75%">Specify the center frequency for changing the amplitude.</TD>
87			</TR>
88			<TR>
89				<TD width="25%">Fs (Hz)</TD>
90				<TD width="75%">Specify the sound sampling rate (47,610 or 32,730).</TD>
91			</TR>
92			</TABLE>
93		</DD>
94
95		<DT>Butterworth Filters</DT>
96		<DD><TABLE>
97			<TR>
98				<TH width="25%">Input items</TH>
99				<TH width="75%">Description</TH>
100			</TR>
101			<TR>
102				<TD width="25%">High/Low</TD>
103				<TD width="75%">Specify &quot;H&quot; for a High Pass Filter and &quot;L&quot; for a Low Pass Filter.</TD>
104			</TR>
105			<TR>
106				<TD width="25%">fc (Hz)</TD>
107				<TD width="75%">Specify the cutoff frequency (frequency at which a 3dB change occurs).</TD>
108			</TR>
109			<TR>
110				<TD width="25%">Fs (Hz)</TD>
111				<TD width="75%">Specify the sound sampling rate (47,610 or 32,730).</TD>
112			</TR>
113			</TABLE>
114		</DD>
115	</DL>
116
117	<P>The following explanation uses the Shelf Filters sheet as an example.</P>
118	<IMG src="img/TableForUserInput.gif" align=left>
119	<P>If the values entered are as shown in the figure at the left, the frequency response graph, 1st biquad parameters, and 2nd biquad parameters will be updated in real time.<BR clear=left></P>
120	<IMG src="img/1stBiquadTable.gif" align=left>
121	<P>The figure to the left shows the calculated IIR filter parameters (the 1st biquad). The values for N0 through D2 correspond to the <A href="../SNDEXIirFilterParam.html"><CODE>SNDEXIirFilterParam</CODE></A> structure's members <CODE>no</CODE> through <CODE>d2</CODE>.</P>
122	<P>However, <B>Values</B>-type values must be type-cast to <CODE>u16</CODE> when they are inserted in the <A href="../SNDEXIirFilterParam.html"><CODE>SNDEXIirFilterParam</CODE></A> structure. Use <B>Hex</B>-type values because they can be passed unchanged.<BR clear=left></P>
123	<P>The <FONT color=blue>blue line</FONT> in the following figure shows the frequency response when this filter is applied. As you can see, its low frequencies are amplified by approximately 10 dB close to the 300-Hz boundary. </P>
124	<IMG src="img/frequencyResponseFig.gif">
125	<P>By looking closely at the blue line, you can see that the high-frequency region drops to approximately -0.1 dB as a side effect of the filter. This can be corrected by using one more IIR filter stage.</P>
126	<IMG src="img/2ndBiquadTable.gif" align=left>
127	<P>The figure to the left shows the IIR filter parameters for the 2nd biquad. The values for N3 through D5 correspond to the <A href="../SNDEXIirFilterParam.html"><CODE>SNDEXIirFilterParam</CODE></A> structure's members <CODE>no</CODE> through <CODE>d2</CODE></P>
128<P>However, <B>Values</B>-type values must be cast to type <CODE>u16</CODE> when they are inserted in the <A href="../SNDEXIirFilterParam.html"><CODE>SNDEXIirFilterParam</CODE></A> structure. Use <B>Hex</B>-type values because they can be passed unchanged.<BR clear=left></P>
129	<P>The <FONT color=green>green line</FONT> shows the frequency response for the 2nd biquad only. The entire frequency band is amplified by approximately 0.1 dB. The <FONT color=red>red line</FONT> shows the results of applying both the 1st biquad and 2nd biquad. If there are no problems with the 1st biquad results, you do not necessarily need to apply a 2nd biquad.</P>
130
131<H2>Notes</H2>
132<P>You must take note of the following when setting the calculated parameters in the <A href="../SNDEXIirFilterParam.html"><CODE>SNDEXIirFilterParam</CODE></A> structure.</P>
133<UL>
134<LI><B>Values</B>-type values: These should be type-cast to <CODE>u16</CODE> when passed.
135<LI><B>Hex</B>-type values: These can be passed unchanged.
136</UL>
137<P>
138</P>
139
140<H2>Revision History</H2>
141<P>
142	2009/02/19 Added text about the Excel setting for enabling automatic calculation in this sheet.<BR> 2008/09/10 Added notes regarding the use of calculated parameters.<BR> 2008/09/06 Initial version.</P>
143<hr><p>CONFIDENTIAL</p></body>
144</HTML>
145
146
147<!-- <A href="../SNDEX_SetIirFilter.html">SNDEX_SetIirFilter[Async]()</A> -->
148
149