From 6b908bf335d3b88986f6891be7afd45652bc3021 Mon Sep 17 00:00:00 2001 From: Kshitij Gupta Date: Sun, 17 Feb 2019 12:11:41 +0530 Subject: [PATCH] Added EffectPreset --- build/depends.py | 1 + src/effects/defs.h | 3 +++ src/effects/effectchainpreset.cpp | 22 ++++++++++++++++++++- src/effects/effectchainpreset.h | 20 ++++++++++++------- src/effects/effectpreset.cpp | 32 +++++++++++++++++++++++++++++++ src/effects/effectpreset.h | 23 ++++++++++++++++++++++ src/effects/effectsmanager.cpp | 8 -------- src/effects/effectsmanager.h | 3 --- 8 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 src/effects/effectpreset.cpp create mode 100644 src/effects/effectpreset.h diff --git a/build/depends.py b/build/depends.py index 6b6c65e466e1..7c039d59f969 100644 --- a/build/depends.py +++ b/build/depends.py @@ -746,6 +746,7 @@ def sources(self, build): "src/effects/effectparameter.cpp", "src/effects/effectchainpreset.cpp", + "src/effects/effectpreset.cpp", "src/effects/effectchainslot.cpp", "src/effects/specialeffectchainslots.cpp", "src/effects/effectslot.cpp", diff --git a/src/effects/defs.h b/src/effects/defs.h index 9bc61c282203..aa64e1d68bff 100644 --- a/src/effects/defs.h +++ b/src/effects/defs.h @@ -76,6 +76,9 @@ typedef QSharedPointer EffectChainSlotPointer; class EffectChainPreset; typedef QSharedPointer EffectChainPresetPointer; +class EffectPreset; +typedef QSharedPointer EffectPresetPointer; + class StandardEffectChainSlot; typedef QSharedPointer StandardEffectChainSlotPointer; diff --git a/src/effects/effectchainpreset.cpp b/src/effects/effectchainpreset.cpp index c1aaae18b661..394a222b387e 100644 --- a/src/effects/effectchainpreset.cpp +++ b/src/effects/effectchainpreset.cpp @@ -1,17 +1,37 @@ #include "effects/effectchainpreset.h" #include "effects/effectxmlelements.h" +#include "effects/effectchainslot.h" #include "util/xml.h" EffectChainPreset::EffectChainPreset() { } EffectChainPreset::EffectChainPreset(const QDomElement& element) { - VERIFY_OR_DEBUG_ASSERT(element.hasChildNodes()) { + if (!element.hasChildNodes()) { return; } + m_id = XmlParse::selectNodeQString(element, EffectXml::ChainId); m_name = XmlParse::selectNodeQString(element, EffectXml::ChainName); + m_description = XmlParse::selectNodeQString(element, EffectXml::ChainDescription); + + QString mixModeStr = XmlParse::selectNodeQString(element, EffectXml::ChainMixMode); + m_mixMode = EffectChainSlot::mixModeFromString(mixModeStr); + + m_dSuper = XmlParse::selectNodeDouble(element, EffectXml::ChainSuperParameter); + + QDomElement effectsElement = XmlParse::selectElement(element, EffectXml::EffectsRoot); + QDomNodeList effectList = effectsElement.childNodes(); + + for (int i = 0; i < effectList.count(); ++i) { + QDomNode effectNode = effectList.at(i); + if (effectNode.isElement()) { + QDomElement effectElement = effectNode.toElement(); + EffectPresetPointer pPreset(new EffectPreset(effectElement)); + m_effectPresets.append(pPreset); + } + } } EffectChainPreset::~EffectChainPreset() { diff --git a/src/effects/effectchainpreset.h b/src/effects/effectchainpreset.h index 7ac2ce7aab08..5e626ea4ee6b 100644 --- a/src/effects/effectchainpreset.h +++ b/src/effects/effectchainpreset.h @@ -4,20 +4,26 @@ #include #include "effects/defs.h" +#include "effects/effectpreset.h" class EffectChainPreset { public: - EffectChainPreset(); - EffectChainPreset(const QDomElement& element); - ~EffectChainPreset(); + EffectChainPreset(); + EffectChainPreset(const QDomElement& element); + ~EffectChainPreset(); - QString name() const { - return m_name; - } + QString name() const { + return m_name; + } private: - QString m_name; + QString m_id; + QString m_name; + QString m_description; + double m_dSuper; + EffectChainMixMode m_mixMode; + QList m_effectPresets; }; diff --git a/src/effects/effectpreset.cpp b/src/effects/effectpreset.cpp new file mode 100644 index 000000000000..ab2adbcfc08b --- /dev/null +++ b/src/effects/effectpreset.cpp @@ -0,0 +1,32 @@ +#include "effects/effectpreset.h" + +#include "effects/effectxmlelements.h" +#include "util/xml.h" + +EffectPreset::EffectPreset() { +} + +EffectPreset::EffectPreset(const QDomElement& element) { + if (!element.hasChildNodes()) { + return; + } + + m_id = XmlParse::selectNodeQString(element, EffectXml::EffectId); + m_version = XmlParse::selectNodeQString(element, EffectXml::EffectVersion); + m_dMetaParameter = XmlParse::selectNodeDouble(element, EffectXml::EffectMetaParameter); + + QDomElement parametersElement = XmlParse::selectElement(element, EffectXml::ParametersRoot); + QDomNodeList parametersList = parametersElement.childNodes(); + + for (int i = 0; i < parametersList.count(); ++i) { + QDomNode parameterNode = parametersList.at(i); + if (parameterNode.isElement()) { + QDomElement parameterElement = parameterNode.toElement(); + // EffectParameterPresetPointer pPreset(new EffectParameterPreset(parameterElement)); + // m_effectParameterPresets.append(pPreset); + } + } +} + +EffectPreset::~EffectPreset() { +} diff --git a/src/effects/effectpreset.h b/src/effects/effectpreset.h new file mode 100644 index 000000000000..fe4e520d2b51 --- /dev/null +++ b/src/effects/effectpreset.h @@ -0,0 +1,23 @@ +#ifndef EFFECTPRESET_H +#define EFFECTPRESET_H + +#include + +#include "effects/defs.h" + + +class EffectPreset { + public: + EffectPreset(); + EffectPreset(const QDomElement& element); + ~EffectPreset(); + + private: + QString m_id; + QString m_version; + double m_dMetaParameter; + + // QList m_effectParameterPresets; +}; + +#endif /* EFFECTPRESET_H */ \ No newline at end of file diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index ee79d08a4417..6978f7a942ca 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -274,8 +274,6 @@ EffectManifestPointer EffectsManager::getManifestFromUniqueId(const QString& uid } void EffectsManager::addStandardEffectChainSlots() { - EffectChainPresetPointer pPreset = m_effectChainPresets["Default"]; - for (int i = 0; i < EffectsManager::kNumStandardEffectChains; ++i) { VERIFY_OR_DEBUG_ASSERT(!m_effectChainSlotsByGroup.contains( StandardEffectChainSlot::formatEffectChainSlotGroup(i))) { @@ -395,12 +393,6 @@ void EffectsManager::setup() { addOutputEffectChainSlot(); } -// NOTE(Kshitij) : Use new functions for effect loading using Effect Preset -// void EffectsManager::loadEffectChains() { -// // populate rack and restore state from effects.xml -// m_pEffectChainManager->loadEffectChains(); -// } - void EffectsManager::setEffectParameterPosition(EffectManifestPointer pManifest, const unsigned int parameterId, const unsigned int position) { for (auto& pChainSlot : m_standardEffectChainSlots) { diff --git a/src/effects/effectsmanager.h b/src/effects/effectsmanager.h index 69f8a8a1f677..06d7c9260991 100644 --- a/src/effects/effectsmanager.h +++ b/src/effects/effectsmanager.h @@ -53,7 +53,6 @@ class EffectsManager : public QObject { // NOTE(Kshitij) : New functions for saving and loading // bool saveEffectChains(); - // void loadEffectChains(); static const int kNumStandardEffectChains = 4; @@ -104,8 +103,6 @@ class EffectsManager : public QObject { void addEqualizerEffectChainSlot(const QString& deckGroupName); void addQuickEffectChainSlot(const QString& deckGroupName); - // NOTE(Kshitij) : Use new functions - // void loadEffectChains(); void loadEffectChainPresets(); // TODO: Remove these methods to reduce coupling between GUI and