• 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!

Sampling problem around multiple frequencies

scherbakov_al

Member
Joined
May 10, 2020
Messages
42
Likes
35
Location
Санкт-петербург
I tried an experiment. I generated a sinusoidal signal, the frequency of which ranged smoothly from 11999Hz to 12001Hz over 300 seconds. The sampling rate was 48000Hz. The bit depth is 32. I did this inside the Izotope program. I also did the same by connecting the balanced output of my S.M.S.L. M500 to Steinberg UR22C input. The result was the same. Here's what I got:

Снимок экрана 2021-09-18 в 18.22.05.png




It turned out that in the center the frequency is 12000Hz. But! Around you can see how the signal level changes in 3 dB. Those. it turns out that a frequency that is close enough to multiples of the sampling rate will experience distortion in amplitude. And the level analyzer confirms this - the level "jumps" during playback. If you do the same thing, but at a sampling rate of 192000Hz, the result is as follows:

Снимок экрана 2021-09-18 в 18.37.18.png



Is this really a problem? Can anyone check this with more accurate instrumentation? I understand that this is not a problem with my recorders. How do manufacturers of reproduction equipment struggle with this? Does this effect add a sense of "numbers"?
How to live now? After all, the signal received sufficient distortion half way to half the sampling frequency ...
 
Last edited:

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,708
Likes
5,978
Location
US East
You are seeing display artifacts from the program you use. Below is a chirp and its digital samples. If the program simply linearly interpolates the samples (dots, which are also probably downsampled) for display, you'll see a waveform with a fluctuating envelop.

In a properly designed DAC, the output is reconstructed using a much more precise interpolation filter, typically a sinc function. The reconstruction will be an (almost) exact copy of the original waveform.

chirp.png
 
Last edited:

DVDdoug

Major Contributor
Joined
May 27, 2021
Messages
3,016
Likes
3,966
Yes, this is "real". You'll get more dramatic results if you have a signal very-near the Nyquist limit (i.e. 22,049Hz at a 44.1kHz sample rate).

You can also get "interesting results" if you generate a sine "wave" exactly the Nyquist limit vs. a cosine. All the sines (at zero and 180 degrees) are zero so you get silence but cosines align with the peaks at 90 & 270 degrees.

In the real world I think what "saves us" is the complexity of real-world sound and the limitations of our hearing.

P.S.
If you generate a 3999Hz tone at 8kHz you can clearly hear the 1Hz modulation. At 1999Hz the modulation is less severe (3dB, I think) and I can't actually hear it but I can see it in the waveform and on a meter.
 
Last edited:

danadam

Addicted to Fun and Learning
Joined
Jan 20, 2017
Messages
981
Likes
1,523
These are not display artifacts because I deliberately made the file long enough (300 seconds) that it would not matter.
I don't see what that has to do with anything. Here's a 300 seconds sweep from 1999 to 2001 Hz sampled at 8 kHz generated by sox:
Code:
sox -r8k -c1 -n -b24 sweep.8k.wav synth 300 sin 1999:2001 norm -0.2
sweep.8k.png

Horrible, right? Let's simply resample the file to 48 kHz and see how it looks:
Code:
sox sweep.8k.wav sweep.48k.wav rate -v 48k
sweep.48k.png


Let's zoom in both files at that point where there is a dip:
sweep.zoom.png
So it is not a problem to reconstruct a "proper" waveform even from samples that don't look like it.
 
Last edited:

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,708
Likes
5,978
Location
US East
[Edit] The ripples in the waveform envelop were purely display artifacts. See post #17. Can't safely ignore the rest of this post. I got myself confused with the spectral ripples. Still need to understand what spectral ripples are and what they do.

The effect described by @scherbakov_al is real. It is not related to digital sampling, but is a property of the chirp signal itself. It is, I believe, known as spectral ripples.

I did some experiments with Mathematica to see it for myself, so no discrete sampling of the signal is used in the analysis.

The formula for a linear chirp is given in Wikipedia.

chirp wiki.PNG


I simplified the chirp formula in Wikipedia by set the phase ϕ to zero and removing the 2π. I then computed symbolically its Fourier Transform (FT). I plotted the magnitude of the FT for the case OP used (center frequency 12000 Hz, bandwidth 2 Hz, duration 300 s). You can see the ripples in the FT amplitude in the plot. Since for a chirp at any instant we have only one frequency, the signal amplitude fluctuates with time following to the ripples in the FT amplitude.

chirp spectrum.png


The ripple spacing and heights are strongly related to product of the duration T and bandwidth B (= T × B). A lower B*T will give stronger ripples. Below is the FT when B = 1000 Hz. You can see a substantially flat FT amplitude except at the start and end.

chirp3.PNG


This is the FT when B is 0.1 Hz (i.e. from 11999.95 Hz to 12000.05 Hz). The amplitude is not close to constant across the chirp frequency range and therefore the signal in time.

chirp4.PNG


References:
https://en.wikipedia.org/wiki/Chirp_spectrum#Linear_chirp
https://www.atlantis-press.com/article/25854967.pdf
 
Last edited:

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,708
Likes
5,978
Location
US East
Found out that when I create the samples digitally, the sampling rate definitely made a difference. Further investigation is required.
 

DonH56

Master Contributor
Technical Expert
Forum Donor
Joined
Mar 15, 2016
Messages
7,881
Likes
16,667
Location
Monument, CO
IIRC, a frequency chirp in the analog domain does not modulate the amplitude. Sampling and applying an FFT results in frequency binning and waveform tails that affect the amplitude reported by the FFT. But it has been a long time since my radar days, and I was designing chips, not dealing with the system-level aspects for the most part.
 

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,708
Likes
5,978
Location
US East
[Edit] These plots are made with straight lines joining the sample points (linear interpolation), and are therefore afflicted with the same display artifacts as OP. See post #17 for proof that they aren't real.

I created 2 chirps of the same duration (5.46s, bandwidth 4 Hz, center at 12 kHz), one using fs=48 kHz (top), the other fs=192 kHz (bottom). The waveforms look different, but the FFTs look the same.

chirp48k.png


chirp192k.png


I wonder if frequency resolution has anything to do with it. Since for a 5.46 s signal, the spacing between the frequency bins is only 0.18 Hz. Feel a bit large to me to resolve a 5.46 second 4 Hz bandwidth chirp.

I think this is beyond my understanding at the moment.
 
Last edited:

danadam

Addicted to Fun and Learning
Joined
Jan 20, 2017
Messages
981
Likes
1,523
I created 2 chirps of the same duration (5.46s, bandwidth 4 Hz, center at 12 kHz), one using fs=48 kHz (top), the other fs=192 kHz (bottom). The waveforms look different, but the FFTs look the same.
Now try pure 11999 Hz tone. Same result :)
s11999.png

With only about 4 samples per period, but not exactly 4, in some places they line up with peaks:
s11999.aligned.png

And in others they don't:
s11999.not_aligned.png

Just don't rely too much on waveform renderings done by audio programs :)
 
Last edited:

pkane

Master Contributor
Forum Donor
Joined
Aug 18, 2017
Messages
5,678
Likes
10,320
Location
North-East

As was mentioned, this is just the effect of the display software not doing proper reconstruction of the waveform from discrete samples. Applying a sinc interpolation will fix this. Take a look at 60sec example from 15999 to 16001 at 48k:

1632014144452.png


Now, zooming in at the top center around 30 seconds mark, you can see that the samples connected by straight lines (red dots with blue lines) create a curve with an apparent lower amplitude. Yet, properly reconstructed waveform using sinc interpolation (white) goes up to -3dBFS, as expected:
1632013952259.png


The reason it looks like the amplitude is higher near the beginning and the end is clear when you zoom in around 1sec mark:

1632014421052.png


The samples fall near the peak of the sine wave, so the simple dots connected with lines appear taller than at 30s, yet reconstructed waveform is exactly the same amplitude.
 
Last edited:

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,708
Likes
5,978
Location
US East
Yep. It was display artifact.

To convince myself, I measured the output from the DAC. Top screen capture. At ~8 sec mark, Audacity meter showed about -2.5 dBFS, which corresponds well with my chirp amplitude of 0.75. Scope shows ~200 mV peak-to-peak (I didn't max out my Windows volume).

scope_a.png


At ~2 minute 24 sec, output is near the bottom of one of the "dips". Audacity meter showed (incorrectly) output dropped to about -5 dBFS. But when you look at the scope measurement, there is no change in the peak-to-peak voltage. The amplitude as output by the Realtek DAC in my laptop was constant during the entire length of the chirp.

scope_b.png
 
OP
scherbakov_al

scherbakov_al

Member
Joined
May 10, 2020
Messages
42
Likes
35
Location
Санкт-петербург
I listened to a stationary signal with a "comb" and compared it with a signal that did not have a comb (at a close, adjacent frequency) but to which I added amplitude modulation. And indeed, when I added modulation, it was audible, but when there was just a visual comb, it was not audible. Thank you all very much for your answers. You have indeed proven that this is a display problem in sound editors when we are close to frequencies that are close to multiples of the sample rates. But there is a real comb and there is a real fluctuation in amplitude when the frequency is very close to half the sampling rate. This is very close and most likely just can be filtered out and most likely is not a problem in real devices. Thanks for the examples. And many thanks for the new articles, which were interesting and added a description of the chirp properties. Have a nice time everyone!
 

dc655321

Major Contributor
Joined
Mar 4, 2018
Messages
1,597
Likes
2,235
Yep. It was display artifact.

To convince myself, I measured the output from the DAC. Top screen capture. At ~8 sec mark, Audacity meter showed about -2.5 dBFS, which corresponds well with my chirp amplitude of 0.75. Scope shows ~200 mV peak-to-peak (I didn't max out my Windows volume).

View attachment 154252

At ~2 minute 24 sec, output is near the bottom of one of the "dips". Audacity meter showed (incorrectly) output dropped to about -5 dBFS. But when you look at the scope measurement, there is no change in the peak-to-peak voltage. The amplitude as output by the Realtek DAC in my laptop was constant during the entire length of the chirp.

View attachment 154255

Those little Analog Discovery boards are soooo useful. Money well spent (for once)!
 
  • Like
Reactions: NTK
Top Bottom