-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove autogenerated code from ChannelMixer
Previously, the autogenerated code allowed for a vectorizing optimization by combining gain application (channel faders + crossfader) with channel mixing. When postfader effects were implemented in Mixxx 2.1 (PR #1254), these two operations had to be decoupled to process effects between gain application and channel mixing. Therefore, the autogenerated code lost its advantage and became an overcomplication. Unused autogenerated functions were removed from SampleUtil as well. Some of the autogenerated SampleUtil functions are still in use, so they were kept.
- Loading branch information
Showing
5 changed files
with
85 additions
and
23,104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include "engine/channelmixer.h" | ||
#include "util/sample.h" | ||
#include "util/timer.h" | ||
|
||
// static | ||
void ChannelMixer::applyEffectsAndMixChannels(const EngineMaster::GainCalculator& gainCalculator, | ||
QVarLengthArray<EngineMaster::ChannelInfo*, kPreallocatedChannels>* activeChannels, | ||
QVarLengthArray<EngineMaster::GainCache, kPreallocatedChannels>* channelGainCache, | ||
CSAMPLE* pOutput, | ||
const ChannelHandle& outputHandle, | ||
unsigned int iBufferSize, | ||
unsigned int iSampleRate, | ||
EngineEffectsManager* pEngineEffectsManager) { | ||
// Signal flow overview: | ||
// 1. Clear pOutput buffer | ||
// 2. Calculate gains for each channel | ||
// 3. Pass each channel's calculated gain and input buffer to pEngineEffectsManager, which then: | ||
// A) Copies each channel input buffer to a temporary buffer | ||
// B) Applies gain to the temporary buffer | ||
// C) Processes effects on the temporary buffer | ||
// D) Mixes the temporary buffer into pOutput | ||
// The original channel input buffers are not modified. | ||
SampleUtil::clear(pOutput, iBufferSize); | ||
ScopedTimer t("EngineMaster::applyEffectsAndMixChannels"); | ||
for (int i = 0; i < activeChannels->size(); ++i) { | ||
EngineMaster::ChannelInfo* pChannelInfo = activeChannels->at(i); | ||
EngineMaster::GainCache& gainCache = (*channelGainCache)[pChannelInfo->m_index]; | ||
CSAMPLE_GAIN oldGain = gainCache.m_gain; | ||
CSAMPLE_GAIN newGain; | ||
if (gainCache.m_fadeout) { | ||
newGain = 0; | ||
gainCache.m_fadeout = false; | ||
} else { | ||
newGain = gainCalculator.getGain(pChannelInfo); | ||
} | ||
gainCache.m_gain = newGain; | ||
pEngineEffectsManager->processPostFaderAndMix( | ||
pChannelInfo->m_handle, outputHandle, | ||
pChannelInfo->m_pBuffer, pOutput, | ||
iBufferSize, iSampleRate, pChannelInfo->m_features, | ||
oldGain, newGain); | ||
} | ||
} | ||
|
||
void ChannelMixer::applyEffectsInPlaceAndMixChannels(const EngineMaster::GainCalculator& gainCalculator, | ||
QVarLengthArray<EngineMaster::ChannelInfo*, kPreallocatedChannels>* activeChannels, | ||
QVarLengthArray<EngineMaster::GainCache, kPreallocatedChannels>* channelGainCache, | ||
CSAMPLE* pOutput, | ||
const ChannelHandle& outputHandle, | ||
unsigned int iBufferSize, | ||
unsigned int iSampleRate, | ||
EngineEffectsManager* pEngineEffectsManager) { | ||
// Signal flow overview: | ||
// 1. Calculate gains for each channel | ||
// 2. Pass each channel's calculated gain and input buffer to pEngineEffectsManager, which then: | ||
// A) Applies the calculated gain to the channel buffer, modifying the original input buffer | ||
// B) Applies effects to the buffer, modifying the original input buffer | ||
// 4. Mix the channel buffers together to make pOutput, overwriting the pOutput buffer from the last engine callback | ||
ScopedTimer t("EngineMaster::applyEffectsInPlaceAndMixChannels"); | ||
SampleUtil::clear(pOutput, iBufferSize); | ||
for (int i = 0; i < activeChannels->size(); ++i) { | ||
EngineMaster::ChannelInfo* pChannelInfo = activeChannels->at(i); | ||
EngineMaster::GainCache& gainCache = (*channelGainCache)[pChannelInfo->m_index]; | ||
CSAMPLE_GAIN oldGain = gainCache.m_gain; | ||
CSAMPLE_GAIN newGain; | ||
if (gainCache.m_fadeout) { | ||
newGain = 0; | ||
gainCache.m_fadeout = false; | ||
} else { | ||
newGain = gainCalculator.getGain(pChannelInfo); | ||
} | ||
gainCache.m_gain = newGain; | ||
pEngineEffectsManager->processPostFaderInPlace( | ||
pChannelInfo->m_handle, outputHandle, | ||
pChannelInfo->m_pBuffer, | ||
iBufferSize, iSampleRate, pChannelInfo->m_features, | ||
oldGain, newGain); | ||
SampleUtil::add(pOutput, pChannelInfo->m_pBuffer, iBufferSize); | ||
} | ||
} |
Oops, something went wrong.