• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Rules of Thumb about Resampling

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
Resampling methods are not all created equal. Some are better than others. By "better" I mean correct mathematically, precise numerically, and transparent perceptually. Without getting into the details, can we establish some pragmatic rules of thumb?

Here's a first draft strawman to throw darts at:
1. Avoid resampling if possible.
2. If you must resample, use integer multiples, as they are computationally simpler and perceptually more transparent.
3. All else equal, upsampling is more transparent than downsampling.

For example: if the source is 88.2 kHz:
1. Listen at 88.2 if possible (no resampling).
2. If you must resample, better to downsample to 44.1 (integer multiple) than upsample to 96 (or worse, downsample to 48).
 

Tks

Major Contributor
Joined
Apr 1, 2019
Messages
3,221
Likes
5,497
Was there contention about this somewhere on the web?
 
OP
MRC01

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
I'm sure there was, and is, generally speaking. But I wasn't thinking of that. I was thinking about discussion threads here. Occasionally, people say they hear differences in sampling rates and the ensuing discussion reveals that whatever they heard were artifacts caused by resampling. JJ had an interesting and educational presentation on this topic. But that is quite in-depth with math, could scare away people who are just looking for practical rules of thumb they can follow.

In light of that, it seems that some practical rules of thumb about resampling would be useful.
 

mansr

Major Contributor
Joined
Oct 5, 2018
Messages
4,685
Likes
10,705
Location
Hampshire
If you must resample, use integer multiples, as they are computationally simpler and perceptually more transparent.
Simpler, yes, but what makes you say it is "more transparent"? The result can be made as numerically accurate as one desires.
 
OP
MRC01

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
I thought resampling at integer multiples obviates the need to interpolate inter-sample values. Put differently, any time you're resampling to a rate that is not an integer multiple, you must predict or guess inter-sample values.
Not true?
 

mansr

Major Contributor
Joined
Oct 5, 2018
Messages
4,685
Likes
10,705
Location
Hampshire
I thought resampling at integer multiples obviates the need to interpolate inter-sample values. Put differently, any time you're resampling to a rate that is not an integer multiple, you must predict or guess inter-sample values.
Not true?
With any realistic filter, all the samples have to be recalculated, even those that coincide in time with the input.
 
OP
MRC01

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
So resampling to integer multiples can't simply add (pad with) 0-value samples then low pass filter the result?
If not, and all realistic filters must recalculate samples, what makes resampling at integer multiples more efficient?
 
Last edited:

mansr

Major Contributor
Joined
Oct 5, 2018
Messages
4,685
Likes
10,705
Location
Hampshire
So resampling to integer multiples can't simply add 0 samples then low pass filter the result?
What do you think the low-pass filter does to the original sample values?

If not, and all realistic filters must recalculate samples, what makes resampling at integer multiples more efficient?
If you're using a poly-phase filter bank, integer ratios result in only one phase being present. FFT based resampling is also simplified somewhat.
 

Lambda

Major Contributor
Joined
Mar 22, 2020
Messages
1,791
Likes
1,525
1. Avoid resampling if possible.
No. Most modern DACs over sample anyways, you can do it more "precise numerically, and transparent perceptually." with more computation power and time.

2. If you must resample, use integer multiples, as they are computationally simpler and perceptually more transparent.
maybe computationally simpler... but not "more transparent" by default.

All else equal, upsampling is more transparent than downsampling.
Yes. Upsampling Can cause imaging but downsampling can cause Aliasing.
 
OP
MRC01

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
What do you think the low-pass filter does to the original sample values? ...
I think I understand your point. There are 2 parts to oversampling:
Part 1: add new samples to match the new sample rate
Part 2: apply a low-pass filter
Oversampling by integer multiples simplifies part 1, since you can pad with 0 values and don't have to interpolate.
But you still have computation to do with part 2.
 
OP
MRC01

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
No. [don't bother to avoid resampling] Most modern DACs over sample anyways, you can do it more "precise numerically, and transparent perceptually." with more computation power and time. ...
Let me give a practical example to see if I understand your point. Suppose you want to play a 44-16 audio stream from your computer connected to an external DAC. You have 2 options:
1. Feed the 44-16 data directly to your DAC, which happens to oversample it 4x internally before converting.
2. Oversample it 4x on the PC, then send the oversampled 176.4-16 data to the DAC.

Which would be "better" depends on the oversampling algorithms used by the DAC and the PC. The point is, you can't avoid resampling (at least, not integer ratio oversampling). It's gonna happen. The only question is exactly where and how.
 

Lambda

Major Contributor
Joined
Mar 22, 2020
Messages
1,791
Likes
1,525
J
Let me give a practical example to see if I understand your point. Suppose you want to play a 44-16 audio stream from your computer connected to an external DAC. You have 2 options:
1. Feed the 44-16 data directly to your DAC, which happens to oversample it 4x internally before converting.
2. Oversample it 4x on the PC, then send the oversampled 176.4-16 data to the DAC.

Which would be "better" depends on the oversampling algorithms used by the DAC and the PC. The point is, you can't avoid resampling (at least, not integer ratio oversampling). It's gonna happen. The only question is exactly where and how.
Yes, exactly.
Some user in this forum strongly disagree with this, but i disagree with them.

He did some interesting experiments about up sampling with different filter types.
https://archimago.blogspot.com/2015/04/internet-blind-test-linear-vs-minimum.html
 

dc655321

Major Contributor
Joined
Mar 4, 2018
Messages
1,597
Likes
2,235
Some user in this forum strongly disagree with this, but i disagree with them.

If you're referring to me, I asked if you had evidence of a problem with your system that upsampling was fixing, or were you simply satisfying nervoses. No evidence was provided.

And again, I could not care less. Simply curious.
 

Aerith Gainsborough

Addicted to Fun and Learning
Joined
May 4, 2020
Messages
853
Likes
1,280
In light of that, it seems that some practical rules of thumb about resampling would be useful.
1) Avoid resampling if you are dependent on low latency for software instruments. (Learned that the hard way :D )
2) Don't give a hoot about stuff you can't hear anyway and just let the system do it's thing.
 
OP
MRC01

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
Another practical take-away: if you're listening on a computer using a tool like DSP that forces a single sample rate, what should you set that sample rate to? Options:

1. Set it to 44.1 k (or whatever most of your music uses), so it won't be resampled.
2. Set it to the highest integer multiple of the most common rate (like 176.4 k), so higher rate audio (48, 88.2, 96) won't be down-sampled.
3. Set it to the highest rate the system supports, even if it's not an integer multiple of the most common rate.

Intuition says use (2) or (3) because if you do (1), music at higher rates will be down-sampled.
What do you think?
 

Lambda

Major Contributor
Joined
Mar 22, 2020
Messages
1,791
Likes
1,525
2
I just set the highest sample rate my DAC supports and and let my DSP and sound server run at this frequency.
Now everything gets up sampled by sox before DSP processing and before it is send to the DAC
 

dc655321

Major Contributor
Joined
Mar 4, 2018
Messages
1,597
Likes
2,235
Intuition says use (2) or (3) because if you do (1), music at higher rates will be down-sampled.
What do you think?

(1), for the stated reason (bulk of music), but also because:

a) there is little musical information above 20kHz (unless you listen to keys jingling on repeat!),
b) my hearing has a bandwidth of 20kHz at best,
c) this rate provides a lower computational burden for any convolutional DSP in my processing stream,
d) i have some confidence that transparent resamplers are available (eg: soxr)
 
OP
MRC01

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,484
Likes
4,110
Location
Pacific Northwest
In the example above, if you follow option #1, it's ideal for most of your music. But any tracks you listen to having native rates above 44.1 (88.2, 96, whatever) will be down-sampled to 44.1.

However, if you follow rule #2 or #3 and set the rate to 176.4, then most of your music won't be any worse, because it oversamples by an integer multiple, which your DAC was doing already even in option #1. Resampling was always happening even in option #1, you've just shifted it to happen earlier. And any other tracks you listen to having higher native rates, will now be up-sampled rather than down-sampled.
 

mr.popo

Member
Joined
Apr 29, 2021
Messages
5
Likes
1
2
I just set the highest sample rate my DAC supports and and let my DSP and sound server run at this frequency.
Now everything gets up sampled by sox before DSP processing and before it is send to the DAC
Can you elaborate? Like how do you resample audio in real time with SoX?
e.g. I want to resample all my 96kHz songs down to 48kHz in real time within MusicBee (if possible).
 
Top Bottom