aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-11-13 22:58:15 -0500
committerThomas Tsou <tom@tsou.cc>2013-11-15 23:35:07 -0500
commit34bbef754f6c053871ed1e2345c93d2586ce4616 (patch)
tree0c60a55bac40948090275c9a806347c2cb181abc
parent2c1f85a10c2c567ebc763b53acd335d4dc6f1e17 (diff)
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>
-rw-r--r--Transceiver52M/sigProcLib.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index d5f92b7..3d2bba6 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -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;
}
}