Transceiver52M: Make GSM pulse filter internal to implementation

There is no reason expose the pulse shaping filter outside of the
signal processing calls. The main transceiver object makes no use
of the filter and there's no reason to pass it around.

Initialize the pulse shape with the signal processing library, and
maintain an internal static member like many of the other library
variables. Similarly destroy the object when the library is closed.

Signed-off-by: Thomas Tsou <tom@tsou.cc>
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index b60496a..a7c629e 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -57,15 +57,12 @@
 	 mControlSocket(wBasePort+1,TRXAddress,wBasePort+101),
 	 mClockSocket(wBasePort,TRXAddress,wBasePort+100)
 {
-  //GSM::Time startTime(0,0);
-  //GSM::Time startTime(gHyperframe/2 - 4*216*60,0);
   GSM::Time startTime(random() % gHyperframe,0);
 
   mFIFOServiceLoopThread = new Thread(32768);  ///< thread to push bursts into transmit FIFO
   mControlServiceLoopThread = new Thread(32768);       ///< thread to process control messages from GSM core
   mTransmitPriorityQueueServiceLoopThread = new Thread(32768);///< thread to process transmit bursts from GSM core
 
-
   mSPS = wSPS;
   mRadioInterface = wRadioInterface;
   mTransmitLatency = wTransmitLatency;
@@ -75,54 +72,65 @@
   mRadioInterface->getClock()->set(startTime);
   mMaxExpectedDelay = 0;
 
-  // generate pulse and setup up signal processing library
-  gsmPulse = generateGSMPulse(2, mSPS);
-  LOG(DEBUG) << "gsmPulse: " << *gsmPulse;
-  sigProcLibSetup(mSPS);
-
   txFullScale = mRadioInterface->fullScaleInputValue();
   rxFullScale = mRadioInterface->fullScaleOutputValue();
 
-  // initialize filler tables with dummy bursts, initialize other per-timeslot variables
-  for (int i = 0; i < 8; i++) {
-    signalVector* modBurst = modulateBurst(gDummyBurst,*gsmPulse,
-					   8 + (i % 4 == 0),
-					   mSPS);
-    scaleVector(*modBurst,txFullScale);
-    fillerModulus[i]=26;
-    for (int j = 0; j < 102; j++) {
-      fillerTable[j][i] = new signalVector(*modBurst);
-    }
-    delete modBurst;
-    mChanType[i] = NONE;
-    channelResponse[i] = NULL;
-    DFEForward[i] = NULL;
-    DFEFeedback[i] = NULL;
-    channelEstimateTime[i] = startTime;
-  }
-
   mOn = false;
   mTxFreq = 0.0;
   mRxFreq = 0.0;
   mPower = -10;
   mEnergyThreshold = INIT_ENERGY_THRSHD;
   prevFalseDetectionTime = startTime;
+
 }
 
 Transceiver::~Transceiver()
 {
-  delete gsmPulse;
   sigProcLibDestroy();
   mTransmitPriorityQueue.clear();
 }
-  
+
+bool Transceiver::init()
+{
+  if (!sigProcLibSetup(mSPS)) {
+    LOG(ALERT) << "Failed to initialize signal processing library";
+    return false;
+  }
+
+  // initialize filler tables with dummy bursts
+  for (int i = 0; i < 8; i++) {
+    signalVector* modBurst = modulateBurst(gDummyBurst,
+					   8 + (i % 4 == 0),
+					   mSPS);
+    if (!modBurst) {
+      sigProcLibDestroy();
+      LOG(ALERT) << "Failed to initialize filler table";
+      return false;
+    }
+
+    scaleVector(*modBurst,txFullScale);
+    fillerModulus[i]=26;
+    for (int j = 0; j < 102; j++) {
+      fillerTable[j][i] = new signalVector(*modBurst);
+    }
+
+    delete modBurst;
+    mChanType[i] = NONE;
+    channelResponse[i] = NULL;
+    DFEForward[i] = NULL;
+    DFEFeedback[i] = NULL;
+    channelEstimateTime[i] = mTransmitDeadlineClock;
+  }
+
+  return true;
+}
 
 void Transceiver::addRadioVector(BitVector &burst,
 				 int RSSI,
 				 GSM::Time &wTime)
 {
   // modulate and stick into queue 
-  signalVector* modBurst = modulateBurst(burst,*gsmPulse,
+  signalVector* modBurst = modulateBurst(burst,
 					 8 + (wTime.TN() % 4 == 0),
 					 mSPS);
   scaleVector(*modBurst,txFullScale * pow(10,-RSSI/10));
@@ -135,10 +143,7 @@
 #ifdef TRANSMIT_LOGGING
 void Transceiver::unModulateVector(signalVector wVector) 
 {
-  SoftVector *burst = demodulateBurst(wVector,
-				   *gsmPulse,
-				   mSPS,
-				   1.0,0.0);
+  SoftVector *burst = demodulateBurst(wVector, mSPS, 1.0, 0.0);
   LOG(DEBUG) << "LOGGED BURST: " << *burst;
 
 /*
@@ -415,7 +420,6 @@
   if ((rxBurst) && (success)) {
     if ((corrType==RACH) || (!needDFE)) {
       burst = demodulateBurst(*vectorBurst,
-			      *gsmPulse,
 			      mSPS,
 			      amplitude,TOA);
     }
@@ -497,7 +501,7 @@
         // Prepare for thread start
         mPower = -20;
         mRadioInterface->start();
-        generateRACHSequence(*gsmPulse, mSPS);
+        generateRACHSequence(mSPS);
 
         // Start radio interface threads.
         mFIFOServiceLoopThread->start((void * (*)(void*))FIFOServiceLoopAdapter,(void*) this);
@@ -589,8 +593,8 @@
       sprintf(response,"RSP SETTSC 1 %d",TSC);
     else {
       mTSC = TSC;
-      generateMidamble(*gsmPulse, mSPS, TSC);
-      sprintf(response,"RSP SETTSC 0 %d",TSC);
+      generateMidamble(mSPS, TSC);
+      sprintf(response,"RSP SETTSC 0 %d", TSC);
     }
   }
   else if (strcmp(command,"SETSLOT")==0) {