Stupid question on sampling theorem and aliasing

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

antto wrote: maybe this will help:
the sample points (which many audio programs visualise as dots) are not equal to the amplitude
they are more like weight coefficients for the resampling filter

these dots happen to "fall" onto the actual continuous signal only at the very low frequencies, while the more you get towards Fs/2 - the dots go wild, but that's actually fine
Thanks to camsr, kraku, purplesunray, music engineer and others for the ideas.

Antto, am guessing you wrote slightly different than your understanding. Or maybe it is my misunderstanding. So far as I know which is not much, a properly bandlimited signal will intersect the discrete sample dots even at high frequencies.

For instance that good video which kraku posted, somewhere in it the fella shows bandlimited computer display of high frequency sine wave, where the interpolated line always passes thru the dots. However, at high frequencies, the data points are so sparse that it would take an expert well-trained eye to imagine the proper bandlimited signal shape which would intersect that "apparent random scattershot" of dots.

Frequency vs Time domain are two sides of the same thing, but I grew up with analog scopes and probably think in time domain more often than freq domain.

One can make an analog sine wave sweep, perhaps 10 kHz to 20 kHz, which varies in amplitude according to instantaneous frequency. And one can make an analog sine sweep with solid steady amplitude at all frequencies. With an analog scope, it is easy to see the difference between the two. The solid-amplitude sweep will stay the same amplitude all the way up on the analog scope, and the variable-amplitude sweep will vary in amplitude on the scope display.

I never owned a digital scope. I suppose the spensive ones would have just as true display as analog, but wonder how good the $500-$1000 digital scopes would do on the above task? Maybe fabulous, or maybe stairstep-city? Dunno.

So anyway, a computer graphic interpolation which is good enough to "connect the dots" with plausible-looking curves, but shows amplitude squiggles even on a steady-amplitude high-freq sweep-- Because it always shows squiggles, there is no way to know whether the analyzed signal is steady or has its own built-in amplitude squiggles.

Many digital filters can have built-in fine-grained high frequency amplitude squiggles. A couple of years ago, that is why I noticed Cool Edit Pro was "a little weird" for close examination of high frequencies. I was testing filters with slow sine sweeps. CEP was my "most accurate" graphic display but it wasn't accurate enough to know which HF amplitude oddities are filter characteristics versus which HF amplitude oddities are mere program display artifacts.

Such tiny display oddities would make no difference for 99.9 percent of music-making tasks. You could generally make music just fine even with a crude stairstep or connect-the-dots-with-straight-lines display. Just like, for most purposes you don't need an oscilloscope in the studio to make music. Though I'd guess tasks such as mastering or audio restoration could benefit from computer display which performs near-identical to analog memory scope.

Long ago had a 1970's era giant Tek 100 MHz 4 bay lab scope with "true analog" memory, rather than the later digital memory. But for most tasks digital memory was lots better. The analog memory feature was the first to fail on that old scope, but the thang was so rugged it took years to die. Just lose yet another feature every year or two. It had so many features to begin with, was a long lingering demise. Until finally so much failed that there wasn't much that it could do anymore. :)

Post

@JCJR
For me the DSP-basic etched in my memory at secondary shool level, without me even knowing what DSP is about :D
We had a teacher on technical drawing that made us draw sine waves.
Only allowed tools: paper and dividers.
After drawing sine waves for about half a year, he changed his mind and wanted us to draw rectangle waves ... by drawing + summing up sine waves.

Back than i though he must be a damn masochist. You can't beleve how much work this is... it literally never ends.
Many years later I actually undestood what I did there... it's the fundamental basis of DSP. :)
Last edited by PurpleSunray on Wed May 24, 2017 11:55 pm, edited 2 times in total.

Post

.. wrong button ..

Post

JCJR wrote:
antto wrote: maybe this will help:
the sample points (which many audio programs visualise as dots) are not equal to the amplitude
they are more like weight coefficients for the resampling filter

these dots happen to "fall" onto the actual continuous signal only at the very low frequencies, while the more you get towards Fs/2 - the dots go wild, but that's actually fine
Thanks to camsr, kraku, purplesunray, music engineer and others for the ideas.

Antto, am guessing you wrote slightly different than your understanding. Or maybe it is my misunderstanding. So far as I know which is not much, a properly bandlimited signal will intersect the discrete sample dots even at high frequencies.
i guess my words got slightly entangled.. yes, the signal does pass thru the dots, but the closer you go towards nyquist, the more those dots don't really show the amplitude of the signal <- that's what i meant

but to make things clearer, here's a picture:

Image

that's a 22kHz sine wave with a steady amplitude of 1.0, at Fs=44.1kHz (so it's slightly under nyquist, but yet very close)
ignore the lines, just look at the dots..
well, even when i know that the dots are "weights" - it's very easy to look at this and think "it looks like amplitude-modulated"
but i ran it thru a spectrograph and it shows a steady tone there, so i know the magic works.. it just looks misleading (even when you know)
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

Actually it is identical to amplitude modulation. What you're seeing is the aliasing - that is the harmonics of the complete spectrum - interfering with the real signal. In AM you have sum and difference frequencies. For example if this signal is 23999 Hz (48 kHz sr) the first alias would appear at 24001 Hz and you'll see amplitude variation at 2 Hz; the difference between the two signals.

How can you tell whether the signal is two distinct tones, aliasing or sum + difference? You can't. They're all exactly the same thing.

So the issue here is that the transient display does not adequately anti-alias the signal before displaying it on screen.

Ideally a combination of a windowed sinc and gaussian filter kernel should be applied to minimize both aliasing and ripple.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

If you resample that waveform, like pitch it down, the AM oscillation will still be there.

Post

Thanks all.

Ya I suppose for instance a "high accuracy" 8 pixels per sample display would be equivalent to real high accuracy 8x upsampling? Which, if played at the original samplerate would be the same as transpose down

Its been a few months and may be remembering wrong, but IIRC cases of frequencies maybe between 8 and 2.5 samples per cycle, could show even more "interesting" scattershot sample dot patterns than when approaching very near nyquist.

Even a cheap 10 or 20 MHz analog scope (in good condition) would laugh at the trivial task of accurately displaying a 20 kHz sine wave.

From aciddose's diagnosis of the mechanism (and suggested cure) for digital HF display artifacts, it seems to want an FIR upsample filter that is no more than maybe -1 dB at 20 kHz and has an exceedingly low-ripple brickwall to -80 dB or better at the source samplerate nyquist?

Which would probably be a rather big filter kernel.

Maybe it would be most feasible to try for accurate graphic rendering up to 20 kHz, rather than try to get it smooth all the way up to almost-nyquist?

So with a huge enough kernel, capable of low-ripple heavy aliasing attenuation-- Would that in itself be sufficient to eliminate HF display artifacts?

And gets back to another thing I was wondering about in my first message-- Could a kernel that huge somehow make general-duty display of ordinary mixed-frequency music signals "worse"?

I haven't any idea. Dunno much about it. Just recall reading comments that huge brickwall filters can be unfriendly to musical transients. If that is true and it could audibly affect music, then maybe it could also somehow "mess up" a graphic display of dynamic broadband music audio?

It seems somehow unlikely, but dunno. Regardless how big the kernel it ought to trace thru the original sample points, so its hard to understand how it could drastically mess up display of transients.

edit: OTOH unless the filter cutoff is set to the source samplerate nyquist (nth-band filter) then the filter output samples won't necessarily intersect the original sample values. So maybe a big 20 kHz brickwall FIR could mess with the transient display. Would want to plot ALL the filter output samples, rather than plotting the source samples with 20 kHz brickwall samples plotted in-between.

Apologies, just thinking out loud.

Post

camsr wrote:If you resample that waveform, like pitch it down, the AM oscillation will still be there.
No actually, this would only be true if you didn't use an adequate re-sampling filter. The aliased frequency is created by the re-sampling itself and is not a part of the original sampled signal.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

JCJR wrote: From aciddose's diagnosis of the mechanism (and suggested cure) for digital HF display artifacts, it seems to want an FIR upsample filter that is no more than maybe -1 dB at 20 kHz and has an exceedingly low-ripple brickwall to -80 dB or better at the source samplerate nyquist?

Which would probably be a rather big filter kernel.
It would be over-kill. You have to remember that the accuracy of the display is often less than 8-bit. Consider the vertical resolution in pixels at which the waveform is actually displayed as well as the color accuracy of the anti-aliasing filters applied to the graphics at the same time as taking into account whether or not this would be discernible visually.

In reality the kernel required is quite reasonable as the accuracy doesn't need to be very high at all. Even -20 dB would improve the accuracy of the visuals dramatically and the slope does not need to be particularly steep. This is why a combination of sinc and gaussian can be used depending upon the zoom (ratio of display resolution vs. sample rate.)

With very small zooms less than 2 (120%) a gaussian kernel will be much preferred to avoid the sudden introduction of massive amounts of ringing which is very visible.

At very high zooms like 32x an almost pure sinc kernel will be preferred in order to accurately represent that ringing which is present in the ideal reconstruction of the signal. Given a wide enough kernel windowing is not too important as the visual accuracy won't be significantly affected by it.

I posted a thread on the wavosaur forum requesting such functionality several years ago.

http://www.wavosaur.com/forum/inter-sam ... t1261.html

I still use cooledit (no longer available, used for example images in the thread) which back in 97 provided this feature in order to examine signals under a high level of zoom. The accuracy isn't excessive but it is high enough to reveal artifacts that would otherwise be indiscernible.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

Well I am glad to get an answer on this question. I suppose the reconstruction filter has a significant impact on everything near nyquist. This is why a higher sampling rate eases filter requirements for audio IMO, less steep filters, but possibly not the best option either.

Post

Thanks aciddose

Yeah, I still use CoolEdit Pro 2, the last version before the sale/rename to Adobe Audition. IMO it remains a very good editor. The minor oddities I noticed were related to artificial waves not very similar to ordinary audio editing.

I looked at it again today, and the "minor oddities" were a bit different than I recalled. The multiple-pixel-per-sample interpolation is very good. Using fixed-frequency sine waves, 44.1 k samplerate-- The interpolation ripple appears to be about 1 dB with a 20 kHz sine. Interpolation ripple is too small to detect by eye below 15 kHz or higher. OTOH interpolation ripple is rather huge at 22 kHz, but it may be unrealistic to expect much accuracy above 20 kHz.
Image
Image
Image

Post

The HF oddities that I had mis-remembered were close-zoomed-in, but not yet up to multiple pixels per sample.

Here is a boring example, maybe not a good example, from a couple of old files I found. It is mis-labeled when I did the screen shots today. The step durations and frequency ranges are correct, but apparently each step was a bit more than an octave sweep.

I had some old files somewhere of filter test sweeps that may have been better examples but couldn't find em right away.

It was a series of 1 second duration, "a little more than 1 octave" sine sweep -6 dB steps, separated by 1 second silence. A simple flavor of gross envelope follower test. The source sweep--
Image
And a test of an envelope follower that sucked rather bad--
Image

Zooming in to the source 1 second duration top octave step sweep shows artifacts, though the actual audio data in the source audio file is solid amplitude--
Image
On the other hand, I think the CEP2 display of the faulty Envelope Follower top octave aliasing is probably rather accurate--
Image

Zooming in to a 50 ms view of that middle big alias pattern in the sucky envelope follower output, probably somewhere in the ballpark of 15 kHz, is probably accurate==
Image

On the other hand, a 50 ms view of the source audio has moire-pattern artifacts.
Image
Also a 23 ms view of the source audio has moire pattern artifacts.
Image
But if we zoom in to multiple-pixel-per-sample at any area below 20 kHz or whatever, we get a low-ripple or no-ripple, low-artifact display. Here is the 2 ms center of the above source audio region which is probably around 15 kHz, and the display is solid as a rock.
Image

So it seems that zoomed-way-out display is solid, and zoomed-way-in is solid, but in-between can be confusing.

In the above example, I think CEP is accurately depicting problems with the envelope follower, but there are so many artifacts in the source display at certain zoom levels, that it might take a bit of head-scratching to know data from artifact.

Post

Music Engineer wrote:
camsr wrote:DACs use analog filters mostly... although some might use linear phase?
as far as i know, there are DACs that use oversampling (together with digital fir filters) out there. somehow it seems to be possible to trade off sampling rate against bit resolution. with 16x oversampling (at 44.1 kHz sample rate), they can use just 1 bit and still provide cd quality - on the average...or something:
https://en.wikipedia.org/wiki/1-bit_DAC
Almost all DAC and ADC are 1bit based because they are cheaper to create. That being said, you still filter the input signal in the analog domain first. The digital part here justa ccumulates the already computed bits together, it's not meant to be a filter as we describe them here.

Post Reply

Return to “DSP and Plugin Development”