From 6a501775f60b3dd96ef8407574decc5874ea7dad Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Sat, 9 Jun 2018 18:55:36 +0530 Subject: [PATCH 1/5] Removed EffectChain class --- build/depends.py | 1 - src/effects/effectchain.cpp | 379 ------------------------- src/effects/effectchain.h | 135 --------- src/effects/effectchainmanager.cpp | 44 +-- src/effects/effectchainmanager.h | 11 +- src/effects/effectchainslot.cpp | 74 +++-- src/effects/effectchainslot.h | 21 +- src/effects/effectrack.cpp | 20 +- src/effects/effectrack.h | 4 +- src/effects/effectsmanager.h | 14 + src/engine/effects/engineeffectchain.h | 1 - 11 files changed, 96 insertions(+), 608 deletions(-) delete mode 100644 src/effects/effectchain.cpp delete mode 100644 src/effects/effectchain.h diff --git a/build/depends.py b/build/depends.py index 32b9712714d..b44532ea9f9 100644 --- a/build/depends.py +++ b/build/depends.py @@ -756,7 +756,6 @@ def sources(self, build): "effects/effectmanifest.cpp", "effects/effectmanifestparameter.cpp", - "effects/effectchain.cpp", "effects/effect.cpp", "effects/effectparameter.cpp", diff --git a/src/effects/effectchain.cpp b/src/effects/effectchain.cpp deleted file mode 100644 index 33e3b027915..00000000000 --- a/src/effects/effectchain.cpp +++ /dev/null @@ -1,379 +0,0 @@ -#include "effects/effectchain.h" - -#include "engine/engine.h" -#include "effects/effectchainmanager.h" -#include "effects/effectsmanager.h" -#include "effects/effectprocessor.h" -#include "effects/effectxmlelements.h" -#include "engine/effects/engineeffectchain.h" -#include "engine/effects/engineeffectrack.h" -#include "engine/effects/message.h" -#include "util/defs.h" -#include "util/sample.h" -#include "util/xml.h" - -EffectChain::EffectChain(EffectsManager* pEffectsManager, const QString& id, - EffectChainPointer pPrototype) - : QObject(pEffectsManager), - m_pEffectsManager(pEffectsManager), - m_pPrototype(pPrototype), - m_bEnabled(true), - m_id(id), - m_name(""), - m_mixMode(EffectChainMixMode::DrySlashWet), - m_dMix(0), - m_pEngineEffectChain(nullptr), - m_bAddedToEngine(false) { - qDebug() << "EffectChain::EffectChain " << id << ' ' << pPrototype; - VERIFY_OR_DEBUG_ASSERT(false) { - return; - } -} - -EffectChain::~EffectChain() { - // Remove all effects. - for (int i = 0; i < m_effects.size(); ++i) { - removeEffect(i); - } -} - -void EffectChain::addToEngine(EngineEffectRack* pRack, int iIndex) { - m_pEngineEffectChain = new EngineEffectChain(m_id, - m_pEffectsManager->registeredInputChannels(), - m_pEffectsManager->registeredOutputChannels()); - EffectsRequest* pRequest = new EffectsRequest(); - pRequest->type = EffectsRequest::ADD_CHAIN_TO_RACK; - pRequest->pTargetRack = pRack; - pRequest->AddChainToRack.pChain = m_pEngineEffectChain; - pRequest->AddChainToRack.iIndex = iIndex; - m_pEffectsManager->writeRequest(pRequest); - m_bAddedToEngine = true; - - // Add all effects. - for (int i = 0; i < m_effects.size(); ++i) { - // Add the effect to the engine. - EffectPointer pEffect = m_effects[i]; - if (pEffect) { - pEffect->addToEngine(m_pEngineEffectChain, i, m_enabledInputChannels); - } - } -} - -void EffectChain::removeFromEngine(EngineEffectRack* pRack, int iIndex) { - if (!m_bAddedToEngine) { - return; - } - - // Order doesn't matter when removing. - for (int i = 0; i < m_effects.size(); ++i) { - EffectPointer pEffect = m_effects[i]; - if (pEffect) { - pEffect->removeFromEngine(m_pEngineEffectChain, i); - } - } - - EffectsRequest* pRequest = new EffectsRequest(); - pRequest->type = EffectsRequest::REMOVE_CHAIN_FROM_RACK; - pRequest->pTargetRack = pRack; - pRequest->RemoveChainFromRack.pChain = m_pEngineEffectChain; - pRequest->RemoveChainFromRack.iIndex = iIndex; - m_pEffectsManager->writeRequest(pRequest); - m_bAddedToEngine = false; - - m_pEngineEffectChain = nullptr; -} - -void EffectChain::updateEngineState() { - if (!m_bAddedToEngine) { - return; - } - // Update chain parameters in the engine. - sendParameterUpdate(); - for (int i = 0; i < m_effects.size(); ++i) { - EffectPointer pEffect = m_effects[i]; - if (pEffect) { - // Update effect parameters in the engine. - pEffect->updateEngineState(); - } - } -} - -// static -EffectChainPointer EffectChain::clone(EffectChainPointer pChain) { - if (!pChain) { - return EffectChainPointer(); - } - - EffectChain* pClone = new EffectChain( - pChain->m_pEffectsManager, pChain->id(), pChain); - pClone->setName(pChain->name()); - // Do not set the state of the chain because that information belongs - // to the EffectChainSlot. Leave that to EffectChainSlot::loadEffectChain. - for (const auto& pEffect : pChain->effects()) { - EffectPointer pClonedEffect; - if (pEffect == nullptr) { - // Insert empty effect to preserve chain order - pClonedEffect = EffectPointer(); - } else { - pClonedEffect = pChain->m_pEffectsManager->instantiateEffect( - pEffect->getManifest()->id()); - } - pClone->addEffect(pClonedEffect); - } - return EffectChainPointer(pClone); -} - -EffectChainPointer EffectChain::prototype() const { - return m_pPrototype; -} - -const QString& EffectChain::id() const { - return m_id; -} - -const QString& EffectChain::name() const { - return m_name; -} - -void EffectChain::setName(const QString& name) { - m_name = name; - emit(nameChanged(name)); -} - -QString EffectChain::description() const { - return m_description; -} - -void EffectChain::setDescription(const QString& description) { - m_description = description; - emit(descriptionChanged(description)); -} - -bool EffectChain::enabled() const { - return m_bEnabled; -} - -void EffectChain::setEnabled(bool enabled) { - m_bEnabled = enabled; - sendParameterUpdate(); - emit(enabledChanged(enabled)); -} - -void EffectChain::enableForInputChannel(const ChannelHandleAndGroup& handle_group) { - // TODO(Be): remove m_enabledChannels from this class and move this logic - // to EffectChainSlot - bool bWasAlreadyEnabled = m_enabledInputChannels.contains(handle_group); - if (!bWasAlreadyEnabled) { - m_enabledInputChannels.insert(handle_group); - } - - // The allocation of EffectStates below may be expensive, so avoid it if - // not needed. - if (!m_bAddedToEngine || bWasAlreadyEnabled) { - return; - } - - EffectsRequest* request = new EffectsRequest(); - request->type = EffectsRequest::ENABLE_EFFECT_CHAIN_FOR_INPUT_CHANNEL; - request->pTargetChain = m_pEngineEffectChain; - request->EnableInputChannelForChain.pChannelHandle = &handle_group.handle(); - - // Allocate EffectStates here in the main thread to avoid allocating - // memory in the realtime audio callback thread. Pointers to the - // EffectStates are passed to the EffectRequest and the EffectProcessorImpls - // store the pointers. The containers of EffectState* pointers get deleted - // by ~EffectsRequest, but the EffectStates are managed by EffectProcessorImpl. - auto pEffectStatesMapArray = new EffectStatesMapArray; - - //TODO: get actual configuration of engine - const mixxx::EngineParameters bufferParameters( - mixxx::AudioSignal::SampleRate(96000), - MAX_BUFFER_LEN / mixxx::kEngineChannelCount); - - for (int i = 0; i < m_effects.size(); ++i) { - auto& statesMap = (*pEffectStatesMapArray)[i]; - if (m_effects[i] != nullptr) { - for (const auto& outputChannel : m_pEffectsManager->registeredOutputChannels()) { - if (kEffectDebugOutput) { - qDebug() << debugString() << "EffectChain::enableForInputChannel creating EffectState for input" << handle_group << "output" << outputChannel; - } - statesMap.insert(outputChannel.handle(), - m_effects[i]->createState(bufferParameters)); - } - } else { - for (EffectState* pState : statesMap) { - if (pState != nullptr) { - delete pState; - } - } - statesMap.clear(); - } - } - request->EnableInputChannelForChain.pEffectStatesMapArray = pEffectStatesMapArray; - - m_pEffectsManager->writeRequest(request); - emit(channelStatusChanged(handle_group.name(), true)); -} - -bool EffectChain::enabledForChannel(const ChannelHandleAndGroup& handle_group) const { - return m_enabledInputChannels.contains(handle_group); -} - -void EffectChain::disableForInputChannel(const ChannelHandleAndGroup& handle_group) { - if (m_enabledInputChannels.remove(handle_group)) { - if (!m_bAddedToEngine) { - return; - } - EffectsRequest* request = new EffectsRequest(); - request->type = EffectsRequest::DISABLE_EFFECT_CHAIN_FOR_INPUT_CHANNEL; - request->pTargetChain = m_pEngineEffectChain; - request->DisableInputChannelForChain.pChannelHandle = &handle_group.handle(); - m_pEffectsManager->writeRequest(request); - - emit(channelStatusChanged(handle_group.name(), false)); - } -} - -double EffectChain::mix() const { - return m_dMix; -} - -void EffectChain::setMix(const double& dMix) { - m_dMix = dMix; - sendParameterUpdate(); - emit(mixChanged(dMix)); -} - -EffectChainMixMode EffectChain::mixMode() const { - return m_mixMode; -} - -void EffectChain::setMixMode(EffectChainMixMode mixMode) { - m_mixMode = mixMode; - sendParameterUpdate(); - emit(mixModeChanged(mixMode)); -} - -void EffectChain::addEffect(EffectPointer pEffect) { - //qDebug() << debugString() << "addEffect" << pEffect; - if (!pEffect) { - // Insert empty effects to preserve chain order - // when loading chains with empty effects - m_effects.append(pEffect); - return; - } - - VERIFY_OR_DEBUG_ASSERT(!m_effects.contains(pEffect)) { - return; - } - - m_effects.append(pEffect); - if (m_bAddedToEngine) { - pEffect->addToEngine(m_pEngineEffectChain, m_effects.size() - 1, m_enabledInputChannels); - } - emit(effectChanged(m_effects.size() - 1)); -} - -void EffectChain::replaceEffect(unsigned int effectSlotNumber, - EffectPointer pEffect) { - //qDebug() << debugString() << "replaceEffect" << effectSlotNumber << pEffect; - // NOTE(Kshitij) : Remove the following return statement and debug the actual problem - // return; - while (effectSlotNumber >= static_cast(m_effects.size())) { - if (pEffect.isNull()) { - return; - } - m_effects.append(EffectPointer()); - } - - EffectPointer pOldEffect = m_effects[effectSlotNumber]; - if (!pOldEffect.isNull()) { - if (m_bAddedToEngine) { - pOldEffect->removeFromEngine(m_pEngineEffectChain, effectSlotNumber); - } - } - - m_effects.replace(effectSlotNumber, pEffect); - if (!pEffect.isNull()) { - if (m_bAddedToEngine) { - pEffect->addToEngine(m_pEngineEffectChain, effectSlotNumber, m_enabledInputChannels); - } - } - - emit(effectChanged(effectSlotNumber)); -} - -void EffectChain::removeEffect(unsigned int effectSlotNumber) { - replaceEffect(effectSlotNumber, EffectPointer()); -} - -void EffectChain::refreshAllEffects() { - for (int i = 0; i < m_effects.size(); ++i) { - emit(effectChanged(i)); - } -} - -unsigned int EffectChain::numEffects() const { - return m_effects.size(); -} - -const QList& EffectChain::effects() const { - return m_effects; -} - -EngineEffectChain* EffectChain::getEngineEffectChain() { - return m_pEngineEffectChain; -} - -void EffectChain::sendParameterUpdate() { - if (!m_bAddedToEngine) { - return; - } - EffectsRequest* pRequest = new EffectsRequest(); - pRequest->type = EffectsRequest::SET_EFFECT_CHAIN_PARAMETERS; - pRequest->pTargetChain = m_pEngineEffectChain; - pRequest->SetEffectChainParameters.enabled = m_bEnabled; - pRequest->SetEffectChainParameters.mix_mode = m_mixMode; - pRequest->SetEffectChainParameters.mix = m_dMix; - m_pEffectsManager->writeRequest(pRequest); -} - -// static -EffectChainPointer EffectChain::createFromXml(EffectsManager* pEffectsManager, - const QDomElement& element) { - if (!element.hasChildNodes()) { - // An empty element is treated as an ejected Chain (null) - return EffectChainPointer(); - } - - QString id = XmlParse::selectNodeQString(element, - EffectXml::ChainId); - QString name = XmlParse::selectNodeQString(element, - EffectXml::ChainName); - QString description = XmlParse::selectNodeQString(element, - EffectXml::ChainDescription); - QString mixModeStr = XmlParse::selectNodeQString(element, - EffectXml::ChainMixMode); - - EffectChainPointer pChain(new EffectChain(pEffectsManager, id)); - pChain->setName(name); - pChain->setDescription(description); - EffectChainMixMode mixMode = mixModeFromString(mixModeStr); - if (mixMode != EffectChainMixMode::NumMixModes) { - pChain->setMixMode(mixMode); - } - - QDomElement effects = XmlParse::selectElement(element, EffectXml::EffectsRoot); - QDomNodeList effectChildren = effects.childNodes(); - - for (int i = 0; i < effectChildren.count(); ++i) { - QDomNode effect = effectChildren.at(i); - if (effect.isElement()) { - EffectPointer pEffect = Effect::createFromXml( - pEffectsManager, effect.toElement()); - pChain->addEffect(pEffect); - } - } - - return pChain; -} diff --git a/src/effects/effectchain.h b/src/effects/effectchain.h deleted file mode 100644 index c0a7c526219..00000000000 --- a/src/effects/effectchain.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef EFFECTCHAIN_H -#define EFFECTCHAIN_H - -#include -#include -#include -#include - -#include "effects/defs.h" -#include "engine/channelhandle.h" -#include "effects/effect.h" -#include "util/class.h" - -class EffectsManager; -class EngineEffectRack; -class EngineEffectChain; -class EffectChain; -typedef QSharedPointer EffectChainPointer; - -// The main-thread representation of an effect chain. This class is NOT -// thread-safe and must only be used from the main thread. -class EffectChain : public QObject { - Q_OBJECT - public: - EffectChain(EffectsManager* pEffectsManager, const QString& id, - EffectChainPointer prototype=EffectChainPointer()); - virtual ~EffectChain(); - - void addToEngine(EngineEffectRack* pRack, int iIndex); - void removeFromEngine(EngineEffectRack* pRack, int iIndex); - void updateEngineState(); - - // The ID of an EffectChain is a unique ID given to it to help associate it - // with the preset from which it was loaded. - const QString& id() const; - - // Whether the chain is enabled (eligible for processing). - bool enabled() const; - void setEnabled(bool enabled); - - // Activates EffectChain processing for the provided channel. - void enableForInputChannel(const ChannelHandleAndGroup& handle_group); - bool enabledForChannel(const ChannelHandleAndGroup& handle_group) const; - const QSet& enabledChannels() const; - void disableForInputChannel(const ChannelHandleAndGroup& handle_group); - - EffectChainPointer prototype() const; - - // Get the human-readable name of the EffectChain - const QString& name() const; - void setName(const QString& name); - - // Get the human-readable description of the EffectChain - QString description() const; - void setDescription(const QString& description); - - double mix() const; - void setMix(const double& dMix); - - static QString mixModeToString(EffectChainMixMode type) { - switch (type) { - case EffectChainMixMode::DrySlashWet: - return "DRY/WET"; - case EffectChainMixMode::DryPlusWet: - return "DRY+WET"; - default: - return "UNKNOWN"; - } - } - static EffectChainMixMode mixModeFromString(const QString& typeStr) { - if (typeStr == "DRY/WET") { - return EffectChainMixMode::DrySlashWet; - } else if (typeStr == "DRY+WET") { - return EffectChainMixMode::DryPlusWet; - } else { - return EffectChainMixMode::NumMixModes; - } - } - - EffectChainMixMode mixMode() const; - void setMixMode(EffectChainMixMode type); - - void addEffect(EffectPointer pEffect); - void replaceEffect(unsigned int effectSlotNumber, EffectPointer pEffect); - void removeEffect(unsigned int effectSlotNumber); - void refreshAllEffects(); - - const QList& effects() const; - unsigned int numEffects() const; - - EngineEffectChain* getEngineEffectChain(); - - static EffectChainPointer createFromXml(EffectsManager* pEffectsManager, - const QDomElement& element); - static EffectChainPointer clone(EffectChainPointer pChain); - - - signals: - // Signal that indicates that an effect has been added or removed. - void effectChanged(unsigned int effectSlotNumber); - void nameChanged(const QString& name); - void descriptionChanged(const QString& name); - void enabledChanged(bool enabled); - void mixChanged(double v); - void mixModeChanged(EffectChainMixMode type); - void channelStatusChanged(const QString& group, bool enabled); - - public: - QString debugString() const { - return QString("EffectChain(%1)").arg(m_id); - } - - void sendParameterUpdate(); - - EffectsManager* m_pEffectsManager; - EffectChainPointer m_pPrototype; - - bool m_bEnabled; - QString m_id; - QString m_name; - QString m_description; - EffectChainMixMode m_mixMode; - double m_dMix; - - QSet m_enabledInputChannels; - QList m_effects; - EngineEffectChain* m_pEngineEffectChain; - bool m_bAddedToEngine; - - DISALLOW_COPY_AND_ASSIGN(EffectChain); - - private: -}; - -#endif /* EFFECTCHAIN_H */ diff --git a/src/effects/effectchainmanager.cpp b/src/effects/effectchainmanager.cpp index 6cf0fc04499..d2527b45167 100644 --- a/src/effects/effectchainmanager.cpp +++ b/src/effects/effectchainmanager.cpp @@ -97,50 +97,50 @@ EffectRackPointer EffectChainManager::getEffectRack(const QString& group) { return m_effectRacksByGroup.value(group); } -void EffectChainManager::addEffectChain(EffectChainPointer pEffectChain) { - if (pEffectChain) { - m_effectChains.append(pEffectChain); +void EffectChainManager::addEffectChain(EffectChainSlotPointer pEffectChainSlot) { + if (pEffectChainSlot) { + m_effectChainSlots.append(pEffectChainSlot); } } -void EffectChainManager::removeEffectChain(EffectChainPointer pEffectChain) { - if (pEffectChain) { - m_effectChains.removeAll(pEffectChain); +void EffectChainManager::removeEffectChain(EffectChainSlotPointer pEffectChainSlot) { + if (pEffectChainSlot) { + m_effectChainSlots.removeAll(pEffectChainSlot); } } -EffectChainPointer EffectChainManager::getNextEffectChain(EffectChainPointer pEffectChain) { - if (m_effectChains.isEmpty()) - return EffectChainPointer(); +EffectChainSlotPointer EffectChainManager::getNextEffectChain(EffectChainSlotPointer pEffectChainSlot) { + if (m_effectChainSlots.isEmpty()) + return EffectChainSlotPointer(); - if (!pEffectChain) { - return m_effectChains[0]; + if (!pEffectChainSlot) { + return m_effectChainSlots[0]; } - int indexOf = m_effectChains.lastIndexOf(pEffectChain); + int indexOf = m_effectChainSlots.lastIndexOf(pEffectChainSlot); if (indexOf == -1) { qWarning() << debugString() << "WARNING: getNextEffectChain called for an unmanaged EffectChain"; - return m_effectChains[0]; + return m_effectChainSlots[0]; } - return m_effectChains[(indexOf + 1) % m_effectChains.size()]; + return m_effectChainSlots[(indexOf + 1) % m_effectChainSlots.size()]; } -EffectChainPointer EffectChainManager::getPrevEffectChain(EffectChainPointer pEffectChain) { - if (m_effectChains.isEmpty()) - return EffectChainPointer(); +EffectChainSlotPointer EffectChainManager::getPrevEffectChain(EffectChainSlotPointer pEffectChainSlot) { + if (m_effectChainSlots.isEmpty()) + return EffectChainSlotPointer(); - if (!pEffectChain) { - return m_effectChains[m_effectChains.size()-1]; + if (!pEffectChainSlot) { + return m_effectChainSlots[m_effectChainSlots.size()-1]; } - int indexOf = m_effectChains.lastIndexOf(pEffectChain); + int indexOf = m_effectChainSlots.lastIndexOf(pEffectChainSlot); if (indexOf == -1) { qWarning() << debugString() << "WARNING: getPrevEffectChain called for an unmanaged EffectChain"; - return m_effectChains[m_effectChains.size()-1]; + return m_effectChainSlots[m_effectChainSlots.size()-1]; } - return m_effectChains[(indexOf - 1 + m_effectChains.size()) % m_effectChains.size()]; + return m_effectChainSlots[(indexOf - 1 + m_effectChainSlots.size()) % m_effectChainSlots.size()]; } void EffectChainManager::refeshAllRacks() { diff --git a/src/effects/effectchainmanager.h b/src/effects/effectchainmanager.h index e95bb2cf9e7..91442419c47 100644 --- a/src/effects/effectchainmanager.h +++ b/src/effects/effectchainmanager.h @@ -6,7 +6,6 @@ #include #include "preferences/usersettings.h" -#include "effects/effectchain.h" #include "effects/effectrack.h" #include "engine/channelhandle.h" #include "util/class.h" @@ -48,15 +47,15 @@ class EffectChainManager : public QObject { EffectRackPointer getEffectRack(const QString& group); - void addEffectChain(EffectChainPointer pEffectChain); - void removeEffectChain(EffectChainPointer pEffectChain); + void addEffectChain(EffectChainSlotPointer pEffectChainSlot); + void removeEffectChain(EffectChainSlotPointer pEffectChainSlot); // To support cycling through effect chains, there is a global ordering of // chains. These methods allow you to get the next or previous chain given // your current chain. // TODO(rryan): Prevent double-loading of a chain into a slot? - EffectChainPointer getNextEffectChain(EffectChainPointer pEffectChain); - EffectChainPointer getPrevEffectChain(EffectChainPointer pEffectChain); + EffectChainSlotPointer getNextEffectChain(EffectChainSlotPointer pEffectChainSlot); + EffectChainSlotPointer getPrevEffectChain(EffectChainSlotPointer pEffectChainSlot); // NOTE(Kshitij) : New functions for saving and loading // bool saveEffectChains(); @@ -81,7 +80,7 @@ class EffectChainManager : public QObject { QList m_quickEffectRacks; OutputEffectRackPointer m_pOutputEffectRack; QHash m_effectRacksByGroup; - QList m_effectChains; + QList m_effectChainSlots; QSet m_registeredInputChannels; QSet m_registeredOutputChannels; DISALLOW_COPY_AND_ASSIGN(EffectChainManager); diff --git a/src/effects/effectchainslot.cpp b/src/effects/effectchainslot.cpp index 08159fbcde3..282f8a22faf 100644 --- a/src/effects/effectchainslot.cpp +++ b/src/effects/effectchainslot.cpp @@ -3,7 +3,6 @@ #include "effects/effectrack.h" #include "effects/effectxmlelements.h" #include "effects/effectslot.h" -#include "effects/effectchainmanager.h" #include "effects/effectsmanager.h" #include "effects/effectprocessor.h" #include "engine/effects/engineeffectchain.h" @@ -394,43 +393,43 @@ void EffectChainSlot::sendParameterUpdate() { } // static -EffectChainPointer EffectChainSlot::createFromXml(EffectsManager* pEffectsManager, +EffectChainSlotPointer EffectChainSlot::createFromXml(EffectsManager* pEffectsManager, const QDomElement& element) { - if (!element.hasChildNodes()) { - // An empty element is treated as an ejected Chain (null) - return EffectChainPointer(); - } - - QString id = XmlParse::selectNodeQString(element, - EffectXml::ChainId); - QString name = XmlParse::selectNodeQString(element, - EffectXml::ChainName); - QString description = XmlParse::selectNodeQString(element, - EffectXml::ChainDescription); - QString mixModeStr = XmlParse::selectNodeQString(element, - EffectXml::ChainMixMode); - - EffectChainPointer pChain(new EffectChain(pEffectsManager, id)); - pChain->setName(name); - pChain->setDescription(description); - EffectChainMixMode mixMode = mixModeFromString(mixModeStr); - if (mixMode != EffectChainMixMode::NumMixModes) { - pChain->setMixMode(mixMode); - } - - QDomElement effects = XmlParse::selectElement(element, EffectXml::EffectsRoot); - QDomNodeList effectChildren = effects.childNodes(); - - for (int i = 0; i < effectChildren.count(); ++i) { - QDomNode effect = effectChildren.at(i); - if (effect.isElement()) { - EffectPointer pEffect = Effect::createFromXml( - pEffectsManager, effect.toElement()); - pChain->addEffect(pEffect); - } - } + // if (!element.hasChildNodes()) { + // // An empty element is treated as an ejected Chain (null) + // return EffectChainPointer(); + // } + + // QString id = XmlParse::selectNodeQString(element, + // EffectXml::ChainId); + // QString name = XmlParse::selectNodeQString(element, + // EffectXml::ChainName); + // QString description = XmlParse::selectNodeQString(element, + // EffectXml::ChainDescription); + // QString mixModeStr = XmlParse::selectNodeQString(element, + // EffectXml::ChainMixMode); + + // EffectChainPointer pChain(new EffectChain(pEffectsManager, id)); + // pChain->setName(name); + // pChain->setDescription(description); + // EffectChainMixMode mixMode = mixModeFromString(mixModeStr); + // if (mixMode != EffectChainMixMode::NumMixModes) { + // pChain->setMixMode(mixMode); + // } + + // QDomElement effects = XmlParse::selectElement(element, EffectXml::EffectsRoot); + // QDomNodeList effectChildren = effects.childNodes(); + + // for (int i = 0; i < effectChildren.count(); ++i) { + // QDomNode effect = effectChildren.at(i); + // if (effect.isElement()) { + // EffectPointer pEffect = Effect::createFromXml( + // pEffectsManager, effect.toElement()); + // pChain->addEffect(pEffect); + // } + // } - return pChain; + // return pChain; } QString EffectChainSlot::id() const { @@ -506,8 +505,7 @@ void EffectChainSlot::slotChainEffectChanged(unsigned int effectSlotNumber, } } -void EffectChainSlot::loadEffectChainToSlot(EffectChainPointer pEffectChain) { - qDebug() << debugString() << "loadEffectChainToSlot" << (pEffectChain ? pEffectChain->id() : "(null)"); +void EffectChainSlot::loadEffectChainToSlot() { clear(); m_pControlChainLoaded->forceSet(true); diff --git a/src/effects/effectchainslot.h b/src/effects/effectchainslot.h index c06f494da5f..b717bd09983 100644 --- a/src/effects/effectchainslot.h +++ b/src/effects/effectchainslot.h @@ -9,7 +9,6 @@ #include "engine/channelhandle.h" #include "util/class.h" -#include "effects/effectchain.h" #include "effects/defs.h" #include "engine/channelhandle.h" #include "effects/effect.h" @@ -23,8 +22,6 @@ class EffectChainSlot; class EffectsManager; class EngineEffectRack; class EngineEffectChain; -class EffectChain; -typedef QSharedPointer EffectChainPointer; class EffectChainSlot : public QObject { @@ -44,10 +41,8 @@ class EffectChainSlot : public QObject { EffectSlotPointer addEffectSlot(const QString& group); EffectSlotPointer getEffectSlot(unsigned int slotNumber); - void loadEffectChainToSlot(EffectChainPointer pEffectChain = EffectChainPointer()); + void loadEffectChainToSlot(); void updateRoutingSwitches(); - EffectChainPointer getEffectChain() const; - EffectChainPointer getOrCreateEffectChain(EffectsManager* pEffectsManager); void registerInputChannel(const ChannelHandleAndGroup& handle_group); @@ -79,7 +74,6 @@ class EffectChainSlot : public QObject { void disableForInputChannel(const ChannelHandleAndGroup& handle_group); void updateEngineState(); - EffectChainPointer prototype() const; // Get the human-readable name of the EffectChain const QString& name() const; @@ -124,8 +118,8 @@ class EffectChainSlot : public QObject { EngineEffectChain* getEngineEffectChain(); unsigned int numEffects() const; - static EffectChainPointer createFromXml(EffectsManager* pEffectsManager, - const QDomElement& element); + static EffectChainSlotPointer createFromXml(EffectsManager* pEffectsManager, + const QDomElement& element); signals: // Indicates that the effect pEffect has been loaded into slotNumber of @@ -136,21 +130,21 @@ class EffectChainSlot : public QObject { // Indicates that the given EffectChain was loaded into this // EffectChainSlot - void effectChainLoaded(EffectChainPointer pEffectChain); + void effectChainLoaded(EffectChainSlotPointer pEffectChain); // Signal that whoever is in charge of this EffectChainSlot should load the // next EffectChain into it. void nextChain(unsigned int iChainSlotNumber, - EffectChainPointer pEffectChain); + EffectChainSlotPointer pEffectChain); // Signal that whoever is in charge of this EffectChainSlot should load the // previous EffectChain into it. void prevChain(unsigned int iChainSlotNumber, - EffectChainPointer pEffectChain); + EffectChainSlotPointer pEffectChain); // Signal that whoever is in charge of this EffectChainSlot should clear // this EffectChain (by removing the chain from this EffectChainSlot). - void clearChain(unsigned int iChainNumber, EffectChainPointer pEffectChain); + void clearChain(unsigned int iChainNumber, EffectChainSlotPointer pEffectChain); // Signal that whoever is in charge of this EffectChainSlot should load the // next Effect into the specified EffectSlot. @@ -247,7 +241,6 @@ class EffectChainSlot : public QObject { EffectsManager* m_pEffectsManager; - EffectChainPointer m_pPrototype; bool m_bEnabled; QString m_id; diff --git a/src/effects/effectrack.cpp b/src/effects/effectrack.cpp index 3f90b2dc4f9..11d300773fc 100644 --- a/src/effects/effectrack.cpp +++ b/src/effects/effectrack.cpp @@ -92,11 +92,11 @@ EffectChainSlotPointer EffectRack::getEffectChainSlot(int i) { } void EffectRack::loadNextChain(const unsigned int iChainSlotNumber, - EffectChainPointer pLoadedChain) { + EffectChainSlotPointer pLoadedChain) { } void EffectRack::loadPrevChain(const unsigned int iChainSlotNumber, - EffectChainPointer pLoadedChain) { + EffectChainSlotPointer pLoadedChain) { } void EffectRack::maybeLoadEffect(const unsigned int iChainSlotNumber, @@ -208,10 +208,10 @@ EffectChainSlotPointer StandardEffectRack::addEffectChainSlot() { getRackNumber(), iChainSlotNumber, i)); } - connect(pChainSlot, SIGNAL(nextChain(unsigned int, EffectChainPointer)), - this, SLOT(loadNextChain(unsigned int, EffectChainPointer))); - connect(pChainSlot, SIGNAL(prevChain(unsigned int, EffectChainPointer)), - this, SLOT(loadPrevChain(unsigned int, EffectChainPointer))); + connect(pChainSlot, SIGNAL(nextChain(unsigned int, EffectChainSlotPointer)), + this, SLOT(loadNextChain(unsigned int, EffectChainSlotPointer))); + connect(pChainSlot, SIGNAL(prevChain(unsigned int, EffectChainSlotPointer)), + this, SLOT(loadPrevChain(unsigned int, EffectChainSlotPointer))); connect(pChainSlot, SIGNAL(nextEffect(unsigned int, unsigned int, EffectPointer)), this, SLOT(loadNextEffect(unsigned int, unsigned int, EffectPointer))); @@ -242,10 +242,10 @@ OutputEffectRack::OutputEffectRack(EffectsManager* pEffectsManager, pChainSlot->loadEffectChainToSlot(); pChainSlot->addEffectSlot("[OutputEffectRack_[Master]_Effect1]"); - connect(pChainSlot, SIGNAL(nextChain(unsigned int, EffectChainPointer)), - this, SLOT(loadNextChain(unsigned int, EffectChainPointer))); - connect(pChainSlot, SIGNAL(prevChain(unsigned int, EffectChainPointer)), - this, SLOT(loadPrevChain(unsigned int, EffectChainPointer))); + connect(pChainSlot, SIGNAL(nextChain(unsigned int, EffectChainSlotPointer)), + this, SLOT(loadNextChain(unsigned int, EffectChainSlotPointer))); + connect(pChainSlot, SIGNAL(prevChain(unsigned int, EffectChainSlotPointer)), + this, SLOT(loadPrevChain(unsigned int, EffectChainSlotPointer))); connect(pChainSlot, SIGNAL(nextEffect(unsigned int, unsigned int, EffectPointer)), this, SLOT(loadNextEffect(unsigned int, unsigned int, EffectPointer))); diff --git a/src/effects/effectrack.h b/src/effects/effectrack.h index 1f97f9f1d8a..ad44cd06d14 100644 --- a/src/effects/effectrack.h +++ b/src/effects/effectrack.h @@ -57,9 +57,9 @@ class EffectRack : public QObject { private slots: void loadNextChain(const unsigned int iChainSlotNumber, - EffectChainPointer pLoadedChain); + EffectChainSlotPointer pLoadedChain); void loadPrevChain(const unsigned int iChainSlotNumber, - EffectChainPointer pLoadedChain); + EffectChainSlotPointer pLoadedChain); void loadNextEffect(const unsigned int iChainSlotNumber, const unsigned int iEffectSlotNumber, diff --git a/src/effects/effectsmanager.h b/src/effects/effectsmanager.h index b9a10abf28e..a28d21dc157 100644 --- a/src/effects/effectsmanager.h +++ b/src/effects/effectsmanager.h @@ -141,6 +141,20 @@ class EffectsManager : public QObject { bool m_underDestruction; + // START EFFECTCHAINMANAGER + // UserSettingsPointer m_pConfig; + // EffectsManager* m_pEffectsManager; + // QList m_standardEffectRacks; + // QList m_equalizerEffectRacks; + // QList m_quickEffectRacks; + // OutputEffectRackPointer m_pOutputEffectRack; + // QHash m_effectRacksByGroup; + // QList m_effectChains; + // QSet m_registeredInputChannels; + // QSet m_registeredOutputChannels; + // END EFFECTCHAINMANAGER + + DISALLOW_COPY_AND_ASSIGN(EffectsManager); }; diff --git a/src/engine/effects/engineeffectchain.h b/src/engine/effects/engineeffectchain.h index 8c984281fcd..70fc0e45b5d 100644 --- a/src/engine/effects/engineeffectchain.h +++ b/src/engine/effects/engineeffectchain.h @@ -12,7 +12,6 @@ #include "engine/channelhandle.h" #include "engine/effects/message.h" #include "engine/effects/groupfeaturestate.h" -#include "effects/effectchain.h" class EngineEffect; From 70fb3e3eff79a22e36ad8fd3e9f06ffb3f3e45dd Mon Sep 17 00:00:00 2001 From: Ritvik Sharma Date: Sun, 10 Jun 2018 08:05:48 +0530 Subject: [PATCH 2/5] Commented toXml function --- src/effects/effectrack.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/effects/effectrack.cpp b/src/effects/effectrack.cpp index 11d300773fc..a239e9a3d51 100644 --- a/src/effects/effectrack.cpp +++ b/src/effects/effectrack.cpp @@ -158,17 +158,17 @@ void EffectRack::loadPrevEffect(const unsigned int iChainSlotNumber, QDomElement EffectRack::toXml(QDomDocument* doc) const { QDomElement rackElement = doc->createElement("Rack"); - QDomElement groupElement = doc->createElement("Group"); - QDomText groupText = doc->createTextNode(m_group); - groupElement.appendChild(groupText); - rackElement.appendChild(groupElement); - - QDomElement chainsElement = doc->createElement("Chains"); - for (EffectChainSlotPointer pChainSlot : m_effectChainSlots) { - QDomElement chain = pChainSlot->toXml(doc); - chainsElement.appendChild(chain); - } - rackElement.appendChild(chainsElement); + // QDomElement groupElement = doc->createElement("Group"); + // QDomText groupText = doc->createTextNode(m_group); + // groupElement.appendChild(groupText); + // rackElement.appendChild(groupElement); + + // QDomElement chainsElement = doc->createElement("Chains"); + // for (EffectChainSlotPointer pChainSlot : m_effectChainSlots) { + // QDomElement chain = pChainSlot->toXml(doc); + // chainsElement.appendChild(chain); + // } + // rackElement.appendChild(chainsElement); return rackElement; } From 54824c2555dff500d595e61a88e37475c0ea54d6 Mon Sep 17 00:00:00 2001 From: Ritvik Sharma Date: Sun, 10 Jun 2018 11:14:19 +0530 Subject: [PATCH 3/5] Removed redundant enabled state from EffectChainSlot --- src/effects/effectchainslot.cpp | 29 ++++++----------------------- src/effects/effectchainslot.h | 13 ++++++------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/effects/effectchainslot.cpp b/src/effects/effectchainslot.cpp index 282f8a22faf..2fc61c5db04 100644 --- a/src/effects/effectchainslot.cpp +++ b/src/effects/effectchainslot.cpp @@ -55,8 +55,8 @@ EffectChainSlot::EffectChainSlot(EffectRack* pRack, const QString& group, // Default to enabled. The skin might not show these buttons. m_pControlChainEnabled->setDefaultValue(true); m_pControlChainEnabled->set(true); - connect(m_pControlChainEnabled, SIGNAL(valueChanged(double)), - this, SLOT(slotControlChainEnabled(double))); + connect(m_pControlChainEnabled, SIGNAL(valueChanged()), + this, SLOT(slotChainUpdated())); m_pControlChainMix = new ControlPotmeter(ConfigKey(m_group, "mix"), 0.0, 1.0, false, true, false, true, 1.0); @@ -209,17 +209,6 @@ void EffectChainSlot::setDescription(const QString& description) { // emit(descriptionChanged(description)); } -bool EffectChainSlot::enabled() const { - return m_bEnabled; -} - -void EffectChainSlot::setEnabled(bool enabled) { - m_bEnabled = enabled; - sendParameterUpdate(); - // emit(enabledChanged(enabled)); - slotChainEnabledChanged(enabled); -} - void EffectChainSlot::enableForInputChannel(const ChannelHandleAndGroup& handle_group) { // TODO(Be): remove m_enabledChannels from this class and move this logic // to EffectChainSlot @@ -386,7 +375,7 @@ void EffectChainSlot::sendParameterUpdate() { EffectsRequest* pRequest = new EffectsRequest(); pRequest->type = EffectsRequest::SET_EFFECT_CHAIN_PARAMETERS; pRequest->pTargetChain = m_pEngineEffectChain; - pRequest->SetEffectChainParameters.enabled = m_bEnabled; + pRequest->SetEffectChainParameters.enabled = m_pControlChainEnabled->get(); pRequest->SetEffectChainParameters.mix_mode = m_mixMode; pRequest->SetEffectChainParameters.mix = m_dMix; m_pEffectsManager->writeRequest(pRequest); @@ -453,8 +442,8 @@ void EffectChainSlot::slotChainNameChanged(const QString&) { emit(updated()); } -void EffectChainSlot::slotChainEnabledChanged(bool bEnabled) { - m_pControlChainEnabled->set(bEnabled); +void EffectChainSlot::slotChainUpdated() { + sendParameterUpdate(); emit(updated()); } @@ -514,8 +503,8 @@ void EffectChainSlot::loadEffectChainToSlot() { // Mix and enabled channels are persistent properties of the chain slot, // not of the chain. Propagate the current settings to the chain. + // NOTE(Kshitij) : Check if these were required? setMix(m_pControlChainMix->get()); - setEnabled(m_pControlChainEnabled->get() > 0.0); // Don't emit because we will below. for (int i = 0; i < m_slots.size(); ++i) { @@ -617,12 +606,6 @@ void EffectChainSlot::slotControlClear(double v) { } } -void EffectChainSlot::slotControlChainEnabled(double v) { - qDebug() << debugString() << "slotControlChainEnabled" << v; - - setEnabled(v > 0); -} - void EffectChainSlot::slotControlChainMix(double v) { qDebug() << debugString() << "slotControlChainMix" << v; diff --git a/src/effects/effectchainslot.h b/src/effects/effectchainslot.h index b717bd09983..58a5b0e565a 100644 --- a/src/effects/effectchainslot.h +++ b/src/effects/effectchainslot.h @@ -23,7 +23,6 @@ class EffectsManager; class EngineEffectRack; class EngineEffectChain; - class EffectChainSlot : public QObject { Q_OBJECT public: @@ -63,16 +62,14 @@ class EffectChainSlot : public QObject { void loadChainSlotFromXml(const QDomElement& effectChainElement); - // Whether the chain is enabled (eligible for processing). - bool enabled() const; - void setEnabled(bool enabled); - // Activates EffectChain processing for the provided channel. + // TODO(Kshitij) : Make this function private once EffectRack layer is removed void enableForInputChannel(const ChannelHandleAndGroup& handle_group); bool enabledForChannel(const ChannelHandleAndGroup& handle_group) const; const QSet& enabledChannels() const; void disableForInputChannel(const ChannelHandleAndGroup& handle_group); + // TODO(Kshitij) : Make this function private once EffectRack layer is removed void updateEngineState(); // Get the human-readable name of the EffectChain @@ -84,6 +81,8 @@ class EffectChainSlot : public QObject { void setDescription(const QString& description); double mix() const; + + // TODO(Kshitij) : Make this function private once EffectRack layer is removed void setMix(const double& dMix); static QString mixModeToString(EffectChainMixMode type) { @@ -163,9 +162,9 @@ class EffectChainSlot : public QObject { private slots: + void slotChainUpdated(); void slotChainEffectChanged(unsigned int effectSlotNumber, bool shouldEmit=true); void slotChainNameChanged(const QString& name); - void slotChainEnabledChanged(bool enabled); void slotChainMixChanged(double mix); void slotChainMixModeChanged(EffectChainMixMode mixMode); void slotChainChannelStatusChanged(const QString& group, bool enabled); @@ -175,7 +174,7 @@ class EffectChainSlot : public QObject { void slotClearEffect(unsigned int iEffectSlotNumber); void slotControlClear(double v); - void slotControlChainEnabled(double v); + // void slotControlChainEnabled(double v); void slotControlChainMix(double v); void slotControlChainSuperParameter(double v, bool force = false); void slotControlChainMixMode(double v); From 5d0b58946e855ba191b1230576217612470e3d56 Mon Sep 17 00:00:00 2001 From: Ritvik Sharma Date: Sun, 10 Jun 2018 11:58:37 +0530 Subject: [PATCH 4/5] Removed redundant 'Mix' state from EffectChainSlot --- src/effects/effectchainslot.cpp | 45 ++++-------------------- src/effects/effectchainslot.h | 9 +---- src/engine/effects/engineeffect.cpp | 1 - src/engine/effects/engineeffectchain.cpp | 1 - 4 files changed, 8 insertions(+), 48 deletions(-) diff --git a/src/effects/effectchainslot.cpp b/src/effects/effectchainslot.cpp index 2fc61c5db04..27d3c770abe 100644 --- a/src/effects/effectchainslot.cpp +++ b/src/effects/effectchainslot.cpp @@ -29,11 +29,9 @@ EffectChainSlot::EffectChainSlot(EffectRack* pRack, const QString& group, m_group(group), m_pEffectRack(pRack), m_pEffectsManager(pEffectsManager), - m_bEnabled(true), m_id(id), m_name(""), m_mixMode(EffectChainMixMode::DrySlashWet), - m_dMix(0), m_pEngineEffectChain(nullptr) { qDebug() << "EffectChainSlot::EffectChainSlot " << pRack << ' ' << group << ' ' << iChainNumber; @@ -55,13 +53,13 @@ EffectChainSlot::EffectChainSlot(EffectRack* pRack, const QString& group, // Default to enabled. The skin might not show these buttons. m_pControlChainEnabled->setDefaultValue(true); m_pControlChainEnabled->set(true); - connect(m_pControlChainEnabled, SIGNAL(valueChanged()), - this, SLOT(slotChainUpdated())); + connect(m_pControlChainEnabled, SIGNAL(valueChanged(double)), + this, SLOT(slotChainUpdated(double))); m_pControlChainMix = new ControlPotmeter(ConfigKey(m_group, "mix"), 0.0, 1.0, false, true, false, true, 1.0); connect(m_pControlChainMix, SIGNAL(valueChanged(double)), - this, SLOT(slotControlChainMix(double))); + this, SLOT(slotChainUpdated(double))); m_pControlChainSuperParameter = new ControlPotmeter(ConfigKey(m_group, "super1"), 0.0, 1.0); connect(m_pControlChainSuperParameter, SIGNAL(valueChanged(double)), @@ -283,15 +281,8 @@ void EffectChainSlot::disableForInputChannel(const ChannelHandleAndGroup& handle } } -double EffectChainSlot::mix() const { - return m_dMix; -} - void EffectChainSlot::setMix(const double& dMix) { - m_dMix = dMix; - sendParameterUpdate(); - // emit(mixChanged(dMix)); - slotChainMixChanged(dMix); + m_pControlChainMix->set(dMix); } EffectChainMixMode EffectChainSlot::mixMode() const { @@ -377,7 +368,7 @@ void EffectChainSlot::sendParameterUpdate() { pRequest->pTargetChain = m_pEngineEffectChain; pRequest->SetEffectChainParameters.enabled = m_pControlChainEnabled->get(); pRequest->SetEffectChainParameters.mix_mode = m_mixMode; - pRequest->SetEffectChainParameters.mix = m_dMix; + pRequest->SetEffectChainParameters.mix = m_pControlChainMix->get(); m_pEffectsManager->writeRequest(pRequest); } @@ -442,16 +433,12 @@ void EffectChainSlot::slotChainNameChanged(const QString&) { emit(updated()); } -void EffectChainSlot::slotChainUpdated() { +void EffectChainSlot::slotChainUpdated(double v) { + Q_UNUSED(v); sendParameterUpdate(); emit(updated()); } -void EffectChainSlot::slotChainMixChanged(double mix) { - m_pControlChainMix->set(mix); - emit(updated()); -} - void EffectChainSlot::slotChainMixModeChanged(EffectChainMixMode mixMode) { m_pControlChainMixMode->set(static_cast(mixMode)); emit(updated()); @@ -501,11 +488,6 @@ void EffectChainSlot::loadEffectChainToSlot() { m_pControlChainMixMode->set( static_cast(mixMode())); - // Mix and enabled channels are persistent properties of the chain slot, - // not of the chain. Propagate the current settings to the chain. - // NOTE(Kshitij) : Check if these were required? - setMix(m_pControlChainMix->get()); - // Don't emit because we will below. for (int i = 0; i < m_slots.size(); ++i) { slotChainEffectChanged(i, false); @@ -606,19 +588,6 @@ void EffectChainSlot::slotControlClear(double v) { } } -void EffectChainSlot::slotControlChainMix(double v) { - qDebug() << debugString() << "slotControlChainMix" << v; - - // Clamp to [0.0, 1.0] - if (v < 0.0 || v > 1.0) { - qWarning() << debugString() << "value out of limits"; - v = math_clamp(v, 0.0, 1.0); - m_pControlChainMix->set(v); - } - - setMix(v); -} - void EffectChainSlot::slotControlChainSuperParameter(double v, bool force) { qDebug() << debugString() << "slotControlChainSuperParameter" << v; diff --git a/src/effects/effectchainslot.h b/src/effects/effectchainslot.h index 58a5b0e565a..79b060c311e 100644 --- a/src/effects/effectchainslot.h +++ b/src/effects/effectchainslot.h @@ -80,8 +80,6 @@ class EffectChainSlot : public QObject { QString description() const; void setDescription(const QString& description); - double mix() const; - // TODO(Kshitij) : Make this function private once EffectRack layer is removed void setMix(const double& dMix); @@ -162,10 +160,9 @@ class EffectChainSlot : public QObject { private slots: - void slotChainUpdated(); + void slotChainUpdated(double v); void slotChainEffectChanged(unsigned int effectSlotNumber, bool shouldEmit=true); void slotChainNameChanged(const QString& name); - void slotChainMixChanged(double mix); void slotChainMixModeChanged(EffectChainMixMode mixMode); void slotChainChannelStatusChanged(const QString& group, bool enabled); @@ -174,8 +171,6 @@ class EffectChainSlot : public QObject { void slotClearEffect(unsigned int iEffectSlotNumber); void slotControlClear(double v); - // void slotControlChainEnabled(double v); - void slotControlChainMix(double v); void slotControlChainSuperParameter(double v, bool force = false); void slotControlChainMixMode(double v); void slotControlChainSelector(double v); @@ -241,12 +236,10 @@ class EffectChainSlot : public QObject { EffectsManager* m_pEffectsManager; - bool m_bEnabled; QString m_id; QString m_name; QString m_description; EffectChainMixMode m_mixMode; - double m_dMix; QSet m_enabledInputChannels; QList m_effects; diff --git a/src/engine/effects/engineeffect.cpp b/src/engine/effects/engineeffect.cpp index 07647d96430..951022d735a 100644 --- a/src/engine/effects/engineeffect.cpp +++ b/src/engine/effects/engineeffect.cpp @@ -164,7 +164,6 @@ bool EngineEffect::process(const ChannelHandle& inputHandle, EffectEnableState effectiveEffectEnableState = m_effectEnableStateForChannelMatrix[inputHandle][outputHandle]; - qDebug() << debugString() << "processing enabled = " << static_cast(effectiveEffectEnableState); // If the EngineEffect is fully disabled, do not let // intermediate enabling/disabing signals from the chain override // the EngineEffect's state. diff --git a/src/engine/effects/engineeffectchain.cpp b/src/engine/effects/engineeffectchain.cpp index 700ddab717f..f9011f76138 100644 --- a/src/engine/effects/engineeffectchain.cpp +++ b/src/engine/effects/engineeffectchain.cpp @@ -270,7 +270,6 @@ bool EngineEffectChain::process(const ChannelHandle& inputHandle, for (EngineEffect* pEffect: m_effects) { if (pEffect != nullptr) { - qDebug() << "### Applying effect " << pEffect->name(); // Select an unused intermediate buffer for the next output if (pIntermediateInput == m_buffer1.data()) { pIntermediateOutput = m_buffer2.data(); From ad9c680f0e173a0fd09e94a2e4882fca4a269de3 Mon Sep 17 00:00:00 2001 From: Ritvik Sharma Date: Sun, 10 Jun 2018 14:52:41 +0530 Subject: [PATCH 5/5] Removed redundant 'MixMode' state from EffectChainSlot --- src/effects/effectchainslot.cpp | 34 +++--------------------- src/effects/effectchainslot.h | 6 ----- src/engine/effects/engineeffectchain.cpp | 3 ++- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/effects/effectchainslot.cpp b/src/effects/effectchainslot.cpp index 27d3c770abe..845295a063e 100644 --- a/src/effects/effectchainslot.cpp +++ b/src/effects/effectchainslot.cpp @@ -31,7 +31,6 @@ EffectChainSlot::EffectChainSlot(EffectRack* pRack, const QString& group, m_pEffectsManager(pEffectsManager), m_id(id), m_name(""), - m_mixMode(EffectChainMixMode::DrySlashWet), m_pEngineEffectChain(nullptr) { qDebug() << "EffectChainSlot::EffectChainSlot " << pRack << ' ' << group << ' ' << iChainNumber; @@ -71,7 +70,7 @@ EffectChainSlot::EffectChainSlot(EffectRack* pRack, const QString& group, m_pControlChainMixMode->setButtonMode(ControlPushButton::TOGGLE); m_pControlChainMixMode->setStates(static_cast(EffectChainMixMode::NumMixModes)); connect(m_pControlChainMixMode, SIGNAL(valueChanged(double)), - this, SLOT(slotControlChainMixMode(double))); + this, SLOT(slotChainUpdated(double))); m_pControlChainNextPreset = new ControlPushButton(ConfigKey(m_group, "next_chain")); connect(m_pControlChainNextPreset, SIGNAL(valueChanged(double)), @@ -285,17 +284,6 @@ void EffectChainSlot::setMix(const double& dMix) { m_pControlChainMix->set(dMix); } -EffectChainMixMode EffectChainSlot::mixMode() const { - return m_mixMode; -} - -void EffectChainSlot::setMixMode(EffectChainMixMode mixMode) { - m_mixMode = mixMode; - sendParameterUpdate(); - // emit(mixModeChanged(mixMode)); - slotChainMixModeChanged(mixMode); -} - void EffectChainSlot::addEffect(EffectPointer pEffect) { //qDebug() << debugString() << "addEffect" << pEffect; if (!pEffect) { @@ -367,7 +355,8 @@ void EffectChainSlot::sendParameterUpdate() { pRequest->type = EffectsRequest::SET_EFFECT_CHAIN_PARAMETERS; pRequest->pTargetChain = m_pEngineEffectChain; pRequest->SetEffectChainParameters.enabled = m_pControlChainEnabled->get(); - pRequest->SetEffectChainParameters.mix_mode = m_mixMode; + pRequest->SetEffectChainParameters.mix_mode = static_cast( + static_cast(m_pControlChainMixMode->get())); pRequest->SetEffectChainParameters.mix = m_pControlChainMix->get(); m_pEffectsManager->writeRequest(pRequest); } @@ -439,11 +428,6 @@ void EffectChainSlot::slotChainUpdated(double v) { emit(updated()); } -void EffectChainSlot::slotChainMixModeChanged(EffectChainMixMode mixMode) { - m_pControlChainMixMode->set(static_cast(mixMode)); - emit(updated()); -} - void EffectChainSlot::slotChainChannelStatusChanged(const QString& group, bool enabled) { ChannelInfo* pInfo = m_channelInfoByName.value(group, NULL); @@ -485,8 +469,6 @@ void EffectChainSlot::loadEffectChainToSlot() { clear(); m_pControlChainLoaded->forceSet(true); - m_pControlChainMixMode->set( - static_cast(mixMode())); // Don't emit because we will below. for (int i = 0; i < m_slots.size(); ++i) { @@ -602,16 +584,6 @@ void EffectChainSlot::slotControlChainSuperParameter(double v, bool force) { } } -void EffectChainSlot::slotControlChainMixMode(double v) { - // Intermediate cast to integer is needed for VC++. - EffectChainMixMode type = static_cast(int(v)); - (void)v; // this avoids a false warning with g++ 4.8.1 - - if (type < EffectChainMixMode::NumMixModes) { - setMixMode(type); - } -} - void EffectChainSlot::slotControlChainSelector(double v) { // qDebug() << debugString() << "slotControlChainSelector" << v; // if (v > 0) { diff --git a/src/effects/effectchainslot.h b/src/effects/effectchainslot.h index 79b060c311e..1176633e6c6 100644 --- a/src/effects/effectchainslot.h +++ b/src/effects/effectchainslot.h @@ -103,9 +103,6 @@ class EffectChainSlot : public QObject { } } - EffectChainMixMode mixMode() const; - void setMixMode(EffectChainMixMode type); - void addEffect(EffectPointer pEffect); void replaceEffect(unsigned int effectSlotNumber, EffectPointer pEffect); void removeEffect(unsigned int effectSlotNumber); @@ -163,7 +160,6 @@ class EffectChainSlot : public QObject { void slotChainUpdated(double v); void slotChainEffectChanged(unsigned int effectSlotNumber, bool shouldEmit=true); void slotChainNameChanged(const QString& name); - void slotChainMixModeChanged(EffectChainMixMode mixMode); void slotChainChannelStatusChanged(const QString& group, bool enabled); void slotEffectLoaded(EffectPointer pEffect, unsigned int slotNumber); @@ -172,7 +168,6 @@ class EffectChainSlot : public QObject { void slotControlClear(double v); void slotControlChainSuperParameter(double v, bool force = false); - void slotControlChainMixMode(double v); void slotControlChainSelector(double v); void slotControlChainNextPreset(double v); void slotControlChainPrevPreset(double v); @@ -239,7 +234,6 @@ class EffectChainSlot : public QObject { QString m_id; QString m_name; QString m_description; - EffectChainMixMode m_mixMode; QSet m_enabledInputChannels; QList m_effects; diff --git a/src/engine/effects/engineeffectchain.cpp b/src/engine/effects/engineeffectchain.cpp index f9011f76138..de38e009897 100644 --- a/src/engine/effects/engineeffectchain.cpp +++ b/src/engine/effects/engineeffectchain.cpp @@ -113,7 +113,8 @@ bool EngineEffectChain::processEffectsRequest(EffectsRequest& message, if (kEffectDebugOutput) { qDebug() << debugString() << this << "SET_EFFECT_CHAIN_PARAMETERS" << "enabled" << message.SetEffectChainParameters.enabled - << "mix" << message.SetEffectChainParameters.mix; + << "mix" << message.SetEffectChainParameters.mix + << "mix_mode" << static_cast(message.SetEffectChainParameters.mix_mode); } response.success = updateParameters(message); break;