# Samples of period to frequency, sampling theorem

In the sample rate of 96kHz there are 96000 samples in a second.

So a periodic waveform with period 96000 samples has a frequency of 1Hz.

A signal with period of 9 samples is ~ 10666 Hz.

Of 5 samples 19200Hz

4 -> 24000

3 ->32000

2 -> 48000 (Nyquist)

So the question is for high frequencies are there really so big gaps in sampling. It can't really represent a frequency of 28.500?

## Edited:

I made some tests creating waveforms in Wavelab. When i try to create a waveform with frequency ( sample rate / 2 ) I get nothing. 0 samples.

But when i create any other frequency ( < Nyquist ) like 47999 in 96kHz sample rate a get visually a kind of amplitude modulated waveform that in the FFT window it shows the correct frequency.

So as i understand the frequency is represented as amplitude modulation of successive samples (how this works i have to find out). Funny thing is that for the waveform to actually resemble the sought form the frequency must be ~ 1/10 of the sample rate.

• Note that your statement in the second sentence shall refer to a pure sine or cosine wave, othwerwise, a periodic signal will have a Fourier series expansion whose fundamental frequency may be what you mean... – Fat32 Jul 27 '16 at 12:20
• you don't need to imagine , here are the first 5 samples of a $\cos(2\pi \frac{48000}{96000}n)$ is {1,-1,1,-1,1} and that of a $\sin(2\pi \frac{48000}{96000}n)$ is 1.0E-015 *{ 0, 0.1225 , -0.2449 , 0.3674, -0.4899 } on my machine... See the answer below – Fat32 Jul 27 '16 at 13:53
• @JohnAm A sine wave of 48kHz at 96kHz will only return zeros (you sample at exactly the nodes). – fibonatic Jul 27 '16 at 16:33
• About your edit: the following clarifies the point: assume a (not necessarily) small $\Delta$ such that a given freqency $\omega_x$ can be represnted also as $\omega_x = \pi -\Delta$ so that: $$x[n] = \sin(\omega_x n) = \sin( (\pi - \Delta) n) = \sin(\pi n)\cos(\Delta n) - \cos(\pi n)\sin(\Delta n)$$. Which is simplified to $$x[n] = (-1)^n\sin(\Delta n)$$ which is what you consider as an amplitdude modulation , which indeed is, a modulation of $(-1)^n$ by the sine wave $\sin(\Delta n)$. However thinking that sampling represents frequencies in AM format is not correct. – Fat32 Jul 27 '16 at 19:40
• Thanks, i 'll have to try to use terminology better and clarify the underlying processes. For me i see a differentiated level of the samples i call it AM. Thanks all of you guys, you helped a lot so to be able to study that stuff that happens to interest me a lot but i have no formal education and i go from hands-on practice to theory. – user17127 Jul 27 '16 at 19:54

No, that is not the reason for aliasing. Due to sampling, a discrete system processes reality at discrete and well defined times. Imagine walking around by rapidly opening and closing your eyes. Obviously, you can navigate the place if you walk around slowly, but if you were to run fast then there comes a point that the environment changes too fast for you to make reliable navigation decisions.

In fact, don't imagine, this is exactly what cinematography cameras are doing. Keep your eyes on the hub bolts of the wheel. Obviously, the wheel turns clockwise but the videoed hub bolts appear to turn clockwise, then go stationary, then anti-clockwise, stop, clockwise, stop, anti-clockwise and so on. Every stopping and reversal is us stradling yet another version of the aliased spectrum as the rate of rotation approaches the camera's frame-rate (The video's Sampling Frequency).

The point is that while your eyes are closed, the camera's shutter is closed, a digital signal processing system's sampling is now "holding", reality does not stop and keeps on happening.

Therefore, it is not that the system "runs out of samples" but more that the system will keep sampling whatever is "in front of it" and in the case of periodic events (such as the case of a spinning wheel), it will start catching the waveform at such points that it would appear that a high frequency is now yet another frequency within the capabilities of the system.

To come back to the "eye flickering" example. Imagine that you are watching a merry-go-round, open eyes it just about crossed 12 o'clock, close your eyes, open: about 3, close, open: about 6, close, open: about 9, close, open: about 11.

Now, imagine that the merry-go-round increases its speed of rotation. There will be a point that the timing will be such that this will happen:

open: 12 o'clock, close (NOW THE MERRY-GO-ROUND MAKES A COMPLETE REVOLUTION BUT ONLY JUST!) open: 11 o'clock, close (NOW THE MERRY-GO-ROUND MAKES A COMPLETE REVOLUTION BUT ONLY JUST!) open: 10 o'clock, close (NOW THE MERRY-GO-ROUND MAKES A COMPLETE REVOLUTION BY ONLY JUST!) open: 9 o'clock, close

While your eyes are closed, you are missing what happens in reality.

This is how the hub appears to roll backwards, or the merry-go-round would appear to run backwards, or an $F_s$ Hz waveform appear as DC (i.e. 0 Hz) when it is sampled bang on on $F_s$ (the sinusoid goes around so fast that we keep sampling it when it is at its positive maximum! -Yes, of course it is phase dependent!-).

In terms of the mathematics behind this, sampling is just a "fancy" modulation (or more generally, the multiplication of two signals, please see this link from this link), because of the "hold". So, if you were to multiply two sinusoids at some $f_1, f_2$, then what you get at the output is one component at $f_1-f_2$ and one component at $f_1+f_2$. This is what creates this folding around $F_s$ if you were to substitute some $f_2$ with $F_s$.

And if we proceed one step further, the $F_s$ waveform is not a sinusoid at $F_s$ but rather a series of spikes at a rate of $F_s$. So, to see how the sampled signal looks like, take your reality signal, say some $f(t)$ (where t is time) and MULTIPLY IT with this spike train.

Multiplication in the time domain equals convolution in the frequency domain and what do you get if you convolve some spectrum with a train of spikes? You get the same spectrum repeated at every spike (in exactly the same reason of why you get echoes, when you convolve with an impulse response of sparse spikes).

And this is how Aliasing emerges. The typical way of controlling for it is to put an analog low-pass filter at the input of the system that attenuates frequencies above $\frac{F_s}{2}$. Therefore, the system doesn't get to "see" (or process) anything (aliased) above $\frac{F_s}{2}$.

Hope this helps.

EDIT: From the comments to this response, I think that the question was more about whether or not a sampled system runs out of frequency components to represent a waveform because this sampling of the time domain, should be reflected to the frequency spectrum too. In other words, the question is about running out of discrete components to represent a waveform and "could this be the reason for aliasing?"

The answer to this is again no, because, to get rid of the "annoying" half a sample at 28.5 Hz (from the original example) all you have to do is double your observation window. In general, for any non-integer frequency at a given $F_s$, there is an integer number of samples that can contain it. But in that case, we still operate under the same constraints for aliasing.

(When you consider the effect of a window on the components of the Discrete Fourier Transform, then you are thinking about the "resolution" of the transform, but again, in that case, the resolution operates within the constraints of aliasing).

• Can I please ask you to clarify what does "low-precision" mean here? "Precision" is a concept I usually associate with "numerical" precision but I have a feeling that you don't mean this. If you mean loss of "fidelity", then yes, this takes us back to aliasing. – A_A Jul 27 '16 at 11:29
• Thanks for letting me know more. I have updated the response. No bother, this is what this site is supposed to be about. – A_A Jul 27 '16 at 11:46
• For the first part, can I please ask you to add more information about the objective you are trying to achieve? After Sample-And-Hold, nothing, within the bandwidth dictated by $F_s$ is lost. Retain the decimal part of the fraction of periods $d=\frac{\frac{1}{f}}{T_s}$ (and call it $x$) then the multiplying factor is $ceil{\frac{1}{d}}$ where $ceil$ is the ceiling function. To accommodate half a sample, just double the window. – A_A Jul 27 '16 at 12:08
• Thanks for the links and the very detailed answer. "{..} sampling is just a "fancy" modulation (or more generally, the multiplication of two signals". This sentence is what i was looking for. :-) – user17127 Jul 27 '16 at 18:13
• Glad it was helpful. Please note, the anti-aliasing filter is to be positioned near $\frac{F_s}{2}$, not $F_s$ as I wrote initially, just spotted and corrected it. – A_A Jul 27 '16 at 19:53

I'm afraid your reasoning behind aliasing is wrong. In addition, your reasoning behind the representation of signal frequencies by the number of samples is misleading because of the following fact:

consider an analog cosine signal $x_c(t) = \cos(2\pi f_x t)$ with a frequency of $f_x$ sampled at a sampling rate of $F_s$ as $t = n/Fs$ is represented in the discrete time via the following: $$x[n] = \cos(2\pi f_x n / F_s)$$

Now the period $N$ of this signal should satisfy the following: $$\cos(2\pi f_x (n+N) / F_s) = \cos(2\pi f_x n / F_s + 2\pi f_x N / F_s)$$

which is true if $2\pi f_x N / F_s = 2\pi k$, where both $N$ and $k$ are integers. Simplify to get : $$N = \frac {F_s}{f_x} k$$

Ex: Let $F_s = 96.000$ and $f_x = 48.000$ then $N$ is found to be: $$N = \frac {96.000}{48.000} k = 2$$ with k = 1.

Ex: Let $F_s = 96.000$ and $f_x = 32.000$ then $N$ is found to be: $$N = \frac {96.000}{32.000} k = 3$$ with k = 1.

Ex: Let $F_s = 96.000$ and $f_x = 47.000$ then $N$ is found to be: $$N = \frac {96.000}{47.000} k = 96$$ with k = 47.

So for the frequency, $f_x = 48000$ we have $N = 2$, and for $f_x = 32000$ we have $N=3$ but for $f_x = 47000$ we have $N = 96$ nothing between $N=2$ and $N=3$... And this has nothing to do with the concept of aliasing.

When replaying 1 second of music sampled at 44100 Hz, many adults can still hear a vast number of different frequencies above 5512.5 Hz, not just 5 different frequencies ( Fs / integer_constant ). That's because the samples can represent sinusoids even if their frequency does not repeat in any integer number of periods. Nothing to do with aliasing unless the frequency content was above Fs/2 before sampling.