Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Understanding polyphase filtering for resampling (Read 17055 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Understanding polyphase filtering for resampling

Hello,

I have combed the net for explanations about resampling, polyphase filtering, etc. and already got some things clarified. What's missing is the final click, where everything finally makes sense. To help me with this, I want to ask some questions.

It is my understanding that to resample from, say, 44.1 kHz to 48 kHz, I would first interpolate to the least common multiple between the two, which would be 7.056 MHz. Interpolation is done by inserting zeros between the original samples ("zero-stuffing"). This is fast and keeps the information in the original frequency band intact.

Then, the data at 7.056 Mhz is low-pass filtered, using a cutoff frequency of 44.1kHz / 2 = 22.05kHz. The resulting signal is still sampled at 7.056MHz, but now contains no frequency higher than 22.05kHz. Now I can decimate this signal by simply reading every 7056/44.1 = 160th sample and forget about the others.

So far so good. However, this is all very wasteful. Using a FIR filter, it becomes apparent that many parts do not participate in the filtering, since they are zero. This is where - as far as I see it - polyphase filtering comes in. Allow me to bring up this article, which gives me an introduction to the polyphase filtering idea. It sounds good, but when thinking about it the way it is presented leaves me a bit unsure. For instance, in the part where it samples the 1/8 delayed samples (the red ones), I assume it means that the coefficients for these samples would contain a FIR lowpass filter with said delay? In other words, if I have N groups, each one having a different delay, then each group gets coefficients for FIR filters with corresponding delays?

To go back to the example in the article, this would mean that the coefficients c0, c8 ... would have a FIR lowpass filter with delay 1/8, coefficients c1, c9 ... would have a FIR lowpass filter with delay 2/8 etc. Is this at least remotely correct?

Also, if I conceptually put N zeros between the sample, then this means that the polyphase filter banks would have N-1 coefficients?

What I wonder is: why not just remove every part of the FIR convolution formula where the sample value would be zero? Why several coefficients in each filter bank? Is this for preserving the original signal's phase? And, -how- do I know which coefficient to take from each filter bank?


A second question stems from this comparison of sample rate conversion algorithms. Linear interpolation is condemned here. In practice, is it really this bad? I mean, for non-audiophile uses, say, MP3 playback, is it worth the effort to implement a polyphase filter?

Understanding polyphase filtering for resampling

Reply #1
A second question stems from this comparison of sample rate conversion algorithms. Linear interpolation is condemned here. In practice, is it really this bad? I mean, for non-audiophile uses, say, MP3 playback, is it worth the effort to implement a polyphase filter?

Take a look at "Ableton Live 7" or "Secret Rabbit Code 0.1.2 (Linear)" resamplers at http://src.infinitewave.ca/

Or take udial.wav and resample it to 48 kHz...

Understanding polyphase filtering for resampling

Reply #2
Linear interpolation is condemned here. In practice, is it really this bad? I mean, for non-audiophile uses, say, MP3 playback, is it worth the effort to implement a polyphase filter?


Its not great, but for real music it works well enough.  We use it in rockbox because we don't have a lot of CPU power available and I've had lots of people say that 96k flac files sound great, apparently unaware they're listening to a linearly interpolated 44.1khz version.

No reason to use it on a PC though.

Understanding polyphase filtering for resampling

Reply #3
Shame on me. For some reason, I overlooked this gem: http://www.dspguru.com/dsp/faqs/multirate/interpolation
now everything is clear. Sorry for the trouble!

Take a look at "Ableton Live 7" or "Secret Rabbit Code 0.1.2 (Linear)" resamplers at http://src.infinitewave.ca/

Or take udial.wav and resample it to 48 kHz...


To be fair, udial.wav is a rather extreme case, but I see your point. However, what about using linear interpolation for _up_sampling? Say, 44.1kHz to 48kHz? The comparison page only shows conversions from 96 to 48 kHz.

Its not great, but for real music it works well enough.  We use it in rockbox because we don't have a lot of CPU power available and I've had lots of people say that 96k flac files sound great, apparently unaware they're listening to a linearly interpolated 44.1khz version.

No reason to use it on a PC though.


Well, now that the polyphase stuff is no longer a mystery to me, I intend to use lerp only as an intermediate solution until other, bigger todos are done. I just have to make sure I do not listen to udial.wav on expensive speakers with volume at 100%

Understanding polyphase filtering for resampling

Reply #4
Linear interpolation is condemned here. In practice, is it really this bad? I mean, for non-audiophile uses, say, MP3 playback, is it worth the effort to implement a polyphase filter?


Its not great, but for real music it works well enough.  We use it in rockbox because we don't have a lot of CPU power available and I've had lots of people say that 96k flac files sound great, apparently unaware they're listening to a linearly interpolated 44.1khz version.

No reason to use it on a PC though.

Just out of curiosity, has anyone ever used cubic spline fitting for resampling? A bit more math than linear interpolation, but not that bad.

Understanding polyphase filtering for resampling

Reply #5
Linear interpolation is condemned here. In practice, is it really this bad? I mean, for non-audiophile uses, say, MP3 playback, is it worth the effort to implement a polyphase filter?


Its not great, but for real music it works well enough.  We use it in rockbox because we don't have a lot of CPU power available and I've had lots of people say that 96k flac files sound great, apparently unaware they're listening to a linearly interpolated 44.1khz version.

No reason to use it on a PC though.

Just out of curiosity, has anyone ever used cubic spline fitting for resampling? A bit more math than linear interpolation, but not that bad.


Labview supports it out of box.  I tried it, looked better then linear, but still had a lot of aliasing type artifacts with mid to high frequencies.  Probably not a bad compromise verses a multistep filter.

Understanding polyphase filtering for resampling

Reply #6
Linear interpolation is condemned here. In practice, is it really this bad? I mean, for non-audiophile uses, say, MP3 playback, is it worth the effort to implement a polyphase filter?


Its not great, but for real music it works well enough.  We use it in rockbox because we don't have a lot of CPU power available and I've had lots of people say that 96k flac files sound great, apparently unaware they're listening to a linearly interpolated 44.1khz version.

No reason to use it on a PC though.


For down-sampling from 96 kHz to 44.1, linear interpolation is probably not too bad, mostly because 1) the initial sampling rate is really high and 2) there's likely no contents above 20 kHz anyway (so no aliasing from that). On the other hand, there are other cases where it's simply awful. For example, upsampling from 8 kHz to 48 kHz produces really annoying metallic artefacts. So the level of annoyance depends on what you're doing, but in general, there's just no reason to do linear interpolation. There are ways to do quick resampling much better than that.

Understanding polyphase filtering for resampling

Reply #7
Its not great, but for real music it works well enough.  We use it in rockbox because we don't have a lot of CPU power available and I've had lots of people say that 96k flac files sound great, apparently unaware they're listening to a linearly interpolated 44.1khz version.


Interesting. I just tested my Samsung YP-R0 with sweep sine. It plays 44.1 kHz WAV file just fine, but uses some low-quality resampling for 48 kHz WAV.