From 0e0e1f43634cb6135f1620f97c84c9453325f005 Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Sat, 9 Nov 2013 22:08:51 -0500 Subject: 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 --- Transceiver52M/sigProcLib.cpp | 25 +++++++++++++++++++++++-- 1 file 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); -- cgit v1.2.3