mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 17:28:50 -05:00
Improve normalisation, so output doesn't exceed 1
This commit is contained in:
parent
fdd73c9d99
commit
a5214e3002
@ -89,18 +89,38 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Calculate maximum output of filter, assuming upsampled bipolar input E.g. [1 0 0 -1 0 0..]
|
// Calculate maximum output of filter, assuming upsampled bipolar input E.g. [1 0 0 -1 0 0..]
|
||||||
// This doesn't necessarily include the centre tap, so we try each offset
|
// This doesn't necessarily include the centre tap, as ISI there should be zero,
|
||||||
double maxGain = 0.0;
|
// it's often at the midpoint between two symbols. However, depending on beta,
|
||||||
for (i = 0; i < samplesPerSymbol; i++)
|
// the input that produces the worst case can vary, so we currently try them all
|
||||||
|
double maxGain = 0;
|
||||||
|
for (int input = 0; input < (1 << symbolSpan); input++)
|
||||||
{
|
{
|
||||||
double g = 0.0;
|
double maxV = 0;
|
||||||
for (j = 0; j < (int)m_taps.size() - 1; j += samplesPerSymbol)
|
for(int i = 0; i < nTaps; i++) {
|
||||||
g += std::fabs(2.0 * m_taps[j]);
|
m_samples[i] = 0;
|
||||||
if ((i & 1) == 0)
|
}
|
||||||
g += std::fabs(m_taps[j]);
|
for (int i = 0; i < symbolSpan; i++)
|
||||||
if (g > maxGain)
|
{
|
||||||
maxGain = g;
|
Type sym = (input >> i) & 1 ? 1 : -1;
|
||||||
|
for (int j = 0; j < samplesPerSymbol; j++)
|
||||||
|
{
|
||||||
|
Type out;
|
||||||
|
if (j == 1) {
|
||||||
|
out = filter(sym);
|
||||||
|
} else {
|
||||||
|
out = filter(0);
|
||||||
|
}
|
||||||
|
double outAbs = abs(out);
|
||||||
|
if (outAbs > maxV) {
|
||||||
|
maxV = outAbs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (maxV > maxGain) {
|
||||||
|
maxGain = maxV;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale up so maximum out is 1
|
// Scale up so maximum out is 1
|
||||||
for(i = 0; i < (int)m_taps.size(); i++)
|
for(i = 0; i < (int)m_taps.size(); i++)
|
||||||
m_taps[i] /= maxGain;
|
m_taps[i] /= maxGain;
|
||||||
|
Loading…
Reference in New Issue
Block a user