The rePhase FIR tool
rePhase is a Windows-based freeware program written by Thomas (aka "pos"), a long time miniDSP community member. rePhase generates finite impulse response (FIR) filters that "reverse" the phase shifts introduced by a loudspeaker crossover. rePhase can also generate linear-phase crossovers. With the aid of a real-time FIR filtering engine or "convolver" such as miniDSP's OpenDRC or miniSHARC, the result is a linear-phase loudspeaker system.
- What you will need
- Functional overview
- Example 1: correcting loudspeaker phase
- Example 2: a linear-phase crossover
- Usage notes
- More info
What you will need [Top]
The rePhase program. rePhase can be downloaded from SourceForge here: http://sourceforge.net/projects/rephase/.
A convolver/filtering engine:
- An OpenDRC-DI with stereo digital input and output, and the OpenDRC 2x2 plugin
- An OpenDRC-AN with stereo balanced analog input and output, and the OpenDRC 2x2 plugin
- An OpenDRC-DA with stereo digital input and balanced analog outputs, and the OpenDRC 2x2 plugin
- A miniSHARC and the miniSHARC 4x8 plugin for up to 4 input channels and 8 output channels (requires implementation of your own I/O via I2S)
To effectively use this app note, you will need to be familiar with some basics of acoustic measurement, loudspeaker design and DSP. Please see the following app notes for background information:
- FIR vs IIR filtering
- UMIK-1 setup with REW
- Loudspeaker measurement with UMIK-1 and REW
- Time alignment basics
- Building a 2way crossover
Functional overview [Top]
rePhase can be used to:
Correct/linearize the phase of conventional loudspeaker crossovers—whether digital or analog
Implement a linear-phase loudspeaker crossover "from scratch"
rePhase accomplishes this by generating FIR filters that you load into an OpenDRC or miniSHARC. While it is possible to use rePhase to correct for room issues, it is intended to be a loudspeaker design tool. In this app note we will give an example of each of the two loudspeaker design scenarios above.
The rePhase user interface allows you to import a measurement from your measurement program and then manipulate the amplitude and phase of the correction filter. The interface is quite intuitive and includes a graph of the predicted response and a large number of controls, many accessed via tabs:
The phase and amplitude correction features are accessed from the main set of tabs:
We will cover each of these tabs in the examples below. The key point in understanding how rePhase works is that it allows you to adjust the amplitude and phase responses of the filter independently. Examine the following figure, in which amplitude is shown as the solid blue line and phase as the dotted blue line:
In this figure, there are three filters applied at different frequencies, as follows:
- 100 Hz: a minimum-phase notch in the amplitude response. In addition to the notch in the amplitude, there is a wiggle in the phase response around the center frequency. This is typical of a normal parametric equalizer (digital IIR or analog).
- 1 kHz: a linear-phase notch in the amplitude response. Note that even though the amplitude changes, the phase is completely unchanged around the center frequency.
- 10 kHz: a phase shift generated by rePhase, but with no change in the amplitude response. This enables rePhase to correct or "undo" phase shifts caused by typical crossover filters.
Example 1: correcting loudspeaker phase [Top]
In this example, we will use rePhase to linearize the phase of a loudspeaker crossover. This technique can be used regardless of whether the crossover is passive (inductors and capacitors in the loudspeaker box), an analog active crossover, or a DSP active crossover.
The example speaker has a fourth-order (24 dB/octave) Linkwitz-Riley crossover at 3 kHz and is a sealed box with a rolloff at 80Hz. First, we measure the loudspeaker's response and then import the measurement into rePhase. To apply the phase correction filters in rePhase, go to the Filters Linearizationtab and add correction filters for the crossover and for the 80 Hz rolloff:
In the figure below is the original response in red, with amplitude shown as the solid line and phase as the dotted line. The predicted response is in blue. As you can see, the amplitude is unchanged but the phase is flattened out (because phase "wraps" every 360 degrees, the corrected phase at -360 is equivalent to it being zero):
To generate the FIR filter coefficients for loading into an OpenDRC, set the Impulse Settings as shown here and press Generate:
Typically, the same filter will be used on both channels, so load the file into both FIR - Channel 1 and FIR - Channel 2 of the OpenDRC 2x2 plugin.
You can now measure the speaker again and check the result. Here is the measured phase of the example speaker, with the phase of the uncorrected speaker in red, and the phase after the correction filter has been applied in blue:
In general, a loudspeaker crossover may not always be quite so easy to linearize. (Also, rePhase only directly supports linearization of Linkwitz-Riley crossovers.) For arbitrary phase corrections, use the Paragraphic Phase EQ tab, which has a set of "sliders" that adjust the phase up or down in a bell-shaped curve. It's like a graphic equalizer, but for phase! Unlike a graphic equalizer, the Q (sharpness) and center frequency of each bell can be changed in addition to the amount of phase shift. The result from using the paragraphic phase EQ for additional phase correction at low frequencies is shown in the graph above in green.
The effect of the phase correction can be observed in the time domain in various ways. For example, here are the impulse responses of the loudspeaker before (in red) and after phase correction (in blue):
Here is a 2 kHz square wave as seen by the microphone, before phase correction:
And after phase correction:
Example 2: a linear-phase crossover [Top]
rePhase can also be used to generate linear-phase crossover filters. As an example, we re-did the above speaker with a linear-phase two-way crossover. One OpenDRC per channel can be used to implement a two-way crossover, or the miniSHARC for up to a stereo four-way crossover.
The drivers must first be measured without any crossover filters in place. You should prepare the measurements for use in rePhase by applying some smoothing or gating, as this will make it easier to make amplitude corrections. For each driver, you will then:
- Export the measurement from the measurement program (in REW, go to File→Export→Measurement as Text)
- Import the measurement file into rePhase
- Use the Paragraphic Gain EQ tab with minimum-phase filters to flatten the amplitude response
- Use the Filters Linearization tab to correct box rolloff phase
- Use the Paragraphic Phase EQ tab for any remaining phase correction
- Use the Linear Phase Filters tab to create the desired crossover filter
- Export the impulse response from rePhase into a file
- Load the impulse response file into the OpenDRC 2x2 or miniSHARC 4x8 plugin
- Measure the driver again to check that the expected result is obtained
That may seem like a lot, but it's straightforward once you understand how rePhase works! Here's the woofer measurement of the example speaker loaded into rePhase shown in red, and the predicted response after steps 1 to 5 above in blue:
The next step is to select a crossover filter. rePhase has a wide range of filter types, different to what you will be used to for IIR crossovers. Here is the setting used for the woofer in the example speaker, an overlapping crossover with a steep (96 dB/octave) cut-off:
To export the impulse response, use settings like those shown in the following screenshot. It's recommended that the "centering" options be set to "middle" and "int" so that the peak of the impulse response is at a known location (see note 4 below):
With the woofer done, you will need to repeat the above for the tweeter (and additional drivers if implementing a three-way or four-way). Each driver should be done in a separate rePhase project.
The impulse responses can now be loaded into the OpenDRC or miniSHARC and the drivers re-measured individually and then in combination. Time alignment may be needed to adjust for acoustic offsets of the drivers and differences in the location of the impulse response peak.
The following graph shows the measured amplitude responses of the example speaker, where the individual responses of the woofer and tweeter are shown in blue and green, and the combined response in mauve (see notes 5 and 6 below).
This is the measured phase response of the example speaker:
Usage notes [Top]
rePhase is designed to allow the operator full control over the correction and filtering implemented. Here are some additional notes on usage:
While you can put in almost anything you like for the correction or crossover filters, the requested filter may not be realizable depending on the length of FIR available. After pressing Generate, rePhase will show the actual response that can be achieved in red.
The generated FIR filters are not causal — that is, the impulse response starts "ahead of time." In practice, this means delaying the impulse response peak, thus effectively delaying the output signal. For stereo audio playback, this is usually not a problem, but it may be a problem when synchronization with video is needed (home theater), for music recording or in live performance.
The part of the FIR impulse response before the peak is sometimes referred to as "pre-ringing." While debates rage about how audible this is and under what circumstances, it is something to be aware of when designing with FIR filters.
When implementing a multi-way speaker, the impulse response peak of each driver must be aligned in time. That is why the "middle int" centering option was suggested above, so the peak is in a predictable location. If the FIR filters for each driver are of different lengths, then time delay will be needed to re-align the acoustic signals from the drivers.
Any digital filter or speaker design program is a tool to aid you in creating a good speaker, but driver selection and cabinet design are also very important. For example, the measurements above show an issue in the 7-8 kHz region that should not be "fixed" digitally. Rather, an investigation is needed into a better design of the cabinet and/or a different tweeter.
The on-axis measured response is, of course, taken at only one point in space. Because a loudspeaker uses multiple drivers, there will be interaction between them so that the response will be different at other points in space. The off-axis responses, both horizontally and vertically, should also be measured and optimized to meet your design goals.
More Info [Top]
If rePhase is not the most suitable for your FIR filtering project, please see these other app notes for more options:
Forum links for more information on rePhase:
Don't forget to ask on the miniDSP forum if you have questions!