Transceiver52M: sigproc: Wrap internal phase on frequency shift

The call into table lookup will loop on values outside of the
table range. With continuously increasing phase, this leads
to an eventual permanent hard spin. Wrap the phase value to
prevent that from happening.

Signed-off-by: Thomas Tsou <tom@tsou.cc>
This commit is contained in:
Thomas Tsou 2013-11-13 22:58:15 -05:00
parent 2c1f85a10c
commit 34bbef754f
1 changed files with 4 additions and 0 deletions

View File

@ -613,6 +613,10 @@ signalVector* frequencyShift(signalVector *y,
while (xP < xPEnd) {
(*yP++) = (*xP++)*expjLookup(phase);
phase += freq;
if (phase > 2 * M_PI)
phase -= 2 * M_PI;
else if (phase < -2 * M_PI)
phase += 2 * M_PI;
}
}