sigproc: Remove dynamic SPS configuration

Samples per symbol used by the transceiver is not configurable through
the socket interface once running, so stop pretending like it could be.
Initialize all tables and midambles at start.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 526153e..df41eac 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -198,7 +198,7 @@
     return false;
   }
 
-  if (!sigProcLibSetup(mSPSTx)) {
+  if (!sigProcLibSetup()) {
     LOG(ALERT) << "Failed to initialize signal processing library";
     return false;
   }
@@ -898,7 +898,6 @@
       sprintf(response, "RSP SETTSC 1 %d", TSC);
     else {
       mTSC = TSC;
-      generateMidamble(mSPSRx, TSC);
       sprintf(response,"RSP SETTSC 0 %d", TSC);
     }
   }
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index b5160ca..de8b1cf 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -55,8 +55,8 @@
 static const float M_1_2PI_F = 1/M_2PI_F;
 
 /* Precomputed rotation vectors */
-static signalVector *GMSKRotationN = NULL;
-static signalVector *GMSKReverseRotationN = NULL;
+static signalVector *GMSKRotation4 = NULL;
+static signalVector *GMSKReverseRotation4 = NULL;
 static signalVector *GMSKRotation1 = NULL;
 static signalVector *GMSKReverseRotation1 = NULL;
 
@@ -115,8 +115,8 @@
 
 CorrelationSequence *gMidambles[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
 CorrelationSequence *gRACHSequence = NULL;
-PulseSequence *GSMPulse = NULL;
 PulseSequence *GSMPulse1 = NULL;
+PulseSequence *GSMPulse4 = NULL;
 
 void sigProcLibDestroy()
 {
@@ -130,21 +130,21 @@
     delayFilters[i] = NULL;
   }
 
-  delete GMSKRotationN;
-  delete GMSKReverseRotationN;
   delete GMSKRotation1;
   delete GMSKReverseRotation1;
+  delete GMSKRotation4;
+  delete GMSKReverseRotation4;
   delete gRACHSequence;
-  delete GSMPulse;
   delete GSMPulse1;
+  delete GSMPulse4;
 
-  GMSKRotationN = NULL;
   GMSKRotation1 = NULL;
-  GMSKReverseRotationN = NULL;
+  GMSKRotation4 = NULL;
+  GMSKReverseRotation4 = NULL;
   GMSKReverseRotation1 = NULL;
   gRACHSequence = NULL;
-  GSMPulse = NULL;
   GSMPulse1 = NULL;
+  GSMPulse4 = NULL;
 }
 
 // dB relative to 1.0.
@@ -253,7 +253,7 @@
 
 
 /** compute e^(-jx) via lookup table. */
-complex expjLookup(float x)
+static complex expjLookup(float x)
 {
   float arg = x*M_1_2PI_F;
   while (arg > 1.0F) arg -= 1.0F;
@@ -268,28 +268,33 @@
 }
 
 /** Library setup functions */
-void initTrigTables() {
+static void initTrigTables() {
   for (int i = 0; i < TABLESIZE+1; i++) {
     cosTable[i] = cos(2.0*M_PI*i/TABLESIZE);
     sinTable[i] = sin(2.0*M_PI*i/TABLESIZE);
   }
 }
 
-void initGMSKRotationTables(int sps)
+/*
+ * Initialize 4 sps and 1 sps rotation tables
+ */
+static void initGMSKRotationTables()
 {
-  GMSKRotationN = new signalVector(157 * sps);
-  GMSKReverseRotationN = new signalVector(157 * sps);
-  signalVector::iterator rotPtr = GMSKRotationN->begin();
-  signalVector::iterator revPtr = GMSKReverseRotationN->begin();
+  size_t len1 = 157, len4 = 625;
+
+  GMSKRotation4 = new signalVector(len4);
+  GMSKReverseRotation4 = new signalVector(len4);
+  signalVector::iterator rotPtr = GMSKRotation4->begin();
+  signalVector::iterator revPtr = GMSKReverseRotation4->begin();
   float phase = 0.0;
-  while (rotPtr != GMSKRotationN->end()) {
+  while (rotPtr != GMSKRotation4->end()) {
     *rotPtr++ = expjLookup(phase);
     *revPtr++ = expjLookup(-phase);
-    phase += M_PI_F / 2.0F / (float) sps;
+    phase += M_PI_F / 2.0F / 4.0;
   }
 
-  GMSKRotation1 = new signalVector(157);
-  GMSKReverseRotation1 = new signalVector(157);
+  GMSKRotation1 = new signalVector(len1);
+  GMSKReverseRotation1 = new signalVector(len1);
   rotPtr = GMSKRotation1->begin();
   revPtr = GMSKReverseRotation1->begin();
   phase = 0.0;
@@ -316,7 +321,7 @@
   if (sps == 1)
     b = GMSKRotation1;
   else
-    b = GMSKRotationN;
+    b = GMSKRotation4;
 
   mul_complex((float *) out->begin(),
               (float *) a->begin(),
@@ -327,7 +332,7 @@
   if (sps == 1)
     rotPtr = GMSKRotation1->begin();
   else
-    rotPtr = GMSKRotationN->begin();
+    rotPtr = GMSKRotation4->begin();
 
   if (x.isReal()) {
     while (xPtr < x.end()) {
@@ -344,14 +349,16 @@
 #endif
 }
 
-static void GMSKReverseRotate(signalVector &x, int sps)
+static bool GMSKReverseRotate(signalVector &x, int sps)
 {
   signalVector::iterator rotPtr, xPtr= x.begin();
 
   if (sps == 1)
     rotPtr = GMSKReverseRotation1->begin();
+  else if (sps == 4)
+    rotPtr = GMSKReverseRotation4->begin();
   else
-    rotPtr = GMSKReverseRotationN->begin();
+    return false;
 
   if (x.isReal()) {
     while (xPtr < x.end()) {
@@ -365,6 +372,8 @@
       xPtr++;
     }
   }
+
+  return true;
 }
 
 signalVector *convolve(const signalVector *x,
@@ -512,7 +521,7 @@
   return true;
 }
 
-static PulseSequence *generateGSMPulse(int sps, int symbolLength)
+static PulseSequence *generateGSMPulse(int sps)
 {
   int len;
   float arg, avg, center;
@@ -535,9 +544,7 @@
     len = 16;
     break;
   default:
-    len = sps * symbolLength;
-    if (len < 4)
-      len = 4;
+    len = 4;
   }
 
   pulse->c0_buffer = convolve_h_alloc(len);
@@ -713,8 +720,8 @@
   if (guard_len < 4)
     guard_len = 4;
 
-  c0_pulse = GSMPulse->c0;
-  c1_pulse = GSMPulse->c1;
+  c0_pulse = GSMPulse4->c0;
+  c1_pulse = GSMPulse4->c1;
 
   burst_len = sps * (bits.size() + guard_len);
 
@@ -794,7 +801,7 @@
   if (sps == 1)
     pulse = GSMPulse1->c0;
   else
-    pulse = GSMPulse->c0;
+    pulse = GSMPulse4->c0;
 
   burst_len = sps * (bits.size() + guard_len);
 
@@ -831,7 +838,7 @@
     return modulateBurstBasic(wBurst, guardPeriodLength, sps);
 }
 
-void generateSincTable()
+static void generateSincTable()
 {
   float x;
 
@@ -1140,7 +1147,7 @@
   return true;
 }
 
-bool generateMidamble(int sps, int tsc)
+static bool generateMidamble(int sps, int tsc)
 {
   bool status = true;
   float toa;
@@ -1216,7 +1223,7 @@
   return status;
 }
 
-bool generateRACHSequence(int sps)
+static bool generateRACHSequence(int sps)
 {
   bool status = true;
   float toa;
@@ -1678,8 +1685,8 @@
 
   signalVector::iterator dPtr = postForward->begin();
   signalVector::iterator dBackPtr;
-  signalVector::iterator rotPtr = GMSKRotationN->begin();
-  signalVector::iterator revRotPtr = GMSKReverseRotationN->begin();
+  signalVector::iterator rotPtr = GMSKRotation4->begin();
+  signalVector::iterator revRotPtr = GMSKReverseRotation4->begin();
 
   signalVector *DFEoutput = new signalVector(postForward->size());
   signalVector::iterator DFEItr = DFEoutput->begin();
@@ -1719,23 +1726,18 @@
   return burstBits;
 }
 
-bool sigProcLibSetup(int sps)
+bool sigProcLibSetup()
 {
-  if ((sps != 1) && (sps != 4))
-    return false;
-
   initTrigTables();
   generateSincTable();
-  initGMSKRotationTables(sps);
+  initGMSKRotationTables();
 
-  GSMPulse1 = generateGSMPulse(1, 2);
-  if (sps > 1)
-    GSMPulse = generateGSMPulse(sps, 2);
+  GSMPulse1 = generateGSMPulse(1);
+  GSMPulse4 = generateGSMPulse(4);
 
-  if (!generateRACHSequence(1)) {
-    sigProcLibDestroy();
-    return false;
-  }
+  generateRACHSequence(1);
+  for (int tsc = 0; tsc < 8; tsc++)
+    generateMidamble(1, tsc);
 
   generateDelayFilters();
 
diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h
index 8685f2d..c6dd172 100644
--- a/Transceiver52M/sigProcLib.h
+++ b/Transceiver52M/sigProcLib.h
@@ -49,7 +49,7 @@
 float vectorPower(const signalVector &x);
 
 /** Setup the signal processing library */
-bool sigProcLibSetup(int sps);
+bool sigProcLibSetup();
 
 /** Destroy the signal processing library */
 void sigProcLibDestroy(void);
@@ -152,22 +152,6 @@
 		 complex scale);
 
 /**
-        Generate a modulated GSM midamble, stored within the library.
-        @param gsmPulse The GSM pulse used for modulation.
-        @param sps The number of samples per GSM symbol.
-        @param TSC The training sequence [0..7]
-        @return Success.
-*/
-bool generateMidamble(int sps, int tsc);
-/**
-        Generate a modulated RACH sequence, stored within the library.
-        @param gsmPulse The GSM pulse used for modulation.
-        @param sps The number of samples per GSM symbol.
-        @return Success.
-*/
-bool generateRACHSequence(int sps);
-
-/**
         Energy detector, checks to see if received burst energy is above a threshold.
         @param rxBurst The received GSM burst of interest.
         @param windowLength The number of burst samples used to compute burst energy