• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required as is 20 years of participation in forums (not all true). There are daily reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Aliasing, imaging and upsampling a real example.

Blumlein 88

Grand Contributor
Forum Donor
Joined
Feb 23, 2016
Messages
16,369
Likes
28,153
A couple of clarifications.

Aliasing is when content above the Nyquist frequency (half the sampling rate) is folded back down into the recording by an ADC.

Imaging is when content below the Nyquist frequency shows up mirror imaged above the Nyquist frequency during playback by a DAC.

So what effect does upsampling have on these if any?

Using a Topping D10 balanced I played wideband white noise at a 384 khz sample rate into an RME Babyface Pro FS ADC at 48 khz. The noise was flat to at least 80 khz and likely well past 100 khz.

So next I played the 48 khz recording into the ADC capturing the result at 192 khz so we can see what is going on. I repeated this by upsamling that same file to 384 khz and playing it back.

A 132k FFT covering 96 khz. Red is the 48 khz file played at its native 48 khz, and Blue is the upsampling of the same file. Upsampling used a sharper filter with a quicker cut-off of the above Nyquist frequencies.

1657685596200.png

Next I created a file with a high level tone at 20 khz and one 10 db lower at 25.5 khz. The file was 384 khz sample rate and recorded by the ADC at 48 khz. The graph is of this file played back at its native 48 khz in Red and Green is the noise floor of the ADC.

You see the 25.5 khz tone aliasing back down to 22.5 khz. 25,500 hz is 1500 hz above 24,000 Nyquist frequency and gets reflected down to 22,500 hz as an alias. Note the aliased tone is only about 15 db lower than its original level. A sharper filter would have reduced this more or eliminated it. There is also a small amount of IMD distortion from the 20 khz and 25.5 khz tone showing up at 14.5 khz. There is some imaging of the 20 khz tone reflected upward to 28 khz. Then you see the 2nd and 3rd harmonic from simple analog distortion of the analog output stage. Plus some leakage of the 25.5 khz tone which was not filtered out. The IMD and Aliasing are now baked into the recording and no post filtering or upsampling will remove them.

1657688095529.png


Next I upsampled the same file to 384 khz. Upsampled signal in Blue and green is the ADC noise floor. You still see the Aliasing and IMD as it has been recorded into the file and no post filtering or upsampling will remove it. Upsampling with Sox via Audacity did filter above Nyquist more steeply as already shown by the white noise profiles. As a result the leakage of the 25.5 khz tone is gone. The imaging of the 20 khz tone above Nyquist is gone as well. Harmonic distortion remains as that is an analog by product of the output stage.
1657687942904.png
 

Attachments

  • 1657687177867.png
    1657687177867.png
    54.8 KB · Views: 29
  • 1657687600630.png
    1657687600630.png
    49.6 KB · Views: 32
Last edited:

bennetng

Major Contributor
Joined
Nov 15, 2017
Messages
1,563
Likes
1,578
Another method to illustrate the phenomenon is using a sweep to show the frequency relationship.
https://www.audiosciencereview.com/forum/index.php?threads/interface-mystery.13115/post-392905
My illustration above is only about aliasing, not imaging.

Yet another more complicated scenario is non-integer resampling ratio, with poor algorithms artifacts will reflect and spread all over the place.

However, I believe only very few people have read the FAQ section:
This part explains the methodology, with a set of test signals which you can try with your own software/hardware.
 
OP
Blumlein 88

Blumlein 88

Grand Contributor
Forum Donor
Joined
Feb 23, 2016
Messages
16,369
Likes
28,153
Another method to illustrate the phenomenon is using a sweep to show the frequency relationship.
https://www.audiosciencereview.com/forum/index.php?threads/interface-mystery.13115/post-392905
My illustration above is only about aliasing, not imaging.

Yet another more complicated scenario is non-integer resampling ratio, with poor algorithms artifacts will reflect and spread all over the place.

However, I believe only very few people have read the FAQ section:
This part explains the methodology, with a set of test signals which you can try with your own software/hardware.
Yes, I actually prefer doing the sweep with those type displays. When I've used them in the past in some posts it seems many people aren't sure what they are seeing. I like showing harmonic distortion that way too. Another way I like is running a real time FFT and doing a sweep recorded as a video. You can see the aliasing, imaging and distortion dance across the frequency display as the sweep moves. Music scope makes this rather easy to do though other softwares do it as well.

At least with Sox I think I've tried non-integer upsampling, and it doesn't make any difference, but Sox is quite good at this. Maybe only iZotope is better. Quite a few resamplers/upsamplers are full of artifacts.

Here is one of a single tone and dual tone sweep of a Marantz 7701 pre/pro. Floor of the spectrogram was -120 dbFS. Jitter, spurious tones, distortion and a little aliasing are in it. The Topping D10 balanced will do the same thing almost completely clean. This display can be very informative if you select the sweep rate and the FFT size correctly. I've found it confuses more than it helps most of the time according to people's comments.

index.php


Same test with same gear, but displayed with -100 dbFS as the floor of the spectrogram. So it looks much cleaner, and tells you most of the junk is below that -100 dbFS level.
index.php
 
Last edited:
OP
Blumlein 88

Blumlein 88

Grand Contributor
Forum Donor
Joined
Feb 23, 2016
Messages
16,369
Likes
28,153
Some might also be interested in this post of mine from 4 years ago in regards to aliasing.

 

tifune

Addicted to Fun and Learning
Forum Donor
Joined
Jan 18, 2020
Messages
893
Likes
590
One thing I've never understood: why does this happen in the first place? Especially with advancements in processing power, why isn't anything above Nyquist simply discarded rather than folded back in?
 

BeerBear

Active Member
Joined
Mar 9, 2020
Messages
136
Likes
137
One thing I've never understood: why does this happen in the first place? Especially with advancements in processing power, why isn't anything above Nyquist simply discarded rather than folded back in?
Mostly because a steep filter requires more taps and more taps = higher latency (audio delay). That's mathematically/physically unavoidable, from what I've read (but I don't have the required education to explain this).
And higher latency is in some cases undesirable, even though it's not really a problem for music listening. So you're free to upsample and use steep filters there.

And, if latency is a concern during production, you can avoid aliasing in the audible range by simply recording at a higher sample rate, like 88.2 or 96kHz. After that you can convert it to 44.1kHz with a good offline SRC that doesn't cause aliasing.
 

mansr

Major Contributor
Joined
Oct 5, 2018
Messages
4,690
Likes
10,539
Location
Hampshire
Mostly because a steep filter requires more taps and more taps = higher latency (audio delay). That's mathematically/physically unavoidable, from what I've read (but I don't have the required education to explain this).
And higher latency is in some cases undesirable, even though it's not really a problem for music listening. So you're free to upsample and use steep filters there.

And, if latency is a concern during production, you can avoid aliasing in the audible range by simply recording at a higher sample rate, like 88.2 or 96kHz. After that you can convert it to 44.1kHz with a good offline SRC that doesn't cause aliasing.
That, and because ADCs and DACs are already as good as they need to be with a healthy margin.
 

BeerBear

Active Member
Joined
Mar 9, 2020
Messages
136
Likes
137
That, and because ADCs and DACs are already as good as they need to be with a healthy margin.
I'm not so sure about healthy margins, at least for recording at 44.1/48k. Keep in mind that recordings usually get amplified/compressed, and sometimes the pitch gets lowered too, which can make ultrasonics audible. It's probably fine in most cases, but to play it safe it's better to keep the recordings free of artifacts.
 

bennetng

Major Contributor
Joined
Nov 15, 2017
Messages
1,563
Likes
1,578
sometimes the pitch gets lowered too
I suppose you meant some of the sampler/Melodyne types of post-processing.

One thing I found interesting is that ADC chips often have high pass filters to deal with DC, and the filter is proportional to sample rate, which means the higher the sample rate, the more the lowet frequencies will be attenuated too. Usually it is inconsequential as the filter is operating at single digit Hz, albeit the transition curve may extend to more than 10Hz or so. Some chips for example AK557x will have the high pass filter deactivated when the recording sample rate is higher than 192kHz, perhaps to avoid the high pass filter affecting the lowest frequencies. However, does it mean it will get trouble when recording sources with high DC offset?
 

bennetng

Major Contributor
Joined
Nov 15, 2017
Messages
1,563
Likes
1,578
Yes, I actually prefer doing the sweep with those type displays. When I've used them in the past in some posts it seems many people aren't sure what they are seeing.
I guess many people only understand Amir's highly annotated graphs and probably affected by the annotations more than the graphs.

At least with Sox I think I've tried non-integer upsampling, and it doesn't make any difference, but Sox is quite good at this. Maybe only iZotope is better.
SoX resamplers in Audacity and foobar2000 may slightly fall behind the iZotope ones due to the export format (32-bit float) when using that silly 180dB range. Perhaps the command line version of SoX when exported to 32-bit integer with rate -u (undocumented highest quality settings that mansr told me earlier) will get everything below that website's measurement threshold.
 
OP
Blumlein 88

Blumlein 88

Grand Contributor
Forum Donor
Joined
Feb 23, 2016
Messages
16,369
Likes
28,153
I guess many people only understand Amir's highly annotated graphs and probably affected by the annotations more than the graphs.


SoX resamplers in Audacity and foobar2000 may slightly fall behind the iZotope ones due to the export format (32-bit float) when using that silly 180dB range. Perhaps the command line version of SoX when exported to 32-bit integer with rate -u (undocumented highest quality settings that mansr told me earlier) will get everything below that website's measurement threshold.
Just the slightest noise just above the -180 db in Audacity vs the best iZotope version. The other iZotope versions aren't as good or better than default in Audacity. The main difference seems to be iZotope with no alias is steeper in the cut-off region. In command line you can alter that about Sox and likely match results. Even if you cannot quite match results we are down to very tiny differences.
1657743968889.png
 

danadam

Addicted to Fun and Learning
Joined
Jan 20, 2017
Messages
681
Likes
990
I played with that in sox (audio files in attachment).
Aliasing:
  1. generate 3800 Hz and 4300 Hz tones at 48 kHz sampling rate
  2. downsample to 8 kHz by only picking every 6th sample using "downsample" command -> creates aliasing
  3. downsample to 8 kHz by lowpass filtering and only then picking every 6th sample -> no aliasing
  4. downsample to 8 kHz using "rate" command to compare
Code:
sox -r48k -n -b8 "1_input.48k.wav" \
    synth 10 sin 3800 sin 4300 \
    remix 1-2 \
    norm -6
sox "1_input.48k.wav" -r8k "2_alias.8k.wav" \
    downsample 6
sox "1_input.48k.wav" -r8k "3_noalias.8k.wav" \
    sinc -3900 -t 200 \
    downsample 6
sox "1_input.48k.wav" "4_rate.8k.wav" rate 8k
1_input.48k.png

2_alias.8k.png

3_noalias.8k.png

4_rate.8k.png


Imaging:
  1. take the "3_noalias.8k.wav" produced above
  2. upsample to 48 kHz by only inserting zero samples between existing samples using "upsample" command -> creates images
  3. upsample to 48 kHz by inserting zero samples and then lowpass filtering -> no images
  4. upsample to 48 kHz using "rate" command to compare (you can notice the difference in gain)
Code:
sox "3_noalias.8k.wav" -r48k "5_imaging.48k.wav" \
    upsample 6
sox "3_noalias.8k.wav" -r48k "6_noimaging.48k.wav" \
    upsample 6 \
    sinc -3900 -t 200
sox "3_noalias.8k.wav" "7_rate.48k.wav" rate 48k
5_a.8k.png

5_imaging.48k.png

6_noimaging.48k.png

7_rate.48k.png
 

Attachments

  • aliasing_and_imaging.zip
    563.7 KB · Views: 14

MC_RME

Addicted to Fun and Learning
Technical Expert
Manufacturer
Joined
May 15, 2019
Messages
667
Likes
2,823
One thing I found interesting is that ADC chips often have high pass filters to deal with DC, and the filter is proportional to sample rate, which means the higher the sample rate, the more the lowet frequencies will be attenuated too. Usually it is inconsequential as the filter is operating at single digit Hz, albeit the transition curve may extend to more than 10Hz or so. Some chips for example AK557x will have the high pass filter deactivated when the recording sample rate is higher than 192kHz, perhaps to avoid the high pass filter affecting the lowest frequencies. However, does it mean it will get trouble when recording sources with high DC offset?
No, as the circuit will have capacitors at the input to remove any external DC. The DC filter within the chip removes DC offset from the input electronics as well as from the AD chips internal design - they usually have a fixed, intentional offset to minimize conversion errors. With the AK557x that is a whopping -33 dBFS. That's why the ADI-2 Pro has an additional digital DC filter in FPGA that also works at highest sample rates. And as that one won't work in DSD mode we also adjust the input offset manually in the factory via old style trim pot technique to minimum. That works so good that you basically don't need any DC filter anymore. Which then leads to the latest firmwares where AD DC filters can be switched off optionally.
 

bennetng

Major Contributor
Joined
Nov 15, 2017
Messages
1,563
Likes
1,578
For those who are not comfortable with command line, I made a drag and drop SoX spectrogram script for Windows, with sensitivity higher than the Infinite Wave website:
 

pma

Major Contributor
Joined
Feb 23, 2019
Messages
3,296
Likes
6,862
Location
Prague
IMO certain level of aliasing is a fact in every ADC, as the filters are never ideal. This is a brief test of E1DA Cosmos ADC, set at 96 kHz sampling rate. Input signal is from analog sine generator, at about -7dBFS ADC input level. 40kHz, 60kHz and 100kHz input sine frequencies. Do not look at noise bottom modulation, it is because of the sine generator and it is unimportant. One can see that the 60kHz created 36kHz alias and 100kHz created 4kHz alias, as expected. All low in level. Input ADC level kept constant.

Note: Arta RMS readings in plots #2 and #3 are incorrect.

E1DA_ADC_40kHz.png


E1DA_ADC_60kHz.png


E1DA_ADC_100kHz.png
 
OP
Blumlein 88

Blumlein 88

Grand Contributor
Forum Donor
Joined
Feb 23, 2016
Messages
16,369
Likes
28,153
@pma Can you show us -4db white noise with the Cosmos running at least half the sample rate as the source of the noise? This lets us see the shape of the filter.
 

pma

Major Contributor
Joined
Feb 23, 2019
Messages
3,296
Likes
6,862
Location
Prague
@pma Can you show us -4db white noise with the Cosmos running at least half the sample rate as the source of the noise? This lets us see the shape of the filter.

Something close to your request as I could have generated. Remember that Arta would show nothing above 48kHz if sampling was 96kHz.
E1DA_ADC_inputwhite.png
 

AudioSceptic

Major Contributor
Joined
Jul 31, 2019
Messages
2,164
Likes
1,999
Location
Northampton, UK
A couple of clarifications.

Aliasing is when content above the Nyquist frequency (half the sampling rate) is folded back down into the recording by an ADC.

Imaging is when content below the Nyquist frequency shows up mirror imaged above the Nyquist frequency during playback by a DAC.

So what effect does upsampling have on these if any?

Using a Topping D10 balanced I played wideband white noise at a 384 khz sample rate into an RME Babyface Pro FS ADC at 48 khz. The noise was flat to at least 80 khz and likely well past 100 khz.

So next I played the 48 khz recording into the ADC capturing the result at 192 khz so we can see what is going on. I repeated this by upsamling that same file to 384 khz and playing it back.

A 132k FFT covering 96 khz. Red is the 48 khz file played at its native 48 khz, and Blue is the upsampling of the same file. Upsampling used a sharper filter with a quicker cut-off of the above Nyquist frequencies.

View attachment 218026
Next I created a file with a high level tone at 20 khz and one 10 db lower at 25.5 khz. The file was 384 khz sample rate and recorded by the ADC at 48 khz. The graph is of this file played back at its native 48 khz in Red and Green is the noise floor of the ADC.

You see the 25.5 khz tone aliasing back down to 22.5 khz. 25,500 hz is 1500 hz above 24,000 Nyquist frequency and gets reflected down to 22,500 hz as an alias. Note the aliased tone is only about 15 db lower than its original level. A sharper filter would have reduced this more or eliminated it. There is also a small amount of IMD distortion from the 20 khz and 25.5 khz tone showing up at 14.5 khz. There is some imaging of the 20 khz tone reflected upward to 28 khz. Then you see the 2nd and 3rd harmonic from simple analog distortion of the analog output stage. Plus some leakage of the 25.5 khz tone which was not filtered out. The IMD and Aliasing are now baked into the recording and no post filtering or upsampling will remove them.

View attachment 218030

Next I upsampled the same file to 384 khz. Upsampled signal in Blue and green is the ADC noise floor. You still see the Aliasing and IMD as it has been recorded into the file and no post filtering or upsampling will remove it. Upsampling with Sox via Audacity did filter above Nyquist more steeply as already shown by the white noise profiles. As a result the leakage of the 25.5 khz tone is gone. The imaging of the 20 khz tone above Nyquist is gone as well. Harmonic distortion remains as that is an analog by product of the output stage.
View attachment 218029
This is just the sort of thing I need to try and understand this stuff.

I can understand that we need to avoid aliases during the ADC process, because they not only pollute the audible range, but will also cause IMD. When it comes to potential images created during the DAC process, if they only occur *above* Nyquist, does that matter? They will waste a bit of power further down the chain, but will be inaudible anyway. I thought that a proper brick wall filter was essential in the DAC, but am I wrong to think that?
 
Top Bottom