0
$\begingroup$

I'm trying to resample a digital communication signal in SciPy or Matlab. Suppose the signal was sampled at 3 samples per second, and I want to resample it to 2 samples per second, the thing is I also want to be able to change the new sampling point so the new samples doesn't necessarily start at the same point as the orignal samples.

I'm using the Scipy resample function, but it doesn't have the flexibility to change the sample point, it only allows

The resampled signal starts at the same value as x ...

The Matlab resample function can't do that either.

Is there a way to shift the start point by a small amount, say $\alpha T$ where $T$ is the symbol duration and $0 \le \alpha < 1$ ? I guess what I need is the generic resampling algorithm underneath these resample functions so I can see if there's anything I can tweak.

$\endgroup$
  • $\begingroup$ Your questions appears to be specific to a SciPy implementation, is that correct? Phrases like "samples per symbol" do not mean much in the broader context of signal processing so it might help to clarify them if you want answers from people without any direct experience of SciPy. $\endgroup$ – PAK-9 Aug 27 '14 at 17:45
  • $\begingroup$ Search for "fractional delay". $\endgroup$ – Jim Clay Aug 27 '14 at 18:22
1
$\begingroup$

since @Community resurrected this question, i'll pick up a little where hotpaw left off. i'm not gonna run this through MATLAB or Octave (i can never remember which are columns and which are rows).

let $r$ be the resampling ratio. $r>1$ means that your sample rate has increased and you're making the sequence longer because there are more samples. so if you pad a delay of $\tau$ at the beginning of the input $x[n]$, that should result in a delay of $r \cdot \tau$ at the output $y[n]$ (whether $\tau$ is an integer number of samples or not).

now suppose you pad (using concatenation) the input with $P$ samples of zero before $x[0]$. $P$ is a positive integer. that will result in a pad in the resampled output $y[n]$ of $rP$ samples where $rP$ is not necessarily an integer. but

$$ \lfloor rP \rfloor \triangleq \operatorname{floor}(rP) $$

is an integer, and you can strip those samples (which will be mostly zero) off of the beginning of $y[n]$. $\lfloor u \rfloor$ is the most positive integer that is no greater than $u$. this is always the case:

$$ \lfloor u \rfloor \le u < \lfloor u \rfloor + 1 $$

at least for $u \ge 0$, we might say that $\lfloor u \rfloor$ is the "integer part" of $u$. the "fractional part" of $u$ is whatever is left:

$$ 0 \le u - \lfloor u \rfloor < 1 $$

so, if what we want left is a fractional delay of $\alpha$ samples where $0 \le \alpha < 1$, then we want to choose an integer $P$ to pad the input such that $\alpha$ is the fractional part remaining in the output delay after stripping away the integer part, $\lfloor rP \rfloor$. that is, given the sample rate ratio $r$, and fractional delay $\alpha$, we want to choose $P$ such that:

$$ rP = \lfloor rP \rfloor + \alpha $$

or

$$ \alpha = rP - \lfloor rP \rfloor \ . $$

after thinking about this a while, the only algorithm i can suggest is to start with $P=1$ and iteratively increment $P$ so that the above equation is close enough to be accurate. that is, given an error constraint on $\alpha$, (call it $0 < \epsilon \ll 1$), increment $P$ until

$$ \left|\alpha - \left( rP - \lfloor rP \rfloor \right) \right| < \epsilon $$

pad the input with $P$ samples of zero, and strip the output of $\lfloor rP \rfloor$ samples, and you will be left with $\left( rP - \lfloor rP \rfloor \right)$ samples of delay.

$\endgroup$
  • $\begingroup$ wow. i can't exactly decode everything i wrote here. $\endgroup$ – robert bristow-johnson Jul 9 '18 at 4:13
0
$\begingroup$

If the resampling is not a ratio of small integers, the it might be possible to approximate a fractional delay by added some number leading zero samples before resampling and the removing some number after.

One can also resample to any rate by interpolation (Sinc kernel for high quality) of each new sample, after any needed low pass filtering of course.

$\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.