Skip to content

Commit

Permalink
Added EffectPreset
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitij98 committed Feb 17, 2019
1 parent 3239628 commit 6b908bf
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 19 deletions.
1 change: 1 addition & 0 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/effects/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ typedef QSharedPointer<EffectChainSlot> EffectChainSlotPointer;
class EffectChainPreset;
typedef QSharedPointer<EffectChainPreset> EffectChainPresetPointer;

class EffectPreset;
typedef QSharedPointer<EffectPreset> EffectPresetPointer;

class StandardEffectChainSlot;
typedef QSharedPointer<StandardEffectChainSlot> StandardEffectChainSlotPointer;

Expand Down
22 changes: 21 additions & 1 deletion src/effects/effectchainpreset.cpp
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
20 changes: 13 additions & 7 deletions src/effects/effectchainpreset.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
#include <QDomElement>

#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 <EffectPresetPointer> m_effectPresets;

};

Expand Down
32 changes: 32 additions & 0 deletions src/effects/effectpreset.cpp
Original file line number Diff line number Diff line change
@@ -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() {
}
23 changes: 23 additions & 0 deletions src/effects/effectpreset.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef EFFECTPRESET_H
#define EFFECTPRESET_H

#include <QDomElement>

#include "effects/defs.h"


class EffectPreset {
public:
EffectPreset();
EffectPreset(const QDomElement& element);
~EffectPreset();

private:
QString m_id;
QString m_version;
double m_dMetaParameter;

// QList <EffectParameterPresetPointer> m_effectParameterPresets;
};

#endif /* EFFECTPRESET_H */
8 changes: 0 additions & 8 deletions src/effects/effectsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions src/effects/effectsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6b908bf

Please sign in to comment.