diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-05-04 13:27:10 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-05-04 13:58:50 +0200 |
commit | 8bb7afbdc7cab7010c5bfb5a0b750a62d953aedf (patch) | |
tree | c1896722bf78336b62a51ff43c0cd3c0a0e6e76f /src/GainControl.cpp | |
parent | f0bb1e24952c7e261ba13907c0a5d8c3e1d198ca (diff) | |
download | dabmod-8bb7afbdc7cab7010c5bfb5a0b750a62d953aedf.tar.gz dabmod-8bb7afbdc7cab7010c5bfb5a0b750a62d953aedf.tar.bz2 dabmod-8bb7afbdc7cab7010c5bfb5a0b750a62d953aedf.zip |
Revert "Normalise TII to 1/sqrt(48)" and fix TII level in GainControl
This reverts commit c7961c2e8688d6db2a87b5079c60a04b8fe37e74.
Diffstat (limited to 'src/GainControl.cpp')
-rw-r--r-- | src/GainControl.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/GainControl.cpp b/src/GainControl.cpp index c111de3..d90da45 100644 --- a/src/GainControl.cpp +++ b/src/GainControl.cpp @@ -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); |