Java Programming Notes # 2358
- Preface
- General Background Information
- Preview
- Experimental Results
- Discussion and Sample Code
- Run the Program
- Summary
- What's Next?
- References
- Complete Program Listings
Preface
DSP and adaptive filtering
With the decrease in cost and the increase in speed of digital devices, Digital Signal Processing (DSP) is showing up in everything from cell phones to hearing aids to rock concerts. Many applications of DSP are static. That is, the characteristics of the digital processor don't change with time or circumstances. However, a particularly interesting branch of DSP is adaptive filtering. This is a scenario where the characteristics of the digital processor change with time, circumstances, or both.
Fifth in a series
This is the fifth lesson in a series designed to teach you about adaptive filtering in Java. The first lesson, entitled Adaptive Filtering in Java, Getting Started, introduced you to the topic by showing you how to write a Java program to adaptively design a time-delay convolution filter with a flat amplitude response and a linear phase response using an LMS adaptive algorithm.
A general-purpose adaptive engine
The third lesson in the series, entitled A General-Purpose LMS Adaptive Engine in Java, presented and explained a general-purpose LMS adaptive engine written in Java. That engine can be used to solve a wide variety of adaptive problems.
An adaptive line tracker
The previous lesson entitled An Adaptive Line Tracker in Java showed you how to use the general-purpose LMS adaptive engine to develop an adaptive spectral line tracker in Java. At the end of that lesson, I promised that future lessons would teach you about the following four general topics in adaptive filtering:
- System Identification
- Inverse System Identification
- Noise Cancellation
- Prediction
This lesson presents and explains a program named Adapt07, which demonstrates the use of adaptive filtering for System Identification and Inverse System Identification. Future lessons will deal with the other two items in the above list.
Viewing tip
You may find it useful to open another copy of this lesson in a separate browser window. That will make it easier for you to scroll back and forth among the different listings and figures while you are reading about them.
Supplementary material
I recommend that you also study the other lessons in my extensive collection of online Java tutorials. You will find those lessons published at Gamelan.com. However, as of the date of this writing, Gamelan doesn't maintain a consolidated index of my Java tutorial lessons, and sometimes they are difficult to locate there. You will find a consolidated index at www.DickBaldwin.com.
In preparation for understanding the material in this lesson, I recommend that you also study the lessons identified in the References section of this document.
General Background Information
What is system identification and system inversion?
Let me try to explain these terms using an example with which most of us are familiar. At some time in your life, you have probably attended a gathering in a venue such as a stadium or an auditorium and you came away with the general conclusion that the acoustics were bad.
What is meant by the acoustics are bad?
When you are located in different seats in such a venue, the acoustics may be good or they may be bad depending on where you are seated. For example, in some seats, you may be able to understand the announcer very clearly. In other seats, echoes, absorption, and other acoustic problems may make the announcer's voice very difficult to understand.
(Or, it may be that the electronic audio system is of poor quality causing the acoustics to be bad in all the seats.)
An acoustic system
We can think of the acoustic and electronic path between the announcer's vocal chords and your ears as an acoustic system. That system can be characterized by a complex frequency response and a corresponding impulse response.
A hypothetical measuring device
Assume for example that you have a portable device on which you can record two tracks of electronic data. Assume that you move this device around the auditorium recording what you hear at different locations. Assume that on one track you record the electronic signal produced by the announcer's microphone. Assume that on the other track you record the electronic output produced by a portable microphone that you carry with you.
The system transfer function
There are a variety of techniques available for analyzing the two recorded electronic signals in order to determine the complex transfer function resulting from the many electronic and physical components between those two points in the system.
Electronic transfer problems
For example, the amplifier and the loud speakers up on the stage may or may not produce a high-quality representation of the electronic output from the announcer's microphone. For example, the amplitude response of the amplifier and the speakers may not be flat across the desired range of frequencies. In addition, they may introduce phase distortion at certain frequencies causing words to sound distorted.
Physical transfer problems
Items such as drapes and carpets in the auditorium may absorb acoustic energy at certain audio frequencies preventing the acoustic energy at those frequencies from reaching your ears.
Various surfaces in the auditorium may produce echoes causing you to hear the same thing more than once. Interference patterns produced by the intersecting waves of acoustic echo energy may cause acoustic energy at certain frequencies and certain locations to interact constructively or destructively. This can cause the sound at some frequencies to be too loud and the sound at other frequencies to be too soft.
The overall system transfer function
All of these factors taken together result in a complex transfer function between the electronic signal produced by the announcer's microphone and the electronic signal produced by your portable microphone in a different location in the auditorium. One way to characterize this transfer function is through the development of an adaptive identification filter.
An inverse filter
Once you have characterized the system transfer function, it may be possible to design an inverse digital filter than will compensate for many of the problems in the system transfer function, causing the combined response of the system transfer function and the inverse filter to have a nearly flat amplitude response and a nearly flat (or at least linear) phase response.
Adaptive filter design provides one approach to designing such an inverse filter. (There are other approaches available as well.) When adaptive filter design is used to design the inverse filter, it is not necessary to first characterize the transfer function and then to design an inverse filter as two separate operations. Rather, those two steps can be combined to produce a single result, which is the adaptive inverse filter.
Applicable to many different areas
Although I have described this process using only one scenario, these techniques are applicable to a variety of different technical areas ranging from telephone line equalization to rock concerts.
Other references
There are many good references to adaptive filtering available on the web, which you can locate using Google. Two of the references that I recommend are located here and here. I will be referring to some of the images contained on those web pages in the discussion that follows.
Preview
The program named Adapt07
The purpose of this program is to illustrate adaptive identification and adaptive inverse filtering.
This program requires the following classes:
- Adapt07.class
- AdaptEngine02.class (new to this lesson)
- AdaptiveResult.class
- ForwardRealToComplex01.class
- PlotALot01.class
- PlotALot03.class
- PlotALot05.class
With the exception of the first two items in the above list, I have presented and explained the source code for each of the classes in the above list in previous lessons. You will find references to those earlier lessons in the References section of this document.
The source code for the class named Adapt07 can be viewed in its entirety in Listing 17. The source code for the class named AdaptEngine02 can be viewed in Listing 18.
The class named AdaptEngine02
This program uses the adaptive engine named AdaptEngine02 to adaptively develop a filter. Depending on user input, the resulting filter is designed to be either an identification filter or an inverse filter.
The class named AdaptEngine02 is a simple upgrade to the class named AdaptEngine01 that was explained in earlier programs. This upgrade makes it possible for the user to pass a boolean parameter to the adapt method of the engine to either enable or disable the adaptive update of the filter coefficients. Because of the similarity of the two classes, I won't provide a detailed explanation of the class named AdaptEngine02 in this lesson.
User options
When the user opts for an identification filter, the adaptive process attempts to replicate the impulse response of a path through which wideband test data are flowing. When the user opts for an inverse filter, the adaptive process attempts to develop a filter that is the inverse of the impulse response of a path through which wideband test data are flowing.
Test cases
User-selectable test cases are provided for six different path scenarios. The user may develop an identification filter or an inverse filter for any of the six cases.
Graphic output
If the user opts for an identification filter, five separate graphs are produced. If the user opts for an inverse filter, six separate graphs are produced. The graphs appear on the screen in two rows with three graphs in each row as shown in Figure 1.
Figure 1 |
Description of the graphs
The following is a brief description of each of the six graphs, working from left to right, top to bottom.
- The impulse response of the path through which the wideband data are flowing.
- The amplitude and phase response of the path through which the wideband data are flowing.
- Four time series that illustrate the time behavior of the adaptive process.
- The amplitude and phase response of the adaptive filter at the end of every 400th iteration.
- The impulse response of the adaptive filter at the end of every 400th adaptive iteration.
- The amplitude and phase spectrum of the time series produced by convolving the final adaptive filter with the impulse response of the path. (This graph is produced only when the user opts for an inverse filter. This amplitude and phase spectrum illustrates the extent to which the inverse filter is able to compensate for the path characteristics. Ideally the amplitude spectrum is flat and the phase spectrum is either flat or linear, indicating a time delay).
Graphs with multiple pages
Graphs 3, 4, and 5 consist of multiple pages stacked on top of one another. You can move the pages on the top of the stack to view the pages further down. The pages on the top of the stack represent the results produced early in the adaptive process while those further down represent the results produced later in the adaptive process.
The time series
The four time series that are plotted in the third graph in the top row are, from top to bottom in the colors indicated:
- Input to the adaptive filter (black).
- Target for the adaptive process (red).
- Output from the adaptive filter (blue).
- Error computed within the adaptive process (green).
Near the end of the run, the adaptive update process is disabled. The input data is set to zero for the remainder of the run except that on two subsequent occasions, an impulse is inserted into the data. This causes several interesting impulse responses to appear on the last page of the time-series plot.
The impulse responses
By running the same path twice, once in identification filter mode and once in inverse filter mode, the insertion of these impulses makes it possible to see:
- The impulse response of the path.
- The impulse response of the final adaptive identification filter.
- The extent to which the impulse response of the identification filter replicates the impulse response of the path.
- The impulse response of the final inverse filter.
- The extent to which the convolution of the final inverse filter with the impulse response of the path compensates for the characteristics of the path and produces the ideal output consisting of a single impulse.
Wideband test data
In operation, the program generates wideband test data produced by a random number generator and convolves it with a specified path impulse response to simulate the effect of the path on the test data. The original wideband test data and the path output data are both presented to the adaptive engine. The order in which the two are presented to the adaptive engine determines whether the adaptive engine will develop an identification filter or an inverse filter.
When the original wideband test data is presented as the data to be filtered within the adaptive engine and the path output is presented as the adaptive target, the adaptive process attempts to develop an adaptive filter that replicates the impulse response of the path. To help explain this, I am going to refer to the picture that you will find at The MathWorks web site.
(While you are there, it would also be a good idea for you to read what they have to say about adaptive filtering.)
Correspondence between my terms and the picture
The following paragraphs explain the correspondence between the terms that I use in this lesson and the terms used by the author of the picture. These relationships apply to the development of an identification filter. (I will address the relationships for an inverse filter a little later.)
The box labeled Unknown System in the picture is what I will refer to in this lesson as the path. The signal that the picture refers to as x(k), (which feeds both the adaptive filter and the path) is what I will refer to as wideband test data.
The signal that the picture refers to as d(k) is what I will refer to as the target. The signal that the picture refers to as e(k) is what I will refer to as the error.
Finally, everything inside the gray box in the picture corresponds to the adaptive engine in this lesson. The box labeled Adaptive Filter in the picture is what I will also refer to as the adaptive filter. It resides inside the adaptive engine.
Adaptive Filter and Unknown System are in parallel
As you can see from the picture, the wideband test data, or x(k) feeds into both the adaptive filter and the path. The target or d(k) feeds into the adaptive engine where it is combined algebraically with the output from the adaptive filter to produce the error or e(k).
(At this point, I have a small quarrel with the picture. The error should be processed through a multiplicative gain factor, feedbackGain, and used to adjust the filter coefficients. That isn't as obvious as it could be in the picture.)
Attempts to drive the error to zero
In any event, an LMS adaptive algorithm is used to adjust the coefficients in the adaptive filter in an attempt to drive the error to zero. When this is accomplished, the characteristics of the adaptive filter match the characteristics of the path. The adaptive filter then becomes an identification filter in that it identifies the characteristics of the Unknown System or the path.
When the two input time series that feed the adaptive engine are reversed, such that the path output is fed to the adaptive filter and the wideband test data is fed as the target, the adaptive process attempts to develop an adaptive filter that is the inverse of the impulse response of the path. To help explain this, I am going to refer to another picture that you will find at The MathWorks web site.
Correspondence between my terms and the other picture
The following paragraphs explain the correspondence between the terms that I will use in this lesson and the terms used by the author of the picture. These relationships apply to the development of an inverse filter in this lesson.
As before, the box in the picture labeled Unknown System is what I will refer to as the path. Everything inside the gray box in the picture is what I will refer to as the adaptive engine.
The signal that is referred to as s(k) in the picture is what I will refer to in this lesson as wideband test data. As you can see, after an appropriate delay, this signal also feeds the adaptive engine as the target or d(k).
As you can also see in the picture, the path output or x(k) feeds the adaptive filter in the adaptive engine. The output from the adaptive filter, y(k) is used to form the error e(k). In this picture, it is clear that the error is fed back and used to adjust the coefficients in the adaptive filter.
(However, even this picture is missing the feedbackGain factor.)
The path and the adaptive filter are in series
As in the previous case, the LMS adaptive algorithm adjusts the values of the filter coefficients in an attempt to drive the error to zero. When this is accomplished, the output from the adaptive filter replicates the wideband test data.
The only way that this can happen is for the characteristics of the adaptive filter to compensate for (cancel out) the characteristics of the path or the Unknown System. When one filter can be placed in series with another filter causing the combination of the two filters to be as if there were no filter in the system at all, one of those filters is known as the inverse of the other. This is sort of like the following arithmetic expression where 1/4 is the inverse of 4.
15 * (4 * (1/4)) = 15
Multiplying a value by 4 and then multiplying again by 1/4 is just like not multiplying at all (or multiplying by 1).
User input
User input is provided by five command-line parameters. If no command-line parameters are provided, default parameters are used. The command-line parameters are:
- feedbackGain: The gain factor that is used in the feedback loop to adjust the coefficient values in the adaptive filter. If this value is too large, the system will become unstable. If too small, it will take a long time for the system to converge to a solution.
- numberIterations: This is the number of iterations that the program executes before stopping and displaying all of the graphic results.
- filterLength: This is the number of coefficients in the adaptive filter. This value must be at least 26 (to satisfy certain plotting alignment issues).
- testCase: An integer from 1 to 6 that specifies the path characteristics.
- identification: Input is T or F. T specifies that the adaptive process is to develop an identification filter. F specifies that the adaptive process is to develop an inverse filter.
The minimum filter length
The minimum filter length of 26 has to do with plotting alignment issues and has nothing to do with the adaptive process. (See a description of the alignment issues in earlier lessons referred to in the References section of this document).
Six path scenarios are built into the code. The six path scenarios can be generally described as follows:
- A low-pass filter of the sort that might be realized with a passive RC network.
- Another low-pass filter that might be realized with a passive RC network but with a much longer time constant than scenario 1.
- A high-pass filter of the sort that might be realized with a passive RLC network having the same long time constant as scenario 2.
- A mid-band filter of the sort that might be realized with a passive RLC network having the same long time constant as scenarios 2 and 3.
- A filter that might represent an acoustic signal containing multiple echoes.
- A boxcar digital filter with a peak at half the Nyquist folding frequency.
Program testing
The program was tested using J2SE 5.0 and WinXP. J2SE 5.0 or later is required.
Experimental Results
Before getting into the program details, I'm going to show you some experimental results for three of the six path scenarios that are built into the program.
A low-pass filter with a short time constant
I will begin with the first scenario in the above list. I will also begin by developing an identification filter for this path scenario.
(This is the default case if you run the program without providing command-line parameters.)
The input parameters for this case are shown in Figure 2.
Input values were not provided. Using following default values: feedbackGain: 1.0E-4 numberIterations: 2001 filterLength: 26 testCase: 1 identification: true Figure 2 |
The path characteristics
Let's begin by characterizing the path for this case. As you will see later when we examine the code, the coefficients in the impulse response that characterize this path are shown in Figure 3.
double[] pathA = {1.0, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0}; Figure 3 |
Those of you who are familiar with such things will recognize this as an impulse response with an inverse exponential decay, truncated to zero after seven filter coefficients.
The impulse and frequency response of the path
This impulse response of the path is shown in graphic format in the left panel of Figure 4.
Figure 4 |
The right panel of Figure 4 shows the amplitude and phase response of this impulse response from zero to the Nyquist folding frequency. The black curve at the top of the panel is the amplitude response. The red line in the bottom of the panel is the phase response.
A low-pass filter
As you can see, this path characteristic tends to pass low-frequency signals and to suppress high-frequency signals.
(As I recall from my early days in the analog world, this is the digital equivalent of the response of a passive RC filter with an attenuation rate of six decibels per octave to the right of the corner frequency.)
The adaptive time series
The top panel in Figure 5 shows the adaptive time series at the beginning of the run. The bottom panel shows the time series at the end of the run.
Figure 5 |
Description of the traces
The top (black) trace shows the wideband test data that is fed into the adaptive filter. The second (red) trace shows the path output data, which forms the adaptive target for the development of the identification filter. In other words, the red trace shows the result of applying the path impulse response shown in Figure 4 to the wideband test data shown by the black trace in Figure 5.
(A practiced eye can discern that the red trace is richer in low-frequency energy and leaner in high-frequency energy than the black trace.)
The adaptive filter output
The blue trace is the output from the adaptive filter. Initially, the output from the filter is zero because all of the coefficients are initialized to values of zero. However as time progresses from left to right in the top panel of Figure 5, we start to see some output from the adaptive filter.
The error trace
The error, shown by the green trace in Figure 5, is the difference between the red target trace and the blue adaptive filter output trace. Initially the error looks just like the red target trace in the top panel of Figure 5. However, as time progresses from left to right, the blue output trace begins to gain strength and the error trace begins to be reduced in amplitude.
Somewhat later in time
Finally, after about 2000 adaptive iterations (see the numberIterations parameter in Figure 2) we arrive at the bottom panel in Figure 5. By this point in time, the adaptive filter coefficients have been adjusted to drive the green error trace to zero. This was accomplished by causing the blue adaptive filter output trace to replicate the red target trace. At this point, the adaptive filter is a replica of the path, and the unknown characteristics of the path have been identified. Stated differently, those characteristics have been captured in a digital filter than can be easily analyzed.
Some impulse responses
As I explained earlier, near the end of the run, the adaptive update process is disabled and a single impulse is inserted into the wideband test data shown by the black trace in Figure 5.
(An impulse in a sampled-data system is a single non-zero value surrounded by values of zero.)
This impulse is filtered by the path characteristics, producing the output shown by the red trace, and is also filtered by the adaptive filter, producing the output shown by the blue trace. As you can see, the adaptive filter has been adjusted such that the impulse response of the adaptive filter is a very good replica of the impulse response of the path. Both impulse responses match the impulse response shown in Figure 4.
Adaptive progression
The left and right panels in Figure 6 show the progression of the adaptive filter as it seeks a solution. (Time increases from top to bottom in Figure 6.)
Figure 6 |
The developing impulse response
The left panel in Figure 6 shows the impulse response at the beginning of the run and at the end of every 400th adaptive iteration. The objective is for the impulse response to match the impulse response for the path shown in the left panel of Figure 4. The match appears to be quite good after about 1200 adaptive iterations.
The developing frequency response
The right panel in Figure 6 shows the amplitude and phase response of the adaptive filter at the beginning of the run and at the end of every 400th iteration. The objective here is for the amplitude and phase response of the filter to match that of the path shown in the right panel of Figure 4. Once again, the match appears to be pretty good after about 1200 adaptive iterations.
A corresponding inverse filter
Now let's take a look at the adaptive development of an inverse filter to compensate for, or cancel out the path characteristics shown in Figure 4.
To begin with, the input parameters for this run are shown in Figure 7.
Input values were provided. Using following values: feedbackGain: 1.0E-4 numberIterations: 2001 filterLength: 26 testCase: 1 identification: false Figure 7 |
As you can see, the input parameters match those in Figure 2 with the exception of the last item, which specifies an identification filter in Figure 2 and an inverse filter in Figure 7.
The path characteristics
The path characteristics haven't changed, so the impulse response and the frequency response shown in Figure 4 still describe the path.
The adaptive time series
Let's begin the discussion with the adaptive time series shown in Figure 8.
Figure 8 |
Interpretation of the traces
Regardless of whether the user has opted for an identification filter or an inverse filter, the four traces shown in Figure 8 have the same relationship to the adaptive engine.
- The black trace is the input to the adaptive filter.
- The red trace is the target.
- The blue trace is the output from the adaptive filter.
- The green trace is the error.
However, depending on whether the user has opted for an identification filter or an inverse filter, the specific time series that are fed to the adaptive engine for the first two roles in the above list are different.
For an identification filter, the wideband test data is fed to the adaptive engine as the input to the adaptive filter and the path output data is fed to the adaptive engine as the target. See the picture at The MathWorks web site.
For an inverse filter, the path output data is fed to the adaptive engine as the input to the adaptive filter, and the wideband data is fed to the adaptive engine as the target. See the other picture at The MathWorks web site.
The top two traces are switched
In summary, the top two traces in graphs having the format of Figure 8 are switched depending on whether the user has opted for an identification filter or an inverse filter.
The data traces for Figure 8
Because Figure 8 shows the time series involved in the development of an inverse filter, the black top trace in Figure 8 is the path output data. The wideband test data is shown by the red trace. As always, the adaptive filter output is shown by the blue trace, and the error is shown by the green trace.
The top panel in Figure 8 shows these traces at the beginning of the run and the bottom panel shows these traces at the end of the run.
As you can see in the bottom panel of Figure 8, the blue filter output trace matches the red target trace. The green error trace, which is the difference between the adaptive filter output and the target, has been driven to zero.
Impulse responses
The bottom panel in Figure 8 shows two sets of impulses or wavelets, one following the other in time. The left-most set of wavelets in Figure 8 has the same meaning as in Figure 5, except for the reversal of the top two traces. In this case, the impulse that is inserted in the wideband data is shown in the red trace. The impulse response of the path is shown in the black trace, and it matches the impulse response shown in Figure 4 as before.
Now for something a little different
The leftmost wavelet on the blue trace in Figure 8 shows the result of applying the adaptive filter, which is now an inverse filter instead of an identification filter to the path output data. In this case, the inverse filter has acted on the wavelet shown in the black path output trace and has transformed it back into a single impulse that matches the impulse in the wideband test data shown by the red trace. That is the desired result. The inverse filter has compensated for, or cancelled out, the characteristics of the path, producing an output that matches the input to the path.
The rightmost wavelets
Now consider the rightmost set of wavelets in the bottom panel in Figure 8. At the time of the rightmost set of wavelets, an impulse was inserted into the black path output data. This impulse propagated through the adaptive filter, (for which the state had been frozen by disabling adaptive updates) producing the impulse response of the adaptive filter shown by the rightmost wavelet on the blue trace.
What does this all mean?
One way to think of this is as follows. The red impulse in the wideband test data was convolved with the impulse response of the path producing the output shown by the leftmost black wavelet. This wavelet was convolved with the impulse response of the adaptive filter (shown by the rightmost blue wavelet) producing the leftmost blue wavelet. For an inverse filter, the leftmost blue wavelet is an impulse that matches (or tries to match) the original input to the path shown by the red trace.
(The wavelet on the green error trace in Figure 8 is an artifact that has no meaning in this discussion of impulse responses. Just ignore it.)
The impulse and frequency response of the adaptive filter
Now let's take a look at the impulse and frequency response of the adaptive filter as shown in Figure 9.
The impulse response of the adaptive filter is shown in the left panel of Figure 9, progressing from the beginning to the end of the run. You should recognize the impulse response at the bottom of the left panel in Figure 9 as the same impulse response that you saw as the rightmost blue wavelet in Figure 8.
Figure 9 |
The frequency response of the adaptive filter
The amplitude and phase response of the adaptive filter is shown in the right panel of Figure 9 with time progressing down the page. As before, the phase response (shown in red) is flat. This makes us happy.
Note the shape of the black amplitude response at the bottom of the right panel. Compare it with the amplitude response of the path shown in Figure 4. As you can see, the amplitude response of the adaptive filter is the inverse of the amplitude response of the path.
At low frequencies where the amplitude response of the path is high, the amplitude response of the inverse adaptive filter is low. At high frequencies where the amplitude response of the path is low, the amplitude response of the inverse filter is high. The result is that the product of these two frequency responses (on a frequency by frequency basis) produces an overall response that is very flat across the frequency spectrum from zero to the Nyquist folding frequency.
More evidence
This is borne out by the graph shown in Figure 10. Figure 10 shows the amplitude and phase response of a wavelet produced by convolving the impulse response of the path with the impulse response of the inverse filter.
Figure 10 |
Essentially, Figure 10 shows the amplitude and phase response of a wavelet that matches the leftmost blue wavelet in Figure 8. Because this wavelet is an impulse, the amplitude response is flat across all frequencies and the phase response is zero across all frequencies.
We already knew that the amplitude response of an impulse was flat
I'm showing you the graph in Figure 10 at this point in the discussion mainly to prepare you for corresponding graphs for other path scenarios. As you will see later, some of the corresponding graphs for other path scenarios aren't nearly as ideal as this one.
Where do we go from here?
I don't plan to show you nearly this much detail for all six path scenarios that are built into the program. You can run all of the scenarios and view the details for yourself. However, I will show you the highlights for a couple of additional path scenarios.
A path with multiple echoes
At this point, I am going to skip ahead to the path scenario identified as test case number 5. The parameters for this run are shown in Figure 11. As you can see from Figure 11, this run is intended to develop an identification filter.
Input values were provided. Using following values: feedbackGain: 1.0E-4 numberIterations: 2001 filterLength: 26 testCase: 5 identification: true Figure 11 |
The path characteristics
Let's begin with the path characteristics shown in Figure 12.
Figure 12 |
The impulse response of the path is shown in the left panel of Figure 12. The amplitude and phase response of the path is shown in the right panel of Figure 12.
Multiple echoes
If by now you have developed an understanding of the convolution process, you may recognize that the impulse response shown in Figure 12 causes the path output to consist of the sum of four attenuated versions of the input, each delayed relative to the previous one. This is generally what we would hear in an acoustic echo situation.
Hello
Hello
Hello
Hello
The amplitude response
This results in a path amplitude response that is definitely not flat as shown by the right panel of Figure 12. In fact, this results in a situation where destructive interference causes (almost) total suppression of the signal at one frequency.
(Note that the phase also goes through a little nonlinearity at the frequency where the amplitude response goes to near zero.)
The adaptive time series
Figure 13 shows the beginning and the ending time series for this run. As you can see, by the end of the run, the green error has been driven to zero and the impulse response of the adaptive filter shown by the blue wavelet matches the impulse response of the path shown in red. Thus, the unknown characteristics of the path have been faithfully captured in the adaptive filter. (The unknown characteristics of the path have been identified.)
Figure 13 |
If you run this case and view the amplitude and phase response for the adaptive filter, you will see that they are also a good match for the amplitude and phase response for the path shown in Figure 12.
Inverse filter for path with multiple echoes
Now let's develop the inverse filter for the same path with multiple echoes. The input parameters for this case are shown in Figure 14.
Input values were provided. Using following values: feedbackGain: 1.0E-4 numberIterations: 2001 filterLength: 26 testCase: 5 identification: false Figure 14 |
The time series for the inverse adaptive filter
The beginning and ending time series for the run are shown in Figure 15.
Figure 15 |
This is a little different
Note that in Figure 15, unlike for the previous path scenario, the green error trace was not driven completely to zero.
Perhaps the most striking thing about Figure 15 is that the impulse response of the adaptive filter (shown as the rightmost blue wavelet) did not succeed in fully compensating for the path characteristics. This is evidenced by the fact that the leftmost blue wavelet is not a clean impulse. Rather, there is some noise to the right of the main body of that wavelet.
How do we explain this anomaly?
I will begin the explanation by taking a look at the impulse and frequency response of the adaptive filter shown in Figure 16 and comparing it with the frequency response of the path shown earlier in Figure 12.
Figure 16 |
Reality sets in
The reality is that it is not possible to develop a perfect inverse filter for this path. There is a frequency (see Figure 12) at which the frequency response of the path totally suppresses (or at least almost totally suppresses) the energy propagating through the path. Once that energy is gone, there is nothing that an inverse filter can do to recover it.
A peak in the amplitude response
If you look at the bottom amplitude response shown in Figure 16, there is a peak in the amplitude response at that frequency. However, for that peak to function as the inverse of the notch in the frequency response of the path (see Figure 12) at that frequency, the peak would have to be infinite in height (or at least very large), which it clearly isn't.
Very little energy in the output at that frequency
Continuing with the explanation as to why the inverse filter doesn't totally compensate for the path characteristics, Figure 17 shows the amplitude and phase response for the wavelet produced by convolving the impulse response of the path with the impulse response of the adaptive filter (the leftmost blue wavelet in Figure 15).
Figure 17 |
Unlike the previous case shown in Figure 10, this amplitude response is not completely flat. Rather, it has a notch at the frequency where the amplitude response of the path goes through zero.
Again, once the characteristics of the path have suppressed most of the energy at that frequency, there is nothing that the inverse filter can do to recreate that energy.
A path with four notches
If you run case 6, you will see that it exhibits similar behavior but even worse. I purposely designed this case such that the amplitude response of the path has four points where the amplitude response goes through zero, as shown in Figure 18.
Figure 18 |
The output time series
This results in the time series shown in Figure 19. As you can see, the adaptive inverse filter (the rightmost blue wavelet in Figure 19) does not succeed in totally compensating for the path characteristics. There is quite a bit of noise following the main body of the leftmost blue wavelet in Figure 19.
Figure 19 |
Also, the green error trace has not been driven to zero in Figure 19.
The overall frequency response
The amplitude and phase spectrum of the leftmost blue wavelet in Figure 19 is shown in Figure 20. As you can see, there are four notches in the spectrum at the same frequencies as the points where the amplitude response of the path (shown in Figure 18) goes through zero. Also, there are nonlinearities in the phase response at those frequencies.
Figure 20 |
The input parameters
For the record, the input parameters for this run are shown in Figure 21.
Input values were provided. Using following values: feedbackGain: 1.0E-4 numberIterations: 2001 filterLength: 26 testCase: 6 identification: false Figure 21 |
Brief summary of adaptive inverse filtering
In summary, inverse filtering can do a lot to compensate for path characters and to restore a signal to the form that it had before propagating through the path. Inverse filtering can amplify energy that has been attenuated by the path, and can often correct for phase distortion. However, inverse filtering cannot work miracles. It cannot recreate signal energy that has been totally eliminated by the path. Fortunately most real-world paths are probably closer to the situation illustrated by case number 1 than by cases 5 and 6.
Now let's see some code.