REW as FIR maker

Mark Wilkinson

Registered
Thread Starter
Joined
Jun 9, 2017
Messages
10
Hi John, first post, and gratitude comes first.... What a blessing REW is to the DIY community. Thank you so much !

I've been experimenting using REW to make linear phase FIR filters and am hoping to get corrections to my process, and/or what you would consider best practice.

Test bed consists of a processor using 4128 samples at 48kHz per channel. FIR files can be wav or csv.
I chose 4128 samples because that lets me apply an even 43ms to both Left and Right IR windows for export.

Technique has been:
a. take measurements at 48kHz with no timing reference and t=0 at impulse peak.
b. import wav impulses from rephase: dirac pulse, and xovers. (48 kHz, 4128 samples, linear phase )
c: All SPL: Align IR start all traces
d. make measurement impulse inverse : dirac/meas
e. All SPL: Align IR start all traces
f. multiply impulse inverse by appropriate xover
g. All SPL: Align IR start all traces
h. Apply IR Widows to ALL, keep Ref Time: 43ms Left and Right Windows. I'm using Gaussian on both sides right now, from looking at overall dBFS impulse patterns zoomed out to see the full window.
i. Export all Impulse Responses as wav: Mono, Measured IR, Normalize, Apply IR Widow before Export

As you see, I've been a bit paranoid with Align IR start all traces. This import/ alignment has been trial and error learning for me.
I've tried, under Impulse Response Calculation in Analysis, setting t=0 to first sample, with success. But not being able to see phase on import without a shift drove me back to Align IR start.
I've tried All SPL: Time Align, and doing Estimated Impulse Shift on each trace individually prior to Trace Arithmetic. All have worked pretty well.
But soofar IR start has been the easiest, most consistent (which may just translate to least error prone) method I've found.

If there is a better way, please hit me with it. !

To test the FIR files, I've cascaded two FIR filters in the processor: the measurement FIR file and the inverse with xover.
The processor's computer interface allows a dual channel FFT in the design, so it's pretty easy to check for flat mag and phase, and then run REW measurements.

The attached mdat is of a coax compression driver tht's been the test platform. It shows the above steps on its two sections, and also the sections' summation.
Meas 1 and 2 are original measurement before IR windows, in case they are needed too.

I should add that what started all this was a quick try on the coax CD, and getting excellent acoustic measurements.
So for me it really is about finding best practice, I know it works for real :)
 

Attachments

  • HF anf VHF IR start 4128 samples.mdat
    8.1 MB · Views: 100

John Mulcahy

REW Author
Joined
Apr 3, 2017
Messages
7,212
Sounds plausible, assuming you can keep room effects out of your measurements with appropriate measurement and windowing. FDW might help with that. The "Offset t=0" controls let you look at phase as t=0 is adjusted, if you use the left/right arrow keys the offset can be adjusted in 1 us increments.
 

Mark Wilkinson

Registered
Thread Starter
Joined
Jun 9, 2017
Messages
10
Thank you sir !
Yes, my measurements are quasi-anechoic, best as I can achieve taken outside.
Speaker building is the hobby...gave up on rooms along time ago lol

Good to learn about the "Offset t=0" control, and its 1 us increment.
I wish my processor worked at 96kHz for such fine phase control. I get caught halfway between samples sometimes, crossing at 6.3kHz and @ 48k sampling.
I know it doesn't matter soundwise, it takes a couple of samples off center to easily hear a change in pink.
But gotta love precision.
Align IR Start before and after Trace Arithmetic is so far giving the best repeatable precision with these FIR making experiments.


May I make a feature request....the ability to define IR Windows Left and Right sizes in terms of samples?
 

Mark Wilkinson

Registered
Thread Starter
Joined
Jun 9, 2017
Messages
10
It's to more easily choose an export length.
And to get past the Right Window rounding inputs to the integer.
 

John Mulcahy

REW Author
Joined
Apr 3, 2017
Messages
7,212
The window reference time (and t = 0 for that matter) are not restricted to sample boundaries, so I'm not sure there would be any benefit to window widths in samples. I'll add an extra decimal place for window widths below 100 ms though.
 

Mark Wilkinson

Registered
Thread Starter
Joined
Jun 9, 2017
Messages
10
Thank you, that will help when trying out FIR files meant to replicate IIR, when I want to start Left window near 0.
I've been using 0.1ms Left window with success, but having trouble with Left set to 0. I figure I'm missing something still...
 

Mark Wilkinson

Registered
Thread Starter
Joined
Jun 9, 2017
Messages
10
Thank you, that will help when trying out FIR files meant to replicate IIR, when I want to start Left window near 0.
I've been using 0.1ms Left window with success, but having trouble with Left set to 0. I figure I'm missing something still...

Take it back. I can't begin to get anything usable with a small left window. Had files confused...my bad.
Linear phase, windows equal is all i've made work so far...
 

John Mulcahy

REW Author
Joined
Apr 3, 2017
Messages
7,212
If you want examples of IIR filter responses set up the filters in the EQ window and use the File menu option to export the filter IR.
 

Mark Wilkinson

Registered
Thread Starter
Joined
Jun 9, 2017
Messages
10
Thanks. Yes, I'm familiar with EQ filter export.
Sorry for lack of clarity at what I'm hoping to accomplish.

The inverse impulse multiplied by a xover gives a near perfect flat mag and flat phase correction, using a total window of 86ms or 4128 taps, split 43ms Left and 43ms Right.
I'm very excited with this easy to make linear phase correction. And I see how adding FDW in the export can tame over correction, and that EQ's can be added as well.
This makes for a pretty powerful linear phase FIR filter.

I was hoping to use FIR with a 1ms Left and 85ms Right windows, to mimic IIR correction without latency, eventually trying to achieve flat mag and minimum phase with the same sized file.

The attached capture shows the two inverse plus xover curves. Brown (43/43) provides spot on linear phase correction. Green (1/85) dunno what's going on.

Oh, one maybe bug. When I try to export an impulse as Minimum Phase, an error message appears saying "no minimum phase version to export, please generate it"

HF INV LEFT window compare.jpg
 

John Mulcahy

REW Author
Joined
Apr 3, 2017
Messages
7,212
Oh, one maybe bug. When I try to export an impulse as Minimum Phase, an error message appears saying "no minimum phase version to export, please generate it"
I have fixed that for the next beta.

Just windowing the IR won't give you an IIR equivalent, you need to create a minimum phase version of it first. To work around the bug you can use the "Minimum phase version" Measurement action on the All SPL graph and export that IR, which can have a zero left hand window if desired since it is purely causal.
 

manton

Registered
Joined
Aug 21, 2022
Messages
4
Is there an official guide on how to generate FIR's using REW? I understand some of the OP, but not all of it and it seems it requires some further knowledge and the use of other software. I'm not having much success. Can this be all done in REW?

I also seem to have " Align IR start all traces " missing from the All SPL graph controls. I'm pretty sure I have seen the button somewhere before. It does have "Align IR start" so was this text changed in an update perhaps?
 

John Mulcahy

REW Author
Joined
Apr 3, 2017
Messages
7,212
Is there an official guide on how to generate FIR's using REW?
Not that I'm aware of. There is a big rePhase thread on diyAudio covering FIR filters.

I also seem to have " Align IR start all traces " missing from the All SPL graph controls. I'm pretty sure I have seen the button somewhere before. It does have "Align IR start" so was this text changed in an update perhaps?
The Align IR Start button applies to all traces that are selected at the time it is pressed, per the heading "Actions for all selected measurements" above it.
 

manton

Registered
Joined
Aug 21, 2022
Messages
4
The Align IR Start button applies to all traces that are selected at the time it is pressed, per the heading "Actions for all selected measurements" above it.

Ok I thought this might be the case, but wanted to check. Thank you John.
 
Top Bottom