FIR Filter Resampling
Sometimes it’s necessary to change the sample rate of a FIR filter for a new DSP that has a different sample rate. This tutorial explains how to use FIR Designer to upsample an existing FIR filter from 48 kHz to 96 kHz. The same technique can be used for downsampling. (In the future may offer a simplified FIR conversion process that doesn’t require using the FIR Designer filter design workflow, described below.)
Although we’re using FIR Designer, the same approach works with FIR Designer M, FIR Creator EX and FIR Creator.
Step 1: Start FIR Designer
Start FIR Designer and set the ‘Design sample rate’ to match the sample rate of the existing FIR filter – in this example, 48 kHz. This is important since the FIR filter we will be loading is a TXT file with only raw filter coefficients and no sample rate metadata. (When loading other non-TXT and non-CSV file formats that do have sample rate metadata, the sample rate in the file is used.)
Step 2: Load the existing FIR filter to the Target tab
On the ‘Target’ tab, select ‘File’ then press ‘Load’ and select the FIR filter. The filter response appears on the plots.
Ensure that ‘Use:’ ‘Magnitude only’ and ‘Phase only’ are unchecked. (We want to use both the magnitude and the phase for the target response.)
Also, under ‘Curve’, ‘Mag’ and ‘Phase’, uncheck each of the ‘Use’ checkboxes. With these off, the ‘File’ is the only response that us used as the target response.
Step 3: Remove excess phase from the target response
This plot shows the original FIR filter impulse response. Note that the maximum magnitude sample is at approximately sample 85 (at 48 kHz), and in the negative direction.
Firstly, change the ‘Design sample rate’ to the new sample rate; in this example, 96 kHz.
Secondly, check ‘Flip polarity’ (to find the negative peak), press ‘Find Peak’, then uncheck ‘Flip polarity’. The plots now show the excess phase gone. The impulse response of the FIR filter has been time aligned so that time=0 matches the largest magnitude sample peak location of the FIR filter.
Note that ‘Delay: samples’ of -170 is in reference to the new sample rate of 96 kHz, which matches -85 samples at the original sample rate of 48 kHz.
Step 4: Designing the new FIR filter
Now that the original 48 kHz FIR filter is loaded as the Target response, we need to design a new FIR filter that matches the Target response.
On the ‘FIR Magnitude Adjust’ tab, add filters to match the Target response at the lowest and highest frequencies of interest. (The middle of the response will be dealt with later in the Auto tabs.)
On the ‘FIR Phase Adjust’ tab, add filters to match the Target response phase at the lowest and highest frequencies of interest. (The middle of the response will be dealt with later in the Auto tabs.)
On the ‘FIR Auto Mag’ tab, set a mag correction band for the frequency range of interest – here approximately 18 Hz to 22 kHz – and set the smoothing to either ‘None’ or ’48th’. Also set the ‘Phase: to ‘Linear’ so that this tab won’t push the phase away from what was set on the ‘FIR Phase Adjust’ tab.
On the ‘FIR Auto Phase’ tab, set a phase correction band for the frequency range of interest – here approximately 16 Hz to 22 kHz.
Note how both the magnitude and phase now match the target response!
Step 5: Export the new FIR filter
On the ‘Export’ tab, set the filter delay and filter length.
Here we have set the delay to 170 samples (at 96 kHz) or 1.7708 ms, which matches the time delay of the original FIR filter. Here we have also set the filter length to 768 samples (at 96 kHz) or 8 ms, which matches the length, in milliseconds, of the original FIR filter.
The ‘Total Error’ section shows the difference between the original FIR filter and this new FIR filter; a maximum of only 0.3 dB and 2.2 degrees.
Now select ‘Export’, choose a file format and press ‘Save’ ‘FIR’.