📄 293-300.html
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1558515682"><META name=vstitle content="Java Digital Signal Processing"><META name=vsauthor content="Douglas A. Lyon"><META name=vsimprint content="M&T Books"><META name=vspublisher content="IDG Books Worldwide, Inc."><META name=vspubdate content="11/01/97"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Java Digital Signal Processing:Digital Audio Transform Recipes</TITLE>
<!-- HEADER --><STYLE type="text/css"> <!-- A:hover { color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!--ISBN=1558515682//-->
<!--TITLE=Java Digital Signal Processing//-->
<!--AUTHOR=Douglas A. Lyon//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=6//-->
<!--PAGES=293-300//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="286-293.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="300-306.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>The Bartlett window is generated by the <I>makeBartlett</I> method:</P>
<!-- CODE //-->
<PRE>
public double[] makeBartlett(int n) {
double window[] = new double[n];
double a = 2.0 / (n - 1);
for (int i = 0; i < n/2; i++)
window[i] = i * a;
for (int i = n/2; i < n; i++)
window[i] = 2.0 - i * a;
return window;
}
</PRE>
<!-- END CODE //-->
<P>We propose a window that is zero at the sample endpoints and also has zero first and second derivatives at both the endpoints and the center. Such a window can be formulated with two fifth-order polynomials (called <I>quintics</I>). We present, for your interest, some Maple code for deriving a quintic-based window.</P>
<P>Maple is a symbolic manipulator that can help with some math problems. In Maple, we let <I>dy</I> and <I>ddy</I> be the first and second derivatives of the polynomial with respect to the dilation parameter <I>u</I>. The dilation parameter will be varied between zero and 1, inclusive. The amplitude of the quintic will vary from <I>y</I>0 to <I>y</I>1. Maple’s optimization routine can output a procedure for computing quintics in minimum CPU time. What follows is a Maple procedure for generating the Lyon window. See [Lyon 91] for more information and an application of the quintic to maneuvering.</P>
<!-- CODE //-->
<PRE>
restart;y:=a5*u^5+a4*u^4+a3*u^3+a2*u^2+a1*u+a0:
> dy:=diff(y,u):
> ddy:=diff(dy,u):
> a0:=y0:
> a1:=solve(y1=subs(u=1,y),a1):
> a2:=solve(0=subs(u=0,dy),a2):
> a3:=solve(0=subs(u=1,dy),a3):
> a4:=solve(0=subs(u=0,ddy),a4):
> a5:=solve(0=subs(u=1,ddy),a5):
> readlib(C):
> C(y,optimized);
t2 = u*u;
t3 = t2*t2;
t11 = (6.0*y1-6.0*y0)*t3*u+(-15.0*y1+15.0*y0)*t3+(10.0*y1-
10.0*y0)*t2*u+y0;
</PRE>
<!-- END CODE //-->
<P>The following code makes the Lyon window:
</P>
<!-- CODE SNIP //-->
<PRE>
public double y5(double y0, double y1, double u) {
double t2 = u*u;
double t3 = t2*t2;
return
(6 * y1 - 6 * y0) * t3 * u +
(-15 * y1 + 15 * y0) * t3 +
(10 * y1 - 10 * y0) * t2 * u + y0;
</PRE>
<!-- END CODE SNIP //-->
<P>The formula for the Lyon window follows:
</P>
<P ALIGN="CENTER"><IMG SRC="images/06-60d.jpg"></P>
<P>(6.28)
</P>
<P>The easier way to formulate (and compute) the dilation parameter, <I>u</I>, is by incrementing it by 2/<I>N</I>:</P>
<!-- CODE //-->
<PRE>
public double[] makeLyon(int n) {
double window[] = new double[n];
double u = 0.0;
double du = 2.0/n;
for (int i = 0; i < n/2; i++) {
window[i] = y5(0,1.0,u);
u += du;
}
u=0;
for (int i = n/2; i < n; i++) {
window[i] = y5(1.0,0.0,u);
u += du;
}
return window;
}
</PRE>
<!-- END CODE //-->
<P>The Lyon and Hann windows are shown in Figure 6.14.
</P>
<P><A NAME="Fig14"></A><A HREF="javascript:displayWindow('images/06-14.jpg',453,228 )"><IMG SRC="images/06-14t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-14.jpg',453,228)"><FONT COLOR="#000077"><B>Figure 6.14</B></FONT></A> The Lyon and Hann windows compared.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>More study is needed to elaborate on the design trade-offs between the Lyon window and other popular windows. The most remarkable thing about it is that it has zero first and second derivatives at the center and endpoints. The Lyon window also has more taper at the side lobes than the Hann window and so may further reduce aliasing error.<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading20"></A><FONT COLOR="#000077">The High-Pass Filter</FONT></H3>
<P>One simple way to design a high-pass filter is to take an FFT on the input samples and then multiply the spectrum by the filter envelope. For example, we can zero out the low frequencies using a rectangular passband function, such as the one shown in Figure 6.15. Figure 6.16 shows a saw wave with its PSD. The PSD is multiplied by the characteristic function of the high-pass folter shown in Figure 6.15. The resulting PSD is shown on the right in Figure 6.17. On the left in Figure 6.17 is the reconstructed filtered wave form.
</P>
<P><A NAME="Fig15"></A><A HREF="javascript:displayWindow('images/06-15.jpg',139,130 )"><IMG SRC="images/06-15t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-15.jpg',139,130)"><FONT COLOR="#000077"><B>Figure 6.15</B></FONT></A> A high-pass filter (high-frequencies are toward the center).</P>
<P><A NAME="Fig16"></A><A HREF="javascript:displayWindow('images/06-16.jpg',390,203 )"><IMG SRC="images/06-16t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-16.jpg',390,203)"><FONT COLOR="#000077"><B>Figure 6.16</B></FONT></A> The saw wave and its PSD.</P>
<P><A NAME="Fig17"></A><A HREF="javascript:displayWindow('images/06-17.jpg',334,191 )"><IMG SRC="images/06-17t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-17.jpg',334,191)"><FONT COLOR="#000077"><B>Figure 6.17</B></FONT></A> The high-pass-filtered saw wave and its PSD.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>For the PSDs depicted in this chapter, the higher frequencies are toward the center of the graph.<HR></FONT>
</BLOCKQUOTE>
<P>For the determination of the performance of the various windows, we follow [Embree] and plot the windowed waveform alongside the log (in dB) of the PSD. We use the dB log and zoom into the first 200 samples of the PSD to make smaller details clear. We compute the graph using this code:
</P>
<!-- CODE SNIP //-->
<PRE>
public void graphPSD() {
double psd[] = fftInstance.computePSD();
double shortPsd[] = new double[200];
for (int i =0 ; i < shortPsd.length; i++) {
shortPsd[i] = 10*Math.log(Math.sqrt(psd[i]));
}
Graph.graph(shortPsd, “spectral mag”,”a dB”);
}
</PRE>
<!-- END CODE SNIP //-->
<P>Figure 6.18 shows a sine wave with a rectangular window. The sine wave is 400 Hz with 8,000-Hz sampling. This is often expressed as a relative frequency of 400/8,000 = 0.05.
</P>
<P><A NAME="Fig18"></A><A HREF="javascript:displayWindow('images/06-18.jpg',361,222 )"><IMG SRC="images/06-18t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-18.jpg',361,222)"><FONT COLOR="#000077"><B>Figure 6.18</B></FONT></A> A rectangular window and spectral dB log.</P>
<P>Figure 6.19 shows the Hann window with the spectral log magnitude.
</P>
<P><A NAME="Fig19"></A><A HREF="javascript:displayWindow('images/06-19.jpg',386,224 )"><IMG SRC="images/06-19t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-19.jpg',386,224)"><FONT COLOR="#000077"><B>Figure 6.19</B></FONT></A> The Hann windowed data with the FFT result.</P>
<P>The triangular windowed input of the Bartlett window and the PSD are shown in Figure 6.20.
</P>
<P>Figures 6.20 and 6.21 show that the Lyon window has somewhat better side lobe performance (lower spectral leakage) than the Bartlett window. Also, the main lobe in the Lyon window is narrower than that of the Bartlett window (lower noise bandwidth).</P>
<P><A NAME="Fig20"></A><A HREF="javascript:displayWindow('images/06-20.jpg',381,218 )"><IMG SRC="images/06-20t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-20.jpg',381,218)"><FONT COLOR="#000077"><B>Figure 6.20</B></FONT></A> The Bartlett windowed data and the PSD.</P>
<P><A NAME="Fig21"></A><A HREF="javascript:displayWindow('images/06-21.jpg',389,216 )"><IMG SRC="images/06-21t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-21.jpg',389,216)"><FONT COLOR="#000077"><B>Figure 6.21</B></FONT></A> The Lyon window and PSD.</P>
<P>Figure 6.22 shows the spectra for the Lyon and hann windows on the left and right, for comparison.
</P>
<P><A NAME="Fig22"></A><A HREF="javascript:displayWindow('images/06-22.jpg',400,220 )"><IMG SRC="images/06-22t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-22.jpg',400,220)"><FONT COLOR="#000077"><B>Figure 6.22</B></FONT></A> Spectra of Lyon (left) and Hann windows.</P>
<P>The Lyon and Hanning windows appear to be very close spectrally. The Lyon window appears to have a few dB better side lobe performance. The main lobe is slightly wider, however, and so has a slightly larger equivalent noise bandwidth. For more information on windowing, see [Mitra].
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="286-293.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="300-306.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright © <a href="/reference/idgbooks00001.html">IDG Books Worldwide, Inc.</a></font></div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --></BODY></HTML><!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -