aboutsummaryrefslogtreecommitdiffstats
path: root/src/GainControl.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-11-21 22:12:14 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-11-21 22:12:14 +0100
commit5fe36a627405b8fc65bdb212a6d505b9a6c8e489 (patch)
tree8646d654e0467be8603c5ad37fb6cd89656dfd26 /src/GainControl.cpp
parent477ac4639a7c7f74f07a6164096fc7de102528ff (diff)
parentf84065c3cc6fff0edb771f85190f7228f4d740b6 (diff)
downloaddabmod-5fe36a627405b8fc65bdb212a6d505b9a6c8e489.tar.gz
dabmod-5fe36a627405b8fc65bdb212a6d505b9a6c8e489.tar.bz2
dabmod-5fe36a627405b8fc65bdb212a6d505b9a6c8e489.zip
Merge branch 'dexter' into next
Diffstat (limited to 'src/GainControl.cpp')
-rw-r--r--src/GainControl.cpp43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/GainControl.cpp b/src/GainControl.cpp
index b781640..84cf065 100644
--- a/src/GainControl.cpp
+++ b/src/GainControl.cpp
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -127,21 +127,25 @@ int GainControl::internal_process(Buffer* const dataIn, Buffer* dataOut)
if ((sizeIn % m_frameSize) != 0) {
PDEBUG("%zu != %zu\n", sizeIn, m_frameSize);
- throw std::runtime_error(
- "GainControl::process input size not valid!");
+ throw std::runtime_error("GainControl::process input size not valid!");
}
const auto constantGain4 = _mm_set1_ps(constantGain);
for (size_t i = 0; i < sizeIn; i += m_frameSize) {
- gain128.m = computeGain(in, m_frameSize);
+ // Do not apply gain computation to the NULL symbol, which either
+ // is blank or contains TII. Apply the gain calculation from the next
+ // symbol on the NULL symbol to get consistent TII power.
+ if (i > 0) {
+ gain128.m = computeGain(in, m_frameSize);
+ }
+ else {
+ gain128.m = computeGain(in + m_frameSize, m_frameSize);
+ }
gain128.m = _mm_mul_ps(gain128.m, constantGain4);
PDEBUG("********** Gain: %10f **********\n", gain128.f[0]);
- ////////////////////////////////////////////////////////////////////////
- // Applying gain to output data
- ////////////////////////////////////////////////////////////////////////
for (size_t sample = 0; sample < m_frameSize; ++sample) {
out[sample] = _mm_mul_ps(in[sample], gain128.m);
}
@@ -163,7 +167,12 @@ int GainControl::internal_process(Buffer* const dataIn, Buffer* dataOut)
}
for (size_t i = 0; i < sizeIn; i += m_frameSize) {
- gain = constantGain * computeGain(in, m_frameSize);
+ // Do not apply gain computation to the NULL symbol, which either
+ // is blank or contains TII. Apply the gain calculation from the next
+ // symbol on the NULL symbol to get consistent TII power.
+ gain = constantGain * (i > 0 ?
+ computeGain(in, m_frameSize) :
+ computeGain(in + m_frameSize, m_frameSize));
PDEBUG("********** Gain: %10f **********\n", gain);
@@ -574,3 +583,21 @@ const string GainControl::get_parameter(const string& parameter) const
return ss.str();
}
+const json::map_t GainControl::get_all_values() const
+{
+ json::map_t map;
+ map["digital"].v = m_digGain;
+ switch (m_gainmode) {
+ case GainMode::GAIN_FIX:
+ map["mode"].v = "fix";
+ break;
+ case GainMode::GAIN_MAX:
+ map["mode"].v = "max";
+ break;
+ case GainMode::GAIN_VAR:
+ map["mode"].v = "var";
+ break;
+ }
+ map["var"].v = m_var_variance_rc;
+ return map;
+}