# Decimation Question about using a low pass filter before downsampling

I have a bunch of audio files that have a sample rate of 380kHz, however I would like to reduce this sampling rate to 44.1kHz. From doing some research online, it seems like I will have to use a low pass filter in order to avoid aliasing before I downsample.

I am using python and thinking of using the butter_lowpass_filter. However, I am confused as to what my cutting frequency would need to be and also how much I will need to decrease my sampling rate in the downsampling step.

Any help would be appreciated!

Your digital signal is originally sampled at $$380KHz$$ and you want to downsample it to sampling rate $$44KHz$$. Therefore, you will require fractional sampling rate change. You cannot just downsample to $$44KHz$$ because $$\frac{380}{44}$$ is not an integer.

First upsample by a factor of $$11$$ and then downsample by a factor of $$95$$ to reach your goal. Since you might be knowing upsampling by $$L$$ is followed by LowPass Filter with cut-off freq of $$\omega = \frac{\pi}{L}$$ and for downsampling by a factor $$M$$ we need to first LowPass Filter of cut-off $$\omega = \frac{\pi}{M}$$. These two Low Pass Filtering operation can be clubbed into one. And you can low-Pass filter with cut-off frequency $$Min \{\frac{\pi}{L}, \frac{\pi}{M} \}$$.

So, to reach your goal of fractional downsampling by a factor of $$\frac{95}{11}$$, upsample by a factor of $$11$$, LowPass Filter with Cut-off frequency $$\omega = \frac{\pi}{95}$$ and then downsample by a factor of $$95$$.

Interpolation sampling frequency will be the new $$44KHz$$. You will retain all frequency component of the original signal till $$22KHz$$ assuming ideal LPF. With finite order Butterworth LPF, there will be some non-zero transition band which will give a roll-off in the transition band of LPF.

• I assume he means 44.1 kHz.. and no, you cannot retain the original signal up to 22kHz, certainly not in any practical implementation – Hilmar Jun 26 at 12:13
• @Hilmar Yeah 44.1KHz is generally what is used, but the OP will get the idea how to do the fractional sampling rate change, I guess from above example. Question said about 44KHz and there is nothing wrong with that. I donot mean to overwhelm the OP with all the implications that practical LPF will bring (sensing from the level of difficulty of original question). Again that is my personal opinion. I think the OP will learn deeper concepts as and when required. Agreed that practically we will have non-zero transition band and non-flat pass band of finite order LPF. Let me add that info. – DSP Rookie Jun 26 at 12:22
• Yeah I meant 44.1kHz! Thanks – Sam Jun 26 at 18:00
• Why are we not able to downsample with a non integer? – Sam Jun 26 at 18:01
• Of course can downsample and upsample by non integers and sample rate convert by non-integer ratios. It's just more work and not pretty, that's why most text books skip over it :-) – Hilmar Jun 26 at 18:30

Sample rate conversation is easy in theory but tricky in practice.

Assuming you want to convert to the standard rate of 44.1 kHz (not 44 kHz), you have an awkward conversion ratio. $$3800 =2^3 \cdot 5^2 \cdot 19$$ and $$441 = 3^2 \cdot 7^2$$ are mutually prime that means that rational sample rate conversion is impractical,so you need irrational sample rate conversion. If you do not need 44.1 kHz exactly you can use $$69/8 \rightarrow 44058Hz$$ or $$112/13 \rightarrow 44107Hz$$

In either case you need a low pass filter. The choice of the filter depends A LOT on your specific application. Specifically

• How much energy is above 20 kHz. There really shouldn't be a lot but you don't know before you look. If there is a lot above 40 kHz you can perhaps pre-filter this out before doing the actual conversion
• What amount of aliasing and signal to noise can you tolerate.
• Do you care more about preserving transients in the time domain or an accurate phase spectrum
• Up to which frequency do you have to meet your requirements. Designing a converter that's good up to 20 kHz is a LOT harder than designing one that's good up to 18 kHz. Don't even try to go up to 22 kHz.
• Do you care about latency, memory consumption and/or execution time.

The "art" of building a good sample rate converter is to really understand your requirements and trade-offs and then optimize the filter design for your specific case.

A bunch of "generic" hints for audio

• Polyphase FIR filter is typically a good choice and a good trade off between time smearing and phase preservation
• 32 taps, 64 phases gets you around 90-100 dB SNR at 18 kHz and much better below.
• If you need to do irrational sample rate conversion, do linear interpolation between the phases.
• You have a conversation factor that is "far away" from unity. In this case, it's probably best to convert this in multiple steps and not in one go. Maybe from 380->95 (down by 4) and then from 95->44.1