:: Home :: FAQ :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::
[Tutorial] Audio and signal theory: Nyquist mirroring (Guru)

 
       Skale Tracker Forum Index -> Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Teetow
Skale Lover


Joined: 12 Nov 2002
Posts: 245
Location: Sweden

Posted: Thu Jan 16, 2003 2:22 am    Post subject: [Tutorial] Audio and signal theory: Nyquist mirroring (Guru)

(Complies to all versions)

The top of human hearing range, according to the schoolbooks, is about 20 kHz. Most adults have damaged their ears down to hearing nothing above 16-17 kHz, though. A regular soundcard samples at roughly twice that frequency (44100 Hz), and some cards even feature 96000 Hz or even 192000 Hz. Why? Because of Mr. Nyquist!

What is Nyquist Mirroring?
Henry Nyquist, an engineer working for AT&T in 1917, figured out something called Nyquist's Theorem. This states that the highest frequency which can be accurately represented by a sample is one-half of the sampling rate. Based upon this, a device with a 44100 sample rate can only reproduce frequencies up to 22050 correctly, since it takes two samples (units of data) to reproduce a frequency. So, sounds in real life are measured in Hz, sample rate in samples/second.

If a soundcard tries to capture a 44100 sine tone recording with a 44100 sample rate, you will get a flat line. This is because each time the soundcard checks the input voltage, the sine tone will have run exactly one full cycle, and it looks to the soundcard as if nothing has happened:



A 44100 samples/sec soundcard capturing a 44100 Hz tone

Now, if we lower the frequency to 44099 Hz (or raise it to 44101 Hz), the computer will sample a 1 Hz sinus tone. Why? Well, following the same reasoning, the tone will have gotten almost one full cycle between each sampling, and the soundcard will slowly "catch up" with the sine tone once per second, resulting in a 1 Hz sine tone.


A 44100 samples/sec soundcard capturing a 44099 Hz tone

This is Nyquist mirroring: Frequencies near even divisors of the current sample rate, meaning 44100, 22050, 11025, 5512.5 and so on, will generate "mirror images", starting in the lo-freq range.

Why should I care?
Since this also goes for playing back samples, not just recording them, you can test this by pitching an already high-frequent sine tone (although the effect is more clear if you use a square wave) steadily upwards, in e.g. Skale or any sample editor. As the tone travels upwards, you will soon be aware of low-frequent sounds appearing, falling in pitch, and then disappearing, to be replaced by other ones. If you generate a sample and look at it in a spectrum analysis, you can clearly see these "mirrors" as blurred lines. I've used a triangle wave to exaggerate the effects.


A triangle tone swept from 4500 Hz to approx. 22000 Hz, causing mirroring around the Nyquist frequencies 11025 Hz and 22050 Hz

I have used this phenomenon as a weird effect in my XM's long before I knew what was causing it, but most of the times Nyquist mirroring is an unwanted artifact. The easiest solution is to increase the sample rate at which your software operates. Take a look at the same wave, generated in 192000 Hz. You'll see that the Nyquist mirroring is gratly reduced:


The same triangle tone, but rendered in 192 000 samples / second

Conclusion
It might be well worth noticing that this effect is rarely audible in such a chaotic environment as a finalized song, but on soloed instruments such as a softsynth or a vocal sample, it can cause some unwanted noise and "cheapness" to the sample. Also, boosting high frequencies too much might produce Nyquist Mirrors that garble the sound.

The best way to avoid this phenomenon is to use as high a samplerate as possible, and to apply a lo-pass filter to all output with a lot of high-frequency content, to cut off the frequencies causing Nyquist mirroring.

That's all for today, kids!

Edit: fixed the pics.
Edit2: Fixed the pics. Again.
_________________
----------
Hap hap!


Last edited by Teetow on Tue Oct 18, 2005 6:37 pm; edited 7 times in total
Back to top
DeiFuz
Skale Lover


Joined: 12 Nov 2002
Posts: 163
Location: Castellón (Spain)

Posted: Thu Jan 16, 2003 11:12 pm    Post subject:

nice info!
Back to top
Teetow
Skale Lover


Joined: 12 Nov 2002
Posts: 245
Location: Sweden

Posted: Tue Jan 28, 2003 5:01 am    Post subject:

Bump!

I added a few illustrations and rewrote some paragraphs, to clear things up a little. Hope this brought some more understanding to the topic.
_________________
----------
Hap hap!
Back to top
Templar
Skale User


Joined: 01 May 2003
Posts: 56
Location: Finland

Posted: Sun Oct 03, 2004 9:39 pm    Post subject:

Can't see the images anymore :/
Back to top
st3vie
Skale Administrator


Joined: 13 Nov 2002
Posts: 641
Location: Beverwijk, The Netherlands

Posted: Sun Oct 03, 2004 9:42 pm    Post subject:

i'll try to get in touch with Teetow for the images.
He hasn't been active lately here, so... wil try.

-st3vie
Back to top
Teetow
Skale Lover


Joined: 12 Nov 2002
Posts: 245
Location: Sweden

Posted: Mon Apr 11, 2005 1:47 am    Post subject:

*tip-toeing in, replacing old broken pictures with brand-spanking fresh ones*

I'm a part-time ninja.
_________________
----------
Hap hap!
Back to top
DreamKing
Guest





Posted: Fri Jan 13, 2006 8:48 am    Post subject: Aliasing

The "Nyquist Mirroring" is called "aliasing" in engineering context. It is assumed in the preceeding text that high pitch notes always have this problem. Actually it depends a lot on the specific implementation of the resampler. Most resamplers use constant averaging which destroys much of the aliasing copies. Once the aliasing is done, there is no turing back. Both low and high frequencies are damaged (high by low, and low by high). So after an inaccurate algorithm increases the pitch, low pass filtering only makes things worse. It makes your signal sound both cheap and low quality (sometimes you want to keep high frequency aliasing copies since they kinda make your signal richer ).
Back to top
Display posts from previous:   
       Skale Tracker Forum Index -> Documentation, Tips & Tricks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group