Skip to content

Commit

Permalink
Fix talkover ducking bug: apply ducking after apllying effects
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsargo committed Nov 6, 2024
1 parent 2d2237e commit 3f3bfdb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
30 changes: 24 additions & 6 deletions src/engine/enginemixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ EngineMixer::EngineMixer(
m_boothGainOld(0.0),
m_headphoneMainGainOld(0.0),
m_headphoneGainOld(1.0),
m_duckingGainOld(1.0),
m_balleftOld(1.0),
m_balrightOld(1.0),
m_numMicsConfigured(0),
Expand Down Expand Up @@ -530,12 +531,8 @@ void EngineMixer::process(const int iBufferSize) {

// Make the mix for each crossfader orientation output bus.
// m_mainGain 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_mainGain.setGains(crossfaderLeftGain,
1.0f,
crossfaderRightGain,
m_pTalkoverDucking->getGain(iFrames));
// channel volume faders and crossfader.
m_mainGain.setGains(crossfaderLeftGain, 1.0f, crossfaderRightGain);

for (int o = EngineChannel::LEFT; o <= EngineChannel::RIGHT; o++) {
ChannelMixer::applyEffectsInPlaceAndMixChannels(m_mainGain,
Expand Down Expand Up @@ -608,6 +605,13 @@ void EngineMixer::process(const int iBufferSize) {
// buffers within the same callback.
applyMainEffects(iBufferSize);

// Apply talkover ducking gain after applying effects in order to
// avoid ducking neutralization by some effects (e.g. compressor or
// AGC)
CSAMPLE_GAIN duckingGain = m_pTalkoverDucking->getGain(iFrames);
SampleUtil::applyRampingGain(m_main.data(), m_duckingGainOld, duckingGain, iBufferSize);
m_duckingGainOld = duckingGain;

if (headphoneEnabled) {
processHeadphones(mainMixGainInHeadphones, iBufferSize);
}
Expand Down Expand Up @@ -648,6 +652,13 @@ void EngineMixer::process(const int iBufferSize) {
// process main effects here before mixing in talkover.
applyMainEffects(iBufferSize);

// Apply talkover ducking gain after applying effects in order to
// avoid ducking neutralization by some effects (e.g. compressor or
// AGC)
CSAMPLE_GAIN duckingGain = m_pTalkoverDucking->getGain(iFrames);
SampleUtil::applyRampingGain(m_main.data(), m_duckingGainOld, duckingGain, iBufferSize);
m_duckingGainOld = duckingGain;

if (headphoneEnabled) {
processHeadphones(mainMixGainInHeadphones, iBufferSize);
}
Expand Down Expand Up @@ -706,6 +717,13 @@ void EngineMixer::process(const int iBufferSize) {
// as what is heard on the main & booth outputs.
applyMainEffects(iBufferSize);

// Apply talkover ducking gain after applying effects in order to
// avoid ducking neutralization by some effects (e.g. compressor or
// AGC)
CSAMPLE_GAIN duckingGain = m_pTalkoverDucking->getGain(iFrames);
SampleUtil::applyRampingGain(m_main.data(), m_duckingGainOld, duckingGain, iBufferSize);
m_duckingGainOld = duckingGain;

if (headphoneEnabled) {
processHeadphones(mainMixGainInHeadphones, iBufferSize);
}
Expand Down
11 changes: 4 additions & 7 deletions src/engine/enginemixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ class EngineMixer : public QObject, public AudioSource {
OrientationVolumeGainCalculator()
: m_dLeftGain(1.0),
m_dCenterGain(1.0),
m_dRightGain(1.0),
m_dTalkoverDuckingGain(1.0) {
m_dRightGain(1.0) {
}

inline CSAMPLE_GAIN getGain(ChannelInfo* pChannelInfo) const override {
Expand All @@ -167,24 +166,21 @@ class EngineMixer : public QObject, public AudioSource {
m_dLeftGain,
m_dCenterGain,
m_dRightGain);
return channelVolume * orientationGain * m_dTalkoverDuckingGain;
return channelVolume * orientationGain;
}

inline void setGains(CSAMPLE_GAIN leftGain,
CSAMPLE_GAIN centerGain,
CSAMPLE_GAIN rightGain,
CSAMPLE_GAIN talkoverDuckingGain) {
CSAMPLE_GAIN rightGain) {
m_dLeftGain = leftGain;
m_dCenterGain = centerGain;
m_dRightGain = rightGain;
m_dTalkoverDuckingGain = talkoverDuckingGain;
}

private:
CSAMPLE_GAIN m_dLeftGain;
CSAMPLE_GAIN m_dCenterGain;
CSAMPLE_GAIN m_dRightGain;
CSAMPLE_GAIN m_dTalkoverDuckingGain;
};

enum class MicMonitorMode {
Expand Down Expand Up @@ -329,6 +325,7 @@ class EngineMixer : public QObject, public AudioSource {
CSAMPLE_GAIN m_boothGainOld;
CSAMPLE_GAIN m_headphoneMainGainOld;
CSAMPLE_GAIN m_headphoneGainOld;
CSAMPLE_GAIN m_duckingGainOld;
CSAMPLE_GAIN m_balleftOld;
CSAMPLE_GAIN m_balrightOld;
std::atomic<unsigned int> m_numMicsConfigured;
Expand Down

0 comments on commit 3f3bfdb

Please sign in to comment.