1
$\begingroup$

Do the processes of upsampling and downsampling affect the magnitude of the transform of a signal? And if not, why am I seeing everywhere that a filter with gain different from 1 is applied after up/downsampling a signal?

EDIT: For example in Discrete-Time Signal Processing by Oppenheim-Schafer (Section 4.6, 2nd edition):

enter image description here

Also, in the summaries of the subject that my teacher did himself, up- and downsampling are always followed by a lowpassfilter with gain different from 1.

$\endgroup$
  • $\begingroup$ Notably, you have said that unity gains are not used for either upsampling or downsampling. Your citation, however, shows a unity gain for the downsampling filter and a gain of L for the upsampling filter. This is because the author intends for the signal amplitudes to remain constant before and after upsampling and downsampling. I can provide a more detailed answer if you don't think any of the below answers are sufficient. $\endgroup$ – hops Jan 23 '17 at 19:51
  • $\begingroup$ @hops Go ahead. $\endgroup$ – Tendero Jan 23 '17 at 21:27
1
$\begingroup$

All of the answers above are good in their own way. The reason that the Oppenheim-Schafer book and other similar resources use a gain of $L$ for upsampling and a gain of $1$ for downsampling is to maintain a constant amplitude for the signal before and after the operation.

Do the processes of upsampling and downsampling affect the magnitude of the transform of a signal?

The short answer is that it depends on whether we are upsampling or downsampling. Upsampling does alter the magnitude of the transform (more on this in a minute). Downsampling doesn't alter the magnitude of the transform (assuming a perfect anti-aliasing filter).

For me, this is easiest to understand with a concrete example. So, let's consider a simple sinusoid, $x(t) = A \cos ( 2 \pi f_0 t + \phi )$. Let's sample this at some sampling rate $f_s$ higher than the Nyquist rate (i.e. $f_s > 2 f_0$). This results in a sample sequence

$$ x[n] = A \cos \left( \frac{2 \pi f_0}{f_s} n + \phi \right). $$

The process of upsampling consists of inserting zeros in between every other sample. A mathematical way to express this is

$$ x_{\uparrow 2}[n] = \left\{\begin{array}{cr} A \cos \left( \frac{2 \pi f_0}{2 f_s} n + \phi \right) & \mbox{$n$ is even} \\ 0 & \mbox{$n$ is odd} \end{array}\right. $$

and another equivalent way is

$$ x_{\uparrow 2}[n] = \frac{A}{2} \cos \left( \frac{2 \pi f_0}{2 f_s} n + \phi \right) + (-1)^n \frac{A}{2} \cos \left( \frac{2 \pi f_0}{2 f_s} n + \phi \right). $$.

If we note that $\cos(\pi n) = (-1)^n$, then we obtain

$$ x_{\uparrow 2}[n] = \frac{A}{2} \cos \left( \frac{2 \pi f_0}{2 f_s} n + \phi \right) + \frac{A}{2} \cos\left( \pi n \right) \cos \left( \frac{2 \pi f_0}{2 f_s} n + \phi \right). $$

From here, we apply the identity $\cos(\alpha) \cos(\beta) = \frac{1}{2} \left[ \cos(\alpha + \beta) + \cos(\alpha - \beta) \right]$ and use the fact that $\cos(\pi - \alpha) = \cos(\pi + \alpha)$. This yields the final form that we care about

$$ x_{\uparrow 2}[n] = \frac{A}{2} \cos \left( \frac{2 \pi f_0}{2 f_s} n + \phi \right) + \frac{A}{2} \cos \left( \frac{2 \pi \left(f_s - f_0\right)}{2 f_s} n + \phi \right). $$

This is the signal prior to passing through the interpolation filter. Notice that now we have $2$ sine waves. In general, if we upsample by $L$ then we have $L$ sine waves. Note that each one is weighted by $1/L$, this ensures that the summed amplitude of all sine waves has the same value as the original sine wave at the correct sampling instants and is zero elsewhere. After applying the interpolation filter, consider the transform of the sequence. It is the same obtained by sampling the original function at the higher rate, but it is scaled by $1/L$. Thus, to preserve the signal amplitude while filtering out the aliased images (in this case the additional sine wave component), we must scale the passband of our interpolation filter by a factor of $L$.

For the second part, assume that we are downsampling by $2$. We start with the same $x[n]$, but this time we choose $f_s > 4 f_0$ so that it isn't rejected in the anti-aliasing filter. The decimated signal is now given by

$$ x_{\downarrow 2}[n] = A \cos\left( \frac{4 \pi f_0}{f_s} n + \phi \right).$$

Unlike the upsampling case, this remains a single sinusoid within the Nyquist bandwidth. So, the magnitude spectrum is unscaled compared to the spectrum we would have arrived at by sampling the original signal at a slower rate.

$\endgroup$
1
$\begingroup$

Do the processes of upsampling and downsampling affect the magnitude of the transform of a signal?

Yes. No. Well.

It all depends on how you define up- and downsampling, but usually, it's defined in a manner that keeps the total energy constant.

So, assume you downsample by a factor of 2, that means you simply "throw away" every second sample. Now, there's two options:

  1. your input signal was appropriately filtered to only contain half of its bandwidth of signal. In that case, that signal doesn't really change; Assume you'd have a signal that is constant 1. Throwing away half of it will still lead to constant 1. Assume your signal is a sine of relative frequency $f=\frac{f_\text{signal}}{f_\text{sample}}$ and amplitude $A$: throwing away half of its samples will change its frequency relative to the sampling rate, but it won't change its amplitude, and therefore its energy. Now, we're doing classical signal theory by postulating you can define every signal as sum of sinusoids: since none of the original sinusoids changes its amplitude, so can't the resulting sum signal.
  2. your signal contained more spectrum than Nyquist would allow for the downsampled signal. You end up with aliases, and thus, amplitude changes...

And if not, why am I seeing everywhere that a filter with gain different from 1 is applied after up/downsampling a signal?

Oh come on. Really. This would be the time to actually cite where you see that. I don't do that. I don't usually see people do that, unless they need to achieve a specific fixed point bit width. So I'd say your claim is unbacked and hence indistinguishable from false.

$\endgroup$
  • $\begingroup$ Sorry about that. I already edited the original question to show what I meant. $\endgroup$ – Tendero Feb 8 '16 at 13:15
  • $\begingroup$ Thanks, I can understand that mostly well. $\endgroup$ – com.prehensible Oct 21 at 9:35
1
$\begingroup$

The discussion on amplitude and energy changes during a sample rate conversion is quite complicated because as others said above, it depends on many factors.

In summary, downsampling by Q leaves the amplitudes unchanged but reduces the energy by a factor of 1/Q, assuming that the gain of the lowpass filter is 1. Upsampling by P can result in different amplitudes and energies depending on the gain of the lowpass filter: $1$, $\sqrt{P}$, or $P$. The corresponding results are shown in the table below.

enter image description here

For complete derivation, you can see it simplified in one of my articles on sample rate conversion.

$\endgroup$
  • $\begingroup$ Qasim, i wonder if some of your explanation in the referred article is flawed. in the second and third diagrams, you need to show the step where the data is LPF'd with cutoff of 1/3 Nyquist before applying the sampling function $p[n]$ which effectively throws 2 of 3 samples away by zeroing those samples. $\endgroup$ – robert bristow-johnson Oct 25 '16 at 3:29
  • $\begingroup$ the other thing is that your treatment of Energy vs gain is really dependent on the manner that the DFT is defined. if you keep the amplitude constant, which means you need a gain of $P$ in your low-pass filter if you are stuffing $P-1$ zeros between each sample, then the amplitude of the upsampled output is the same as the input and the mean energy per sample is the same. $\endgroup$ – robert bristow-johnson Oct 25 '16 at 3:35
  • $\begingroup$ @robertbristow-johnson: that step of actual lowpass filtering is missing, that's right but it doesn't make the ongoing discussion flawed. If it does, let me know how. As far as your second comment is concerned, I agree. But here I'm talking about energy in the upsampled signal and not energy per sample. Many people would call that power (although definition of power is a little shaky in discrete-time signals). $\endgroup$ – Qasim Chaudhari Oct 25 '16 at 4:49
0
$\begingroup$
  1. In downsampling you will throw away samples, so if you have a signal of X samples, you'll end up with a signal of X/R samples where R is the downsampling factor. If you do the FFT of the whole signal then you'll see that the energy is lower now of course, where you don't have as many samples. However the average energy is constant in this case, where you didn't alter the signal.

  2. For upsampling, you will add zeros between samples, so the total energy will stay constant no matter what the upsampling rate is. However the average energy is lower in this case where you added samples without energy (the zeros).

  3. You would use an anti-imaging filter with gain after you do upsampling. Since this filter will interpolate the values of all the samples, hence if you used a filter without gain, think of it as you'll be taking energy from the original samples so you put it in the interpolated zero samples when you're smoothing the signal and removing the images of the frequency spectrum created by upsampling (i.e: if you upsample an audio track and do an anti-imaging filtering without gain, the result track will have a lower volume (actually the same volume without filtering too), you want the same average energy to have the same volume, so you want a filter with gain to give energy to the added zeros).

    For the anti-aliasing filter, you may want to use a filter with gain if you're interested in having a constant total energy. However in anti-aliasing think of it as trying to filter unwanted frequency components, that you don't want them to mix with your useful signal, so you'll always have the same energy for that latter.

Don't confuse filter gain with signal energy in any way, the gain of the filter is how much you boost each freqeuncy component, this however will increase the signal energy in the end.

Btw, what I think Marcus meant is that you want to keep a constant average energy, not the total energy, where a shorter signal will have lower energy anyway, but average energy defines the power of a DAC's output. (Correct me if I'm wrong please)

$\endgroup$
0
$\begingroup$

The reason behind choosing the gain $L$ for upsampling and $1$ for downsampling is to ensure that the output power remains same as the input.

The following is an example illustrating this. Consider an input signal which is constant with amplitude $A$, i.e. $x(n) = A$. Note that the RMS value of this signal is $A^2$.

Upsampling:

Before the low-pass filter, the signal is upsampled by simply inserting $L-1$ zeros after each input sample. So, the resulting signal is the sequence: $A, 0_{(1)}, 0_{(2)},...,0_{(L-1)},A,0_{(1)},...$. The power of this signal is $A^2 / L$. Moreover this power is divided equally into $L$ frequency bands. The low-pass filter is supposed to filter out $L-1$ of those bands. So, after the low-pass filter, the signal power would be $L$ times lower, i.e. $A^2/L^2$. Thus, having a gain of $L$ in the signal path would result in the output having the same power as the input, which is $A^2$ in this example.

Downsampling:

Downsampling our example signal $x(n)$ by taking every $L$-th sample results in the same sequence $\{A, A, A, ...\}$, so it does not require any scaling. This is true, in general, for all signals which are bandlimited to $1/L$-th of the full frequency range. Note that the low-pass filter before the downsampling is meant to ensure this condition.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.