diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-09-25 02:15:22 +0200 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-09-25 02:15:22 +0200 |
commit | b33aa5ab2c06e4b246ce8297f6d1f528d19c7f3a (patch) | |
tree | 55d3eb9726344509b682d2b2753eb31204f93daa /src/engine | |
parent | feb1a7af0a86babdba20690ff86b30a39388e556 (diff) |
engine/enginexfader: Use CSAMPLE_GAIN for getXfadeGains()
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/enginemaster.cpp | 6 | ||||
-rw-r--r-- | src/engine/enginexfader.cpp | 28 | ||||
-rw-r--r-- | src/engine/enginexfader.h | 17 |
3 files changed, 29 insertions, 22 deletions
diff --git a/src/engine/enginemaster.cpp b/src/engine/enginemaster.cpp index 87c6294067..b38914eaea 100644 --- a/src/engine/enginemaster.cpp +++ b/src/engine/enginemaster.cpp @@ -492,7 +492,7 @@ void EngineMaster::process(const int iBufferSize) { } // Calculate the crossfader gains for left and right side of the crossfader - double crossfaderLeftGain, crossfaderRightGain; + CSAMPLE_GAIN crossfaderLeftGain, crossfaderRightGain; EngineXfader::getXfadeGains(m_pCrossfader->get(), m_pXFaderCurve->get(), m_pXFaderCalibration->get(), m_pXFaderMode->get(), @@ -503,9 +503,9 @@ void EngineMaster::process(const int iBufferSize) { // m_masterGain takes care of applying the attenuation from // channel volume faders, crossfader, and talkover ducking. // Talkover is mixed in later according to the configured MicMonitorMode - m_masterGain.setGains(static_cast<CSAMPLE_GAIN>(crossfaderLeftGain), + m_masterGain.setGains(crossfaderLeftGain, 1.0f, - static_cast<CSAMPLE_GAIN>(crossfaderRightGain), + crossfaderRightGain, m_pTalkoverDucking->getGain(m_iBufferSize / 2)); for (int o = EngineChannel::LEFT; o <= EngineChannel::RIGHT; o++) { diff --git a/src/engine/enginexfader.cpp b/src/engine/enginexfader.cpp index 47eddfb639..55f1aed606 100644 --- a/src/engine/enginexfader.cpp +++ b/src/engine/enginexfader.cpp @@ -13,9 +13,13 @@ double EngineXfader::getPowerCalibration(double transform) { return pow(0.5, 1.0 / transform); } -void EngineXfader::getXfadeGains( - double xfadePosition, double transform, double powerCalibration, - double curve, bool reverse, double* gain1, double* gain2) { +void EngineXfader::getXfadeGains(double xfadePosition, + double transform, + double powerCalibration, + double curve, + bool reverse, + CSAMPLE_GAIN* gain1, + CSAMPLE_GAIN* gain2) { if (gain1 == NULL || gain2 == NULL) { return; } @@ -33,23 +37,23 @@ void EngineXfader::getXfadeGains( if (xfadePositionLeft < 0) { // on left side xfadePositionLeft *= -1; - *gain2 = (1.0 - (1.0 * pow(xfadePositionLeft, transform))); + *gain2 = static_cast<CSAMPLE_GAIN>(1.0 - (1.0 * pow(xfadePositionLeft, transform))); } else { - *gain2 = 1.0; + *gain2 = 1.0f; } if(xfadePositionRight > 0) { // right side - *gain1 = (1.0 - (1.0 * pow(xfadePositionRight, transform))); + *gain1 = static_cast<CSAMPLE_GAIN>(1.0 - (1.0 * pow(xfadePositionRight, transform))); } else { - *gain1 = 1.0; + *gain1 = 1.0f; } //prevent phase reversal if (*gain1 < 0.0) { - *gain1 = 0.0; + *gain1 = 0.0f; } if (*gain2 < 0.0) { - *gain2 = 0.0; + *gain2 = 0.0f; } if (curve == MIXXX_XFADER_CONSTPWR) { @@ -63,17 +67,17 @@ void EngineXfader::getXfadeGains( // In theory the gain ratio varies from 0.5 for two equal signals to sqrt(0.5) = 0.707 for totally // uncorrelated signals. // Since the underlying requirement for this curve is constant loudness, we did a test with 30 s - // snippets of various genres and ReplayGain 2.0 analysis. Almost all results where near 0.707 + // snippets of various genres and ReplayGain 2.0 analysis. Almost all results where near 0.707 // with one exception of mixing two parts of the same track, which resulted in 0.66. // Based on the testing, we normalize the gain as if the signals were uncorrelated. The // correction on the following lines ensures that gain1^2 + gain2^2 == 1. - double gain = sqrt(*gain1 * *gain1 + *gain2 * *gain2); + CSAMPLE_GAIN gain = static_cast<CSAMPLE_GAIN>(sqrt(*gain1 * *gain1 + *gain2 * *gain2)); *gain1 = *gain1 / gain; *gain2 = *gain2 / gain; } if (reverse) { - double gain_temp = *gain1; + CSAMPLE_GAIN gain_temp = *gain1; *gain1 = *gain2; *gain2 = gain_temp; } diff --git a/src/engine/enginexfader.h b/src/engine/enginexfader.h index e9140e415b..f324a3cb1c 100644 --- a/src/engine/enginexfader.h +++ b/src/engine/enginexfader.h @@ -1,5 +1,6 @@ -#ifndef ENGINEXFADER_H -#define ENGINEXFADER_H +#pragma once + +#include "util/types.h" // HACK until we have Control 2.0 #define MIXXX_XFADER_ADDITIVE 0.0 @@ -8,14 +9,16 @@ class EngineXfader { public: static double getPowerCalibration(double transform); - static void getXfadeGains( - double xfadePosition, double transform, double powerCalibration, - double curve, bool reverse, double* gain1, double* gain2); + static void getXfadeGains(double xfadePosition, + double transform, + double powerCalibration, + double curve, + bool reverse, + CSAMPLE_GAIN* gain1, + CSAMPLE_GAIN* gain2); static const char* kXfaderConfigKey; static const double kTransformDefault; static const double kTransformMax; static const double kTransformMin; }; - -#endif /* ENGINEXFADER_H */ |