FIR-ward Thinking – Part 4 – Build a FIR in EASERA
by Paul Peace
One of the powerful features of EASERA™ is its ability to work equally well in both the time and frequency domains.
One of the powerful features of EASERA™ is its ability to work equally well in both the time and frequency domains. The exercise shown here produces a complement filter impulse response from a loudspeaker measurement. This filter ‘kernel’ can be used as a set of FIR coefficients to linearize the loudspeaker’s phase response while also doing gentle equalization.
In general, the idea here is to use an anechoic type measurement of the loudspeaker to correct its baseline performance errors. Room equalization should be performed in a traditional manner once the loudspeaker is installed.
It Begins With the Impulse Response
The impulse response of the example loudspeaker is shown below.
Plot 1 – The loudspeaker’s impulse response.
The example loudspeaker was not measured in an anechoic chamber, but a large room with the mic 2 m from the loudspeaker with all room reflections windowed out of the measurement.
This paper assumes a basic knowledge of EASERA and its EDIT functions. It must be remembered to always use the MARKERS to set the area to be edited and to always verify the results before moving to the next step. A good practice is to SAVE a copy of each completed step along the way. This is easily done by CREATING A DUPLICATE COPY FOR PROCESSING of the file each step.
Beginning measurement: Typical loudspeaker with non‐minimum phase behavior due to crossover, driver, and horn effects (Plot 2).
This measurement has already been windowed to remove room related artifacts. This is evident by the lack of low frequency resolution. This is totally acceptable in this exercise as we are not trying to do any room related or low frequency equalization with this filter.
I will take this measurement and build an FIR filter kernel to correct phase and do gentle magnitude shaping.
Plot 2: The transfer function of the windowed impulse response.
Special considerations at this point:
- 1. The measurement sampling rate should be the same as the DSP filter sampling rate. Interpolation or decimation will be required otherwise and both present difficulty and potential error. This paper assumes the sampling rate is a constant.
- 2. There are always tap count and latency requirements and limitations. These should be understood before beginning.
- 3. Linear Phase vs. Minimum Phase – The goal here should be to remove non‐minimum phase behavior. Minimum phase behavior should be left intact or corrected with minimum phase correction.
In the category of “Leave minimum phase behavior intact” are the two ends of the spectrum. The natural high pass and low pass of the loudspeaker does not need correction. Therefore, we want the filter kernel to leave magnitude and phase as‐is in this area. Therefore, this area is ‘flattened’ in both magnitude and phase (Plot 3).
Plot 3 – The high and low pass sections of the transfer function are excluded.
Use the “SET TO” function for this.
Set transition points the same for both magnitude and phase.
The low frequency transition point should be set at the zero crossing of the phase that corresponds to the high pass filter action. In this case, this point was 215Hz.
If at all possible, let the high frequency section to be zeroed be at the same level as the low frequency section. This was done in this example as shown in the magnitude response.
Smoothing – An Important Step
The next operation is smoothing. The amount of smoothing is a case-by-case judgment. 1/3-octave is chosen here. There is a temptation with FIR to try and fix everything. It must be remembered the measurement taken was only one point in space. In addition, it is important to understand what errors can and should be corrected. Not all errors can be fixed with equalization, even with the precision available with FIR.
The magnitude and phase is smoothed independently in EASERA. It is very important to smooth both.
Start with magnitude and set markers in the flat areas as shown (Plot 4). Setting markers at the FFT ends forces the smoothing to look through the FFT cycle which can produce unexpected results.
Plot 4 – Marked sections are to be smoothed.
EASERA provides the ability to smooth the phase response but this can be tricky. Smoothing through a phase wrap (or in UN‐WRAP) produces error. The best thing is to do is a CYCLIC MOVE to shift the phase such that the area to be smoothed is in‐between wraps as shown above. Do this in two operations if necessary. This example allows us to achieve it in one.
CYCLIC MOVE back to original position once completed.
Plot 5 – The smoothed and flattened curves overlaid against the original.
To linearize the frequency response, we must create the mirror image of both magnitude and phase. The first step is to create the mirror image of the phase response. Mathematically, this is called the complex conjugate. This simply means inverting the ‘sign’ of the imaginary part of the complex data (Plot 6).
Plot 6 – The imaginary part “flipped.”
EASERA does this easily by allowing us to view and process the imaginary curve. Simply set markers at the two extremes and multiply the Imag curve by –1.
Before and After shown in Plot 7.
Plot 7 – The phase curve is now a mirror image of the original in its smoothed and flattened form.
The next operation is to take the Inverse of the smoothed and flattened magnitude. This result is shown overlaid with the original curve below (Plot 8).
The operation used for this is the 1/x command or Exponentiate by –1.
The magnitude level of the result will usually need to be adjusted after this process. It is fairly arbitrary at this point. The final filter kernel can be scaled in the time domain to get the final gain of the filter correct.
Use the MULTIPLY BY FACTOR command to adjust level at this step if desired.
Plot 8 – The filter is the inverse of the smoothed, flattened magnitude response.
We now have the foundation of a filter kernel. Make sure and Save the new file at this point.
To test the filter:
While in Magnitude view, overlay the ORIGINAL signal and the new filter KERNEL.
Do a MULTIPLY CHANNELS command (Multiplying in Frequency Domain is Convolving in the Time Domain).
The result of this operation is shown below.
Plot 9 – The filter is applied by multiplying in the frequency domain.
The results will be a good predictor of what an actual FIR implementation will be. At this point, we are still using the full FFT windows for both measurement and kernel. The next steps will begin developing an FIR kernel from the FFT file.
Convolution in the Time Domain
The time domain view of what we just created. Notice the near mirror image of the ORIGINAL vs. the KERNEL.
Plot 10 – The responses are convolved in the time domain. The “*” denotes convolution.
The Step response view (Plot 11) shows how distorted the original response (green) of the loudspeaker in the time domain. The RESULT (in red) shows a Step response very similar to a typical high pass filter (which the loudspeaker response is similar to). The energy is now centered on a single point in time.
Plot 11 – The step response, before and after.
Now the KERNEL can be prepared to send out to a DSP. The first step is to determine the overall tap size. This is counted in samples while in EASERA. Use the CYCLIC move and ZOOM to get all of the KERNEL visible, then set markers at the outer fringes.
This KERNEL is not a linear phase filter in itself. It is the mirror complement of a non‐minimum phase device. The Kernel Impulse response will not be symmetric, however, it will still need to have an overall window with the primary energy close to the center.
It is best to perform a window operation at the fringes to set a graceful termination of the energy to zero. This is done using the WINDOW command at both ends as shown below (Plot 12). This exercise will determine how low in frequency the filtering will go. Correcting low frequency errors will require longer time windows. This example does not show difficulty in this regard, but expect this compromise often in practice.
A helpful step is to CYCLIC MOVE the KERNEL to begin exactly at 0 sec. This allows the tap count and latency estimation to be determined directly from the graph and cursor.
The KERNEL shown here is 230 samples of non‐zero information.
Plot 12 – Setting the filter length (# of taps) requires the placement of MARKERS.
Creating the Final File
- 1. SET END MARKERS to the determined FIR window size (remember sample = coefficient in this endeavor).
- 2. CREATE NEW FILE FROM MARKER AREA. There is a 256 sample minimum for this operation so there will be 26 zero coefficients in the example file.
- 3. Once the KERNEL is created with the new time window, it should then be saved as a file for export. With Impulse window open, do a SAVE AS in .etx file format or in .wav format, depending on the DSP requirements.
- 4. For .txt file requirements, open the file in EXCEL (or equiv). Go through the import routine engaging comma delimited parameter.
The file will look like the screen shot shown below. Delete all of the header information and the first column of data (time axis).
At the end of the file, the data string will be just zeros with footer information as shown below. Delete off the zero coefficients not needed to achieve the proper tap count.
Save this file (the coefficients) as a .txt or .csv depending on the DSP targeted. The coefficient file can then be imported into the DSP of choice and utilized for actual use.
The ‘BEFORE and AFTER’ graph below shows the result of this operation.
Plot 13 – The before and after loudspeaker response.
If filter gain needs adjusting, go back into EXCEL and multiply all coefficients by the appropriate amount to make the adjustment – usually somewhere between 0.9 to 1.1 in most cases. A helpful design marker is to sum all coefficients. This should be close to unity in most cases. pp
Paul Peace is a senior systems engineer for JBL Professional. His background includes the development of loudspeakers for IMAX theaters at Sonics Associates. He also worked as a loudspeaker engineer for Renkus-Heinz, Inc.