Saturday, October 5, 2019

interpolation - Output gain when upsampling and downsampling


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.



Answer



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.


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...