aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/sigProcLib.cpp
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-11-09 22:19:19 -0500
committerThomas Tsou <tom@tsou.cc>2013-11-15 23:35:07 -0500
commit94edaaeee653a03f6734782169f6ba3c042371e1 (patch)
tree7c2dd52ec46273db16adbd023db6a6bea03ebba7 /Transceiver52M/sigProcLib.cpp
parent0e0e1f43634cb6135f1620f97c84c9453325f005 (diff)
Transceiver52M: Allow separate in/out vectors for delay and decimation
Allow non-in-place use of the delay setting. Internally, the delay call creates a new vector and copies the contents back into the original. Instead, provide the option to return the computed output vector directly and remove an an extra copy in the process. Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/sigProcLib.cpp')
-rw-r--r--Transceiver52M/sigProcLib.cpp113
1 files changed, 62 insertions, 51 deletions
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index d0dcde5..12dcf00 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -893,11 +893,11 @@ void generateDelayFilters()
}
}
-bool delayVector(signalVector &wBurst, float delay)
+signalVector *delayVector(signalVector *in, signalVector *out, float delay)
{
int whole, index;
float frac;
- signalVector *h, *shift;
+ signalVector *h, *shift, *fshift = NULL;
whole = floor(delay);
frac = delay - whole;
@@ -907,35 +907,44 @@ bool delayVector(signalVector &wBurst, float delay)
index = floorf(frac * (float) DELAYFILTS);
h = delayFilters[index];
- shift = convolve(&wBurst, h, NULL, NO_DELAY);
- if (!shift)
- return false;
-
- wBurst.clone(*shift);
- delete shift;
+ fshift = convolve(in, h, NULL, NO_DELAY);
+ if (!fshift)
+ return NULL;
}
+ if (!fshift)
+ shift = new signalVector(*in);
+ else
+ shift = fshift;
+
/* Integer sample shift */
if (whole < 0) {
whole = -whole;
- signalVector::iterator wBurstItr = wBurst.begin();
- signalVector::iterator shiftedItr = wBurst.begin() + whole;
+ signalVector::iterator wBurstItr = shift->begin();
+ signalVector::iterator shiftedItr = shift->begin() + whole;
- while (shiftedItr < wBurst.end())
+ while (shiftedItr < shift->end())
*wBurstItr++ = *shiftedItr++;
- while (wBurstItr < wBurst.end())
+
+ while (wBurstItr < shift->end())
*wBurstItr++ = 0.0;
- } else {
- signalVector::iterator wBurstItr = wBurst.end() - 1;
- signalVector::iterator shiftedItr = wBurst.end() - 1 - whole;
+ } else if (whole >= 0) {
+ signalVector::iterator wBurstItr = shift->end() - 1;
+ signalVector::iterator shiftedItr = shift->end() - 1 - whole;
- while (shiftedItr >= wBurst.begin())
+ while (shiftedItr >= shift->begin())
*wBurstItr-- = *shiftedItr--;
- while (wBurstItr >= wBurst.begin())
+
+ while (wBurstItr >= shift->begin())
*wBurstItr-- = 0.0;
}
- return true;
+ if (!out)
+ return shift;
+
+ out->clone(*shift);
+ delete shift;
+ return out;
}
signalVector *gaussianNoise(int length,
@@ -1488,57 +1497,59 @@ int analyzeTrafficBurst(signalVector &rxBurst, unsigned tsc, float thresh,
return 1;
}
-signalVector *decimateVector(signalVector &wVector,
- int decimationFactor)
+signalVector *decimateVector(signalVector &wVector, size_t factor)
{
-
- if (decimationFactor <= 1) return NULL;
+ signalVector *dec;
- signalVector *decVector = new signalVector(wVector.size()/decimationFactor);
- decVector->isReal(wVector.isReal());
+ if (factor <= 1)
+ return NULL;
- signalVector::iterator vecItr = decVector->begin();
- for (unsigned int i = 0; i < wVector.size();i+=decimationFactor)
- *vecItr++ = wVector[i];
+ dec = new signalVector(wVector.size() / factor);
+ dec->isReal(wVector.isReal());
- return decVector;
-}
+ signalVector::iterator itr = dec->begin();
+ for (size_t i = 0; i < wVector.size(); i += factor)
+ *itr++ = wVector[i];
+ return dec;
+}
SoftVector *demodulateBurst(signalVector &rxBurst, int sps,
- complex channel, float TOA)
+ complex channel, float TOA)
{
- scaleVector(rxBurst,((complex) 1.0)/channel);
- delayVector(rxBurst,-TOA);
+ signalVector *delay, *dec = NULL;
+ SoftVector *bits;
- signalVector *shapedBurst = &rxBurst;
+ scaleVector(rxBurst, ((complex) 1.0) / channel);
+ delay = delayVector(&rxBurst, NULL, -TOA);
- // shift up by a quarter of a frequency
- // ignore starting phase, since spec allows for discontinuous phase
- GMSKReverseRotate(*shapedBurst, sps);
+ /* Shift up by a quarter of a frequency */
+ GMSKReverseRotate(*delay, sps);
- // run through slicer
+ /* Decimate and slice */
if (sps > 1) {
- signalVector *decShapedBurst = decimateVector(*shapedBurst, sps);
- shapedBurst = decShapedBurst;
+ dec = decimateVector(*delay, sps);
+ delete delay;
+ delay = NULL;
+ } else {
+ dec = delay;
}
- vectorSlicer(shapedBurst);
+ vectorSlicer(dec);
- SoftVector *burstBits = new SoftVector(shapedBurst->size());
+ bits = new SoftVector(dec->size());
- SoftVector::iterator burstItr = burstBits->begin();
- signalVector::iterator shapedItr = shapedBurst->begin();
- for (; shapedItr < shapedBurst->end(); shapedItr++)
- *burstItr++ = shapedItr->real();
+ SoftVector::iterator bit_itr = bits->begin();
+ signalVector::iterator burst_itr = dec->begin();
- if (sps > 1)
- delete shapedBurst;
+ for (; burst_itr < dec->end(); burst_itr++)
+ *bit_itr++ = burst_itr->real();
- return burstBits;
+ delete dec;
+ return bits;
}
-
+
// Assumes symbol-spaced sampling!!!
// Based upon paper by Al-Dhahir and Cioffi
bool designDFE(signalVector &channelResponse,
@@ -1586,7 +1597,7 @@ bool designDFE(signalVector &channelResponse,
signalVector G1new = G0;
scaleVector(G1new,k*(-1.0));
addVector(G1new,G1);
- delayVector(G1new,-1.0);
+ delayVector(&G1new, &G1new, -1.0);
scaleVector(G0new,1.0/sqrtf(1.0+k.norm2()));
scaleVector(G1new,1.0/sqrtf(1.0+k.norm2()));
@@ -1644,7 +1655,7 @@ SoftVector *equalizeBurst(signalVector &rxBurst,
{
signalVector *postForwardFull;
- if (!delayVector(rxBurst, -TOA))
+ if (!delayVector(&rxBurst, &rxBurst, -TOA))
return NULL;
postForwardFull = convolve(&rxBurst, &w, NULL,