aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-11-09 22:08:51 -0500
committerThomas Tsou <tom@tsou.cc>2013-11-15 23:35:07 -0500
commit0e0e1f43634cb6135f1620f97c84c9453325f005 (patch)
tree6a917d8709adbd2938ba7a3a8f67a91a09e8d931
parentd0f3ca3e94be458cde4b2654681ba2e7e21197b4 (diff)
Transceiver52M: Setup sinc() call directly with table lookup
On Beagle Board the call into the sinc() function is generating a lot of load on the peak interpolation. Simplify the sinc() function with a dedicated table lookup. Eventually, this table may be removed in favour of using a precomputed filterbank for fractional delay determination. Signed-off-by: Thomas Tsou <tom@tsou.cc>
-rw-r--r--Transceiver52M/sigProcLib.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index efa8f5d..d0dcde5 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -43,6 +43,7 @@ using namespace GSM;
/** Lookup tables for trigonometric approximation */
float cosTable[TABLESIZE+1]; // add 1 element for wrap around
float sinTable[TABLESIZE+1];
+float sincTable[TABLESIZE+1];
/** Constants */
static const float M_PI_F = (float)M_PI;
@@ -821,10 +822,29 @@ signalVector *modulateBurst(const BitVector &wBurst, int guardPeriodLength,
return modulateBurstBasic(wBurst, guardPeriodLength, sps);
}
+void generateSincTable()
+{
+ float x;
+
+ for (int i = 0; i < TABLESIZE; i++) {
+ x = (float) i / TABLESIZE * 8 * M_PI;
+ if (fabs(x) < 0.01) {
+ sincTable[i] = 1.0f;
+ continue;
+ }
+
+ sincTable[i] = sinf(x) / x;
+ }
+}
+
float sinc(float x)
{
- if ((x >= 0.01F) || (x <= -0.01F)) return (sinLookup(x)/x);
- return 1.0F;
+ if (fabs(x) >= 8 * M_PI)
+ return 0.0;
+
+ int index = (int) floorf(fabs(x) / (8 * M_PI) * TABLESIZE);
+
+ return sincTable[index];
}
/*
@@ -1685,6 +1705,7 @@ bool sigProcLibSetup(int sps)
return false;
initTrigTables();
+ generateSincTable();
initGMSKRotationTables(sps);
GSMPulse1 = generateGSMPulse(1, 2);