Skip to content

Commit

Permalink
Added EffectChainPreset
Browse files Browse the repository at this point in the history
- Added EffectChainPreset class
- Added EffectsManager::loadEffectChainPresets
  • Loading branch information
kshitij98 committed Feb 17, 2019
1 parent 2ef7b92 commit 3239628
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 4 deletions.
1 change: 1 addition & 0 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ def sources(self, build):

"src/effects/effectparameter.cpp",

"src/effects/effectchainpreset.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 @@ -73,6 +73,9 @@ typedef QSharedPointer<EffectParameterSlotBase> EffectParameterSlotBasePointer;
class EffectChainSlot;
typedef QSharedPointer<EffectChainSlot> EffectChainSlotPointer;

class EffectChainPreset;
typedef QSharedPointer<EffectChainPreset> EffectChainPresetPointer;

class StandardEffectChainSlot;
typedef QSharedPointer<StandardEffectChainSlot> StandardEffectChainSlotPointer;

Expand Down
18 changes: 18 additions & 0 deletions src/effects/effectchainpreset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "effects/effectchainpreset.h"

#include "effects/effectxmlelements.h"
#include "util/xml.h"

EffectChainPreset::EffectChainPreset() {
}

EffectChainPreset::EffectChainPreset(const QDomElement& element) {
VERIFY_OR_DEBUG_ASSERT(element.hasChildNodes()) {
return;
}

m_name = XmlParse::selectNodeQString(element, EffectXml::ChainName);
}

EffectChainPreset::~EffectChainPreset() {
}
24 changes: 24 additions & 0 deletions src/effects/effectchainpreset.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef EFFECTCHAINPRESET_H
#define EFFECTCHAINPRESET_H

#include <QDomElement>

#include "effects/defs.h"


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

QString name() const {
return m_name;
}

private:
QString m_name;

};

#endif /* EFFECTCHAINPRESET_H */
36 changes: 35 additions & 1 deletion src/effects/effectsmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "effects/effectsmanager.h"

#include <QDir>
#include <QMetaType>
#include <QtAlgorithms>

#include <algorithm>

#include "engine/effects/engineeffectsmanager.h"
#include "effects/effectchainpreset.h"
#include "effects/effectsbackend.h"
#include "effects/effectslot.h"
#include "effects/effectxmlelements.h"
Expand Down Expand Up @@ -272,6 +274,8 @@ 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 @@ -328,7 +332,8 @@ void EffectsManager::addQuickEffectChainSlot(const QString& deckGroupName) {
m_effectChainSlotsByGroup.insert(pChainSlot->group(), pChainSlot);
}

EffectChainSlotPointer EffectsManager::getEffectChainSlot(const QString& group) const {
EffectChainSlotPointer EffectsManager::getEffectChainSlot(
const QString& group) const {
return m_effectChainSlotsByGroup.value(group);
}

Expand Down Expand Up @@ -384,6 +389,7 @@ bool EffectsManager::getEffectVisibility(EffectManifestPointer pManifest) {
}

void EffectsManager::setup() {
loadEffectChainPresets();
// Add postfader effect chain slots
addStandardEffectChainSlots();
addOutputEffectChainSlot();
Expand Down Expand Up @@ -498,3 +504,31 @@ void EffectsManager::collectGarbage(const EffectsRequest* pRequest) {
pRequest->DisableInputChannelForChain.pChannelHandle);
}
}

void EffectsManager::loadEffectChainPresets() {
QDir settingsPath(m_pConfig->getSettingsPath());
QFile file(settingsPath.absoluteFilePath("effects.xml"));
QDomDocument doc;

if (!file.open(QIODevice::ReadOnly)) {
return;
} else if (!doc.setContent(&file)) {
file.close();
return;
}
file.close();

QDomElement root = doc.documentElement();
QDomElement chainsElement = XmlParse::selectElement(root, EffectXml::ChainsRoot);
QDomNodeList chainsList = chainsElement.elementsByTagName(EffectXml::Chain);

for (int i=0; i<chainsList.count(); ++i) {
QDomNode chainNode = chainsList.at(i);

if (chainNode.isElement()) {
QDomElement chainElement = chainNode.toElement();
EffectChainPresetPointer pPreset(new EffectChainPreset(chainElement));
m_effectChainPresets.insert(pPreset->name(), pPreset);
}
}
}
3 changes: 3 additions & 0 deletions src/effects/effectsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class EffectsManager : public QObject {

// NOTE(Kshitij) : Use new functions
// void loadEffectChains();
void loadEffectChainPresets();

// TODO: Remove these methods to reduce coupling between GUI and
// effects system implementation details.
Expand Down Expand Up @@ -187,6 +188,8 @@ class EffectsManager : public QObject {
QHash<QString, EqualizerEffectChainSlotPointer> m_equalizerEffectChainSlots;
QHash<QString, QuickEffectChainSlotPointer> m_quickEffectChainSlots;

QHash<QString, EffectChainPresetPointer> m_effectChainPresets;

DISALLOW_COPY_AND_ASSIGN(EffectsManager);
};

Expand Down
3 changes: 0 additions & 3 deletions src/effects/effectxmlelements.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ const int kXmlSchemaVersion = 0;
const QString Root("MixxxEffects");
const QString SchemaVersion("SchemaVersion");

const QString Rack("Rack");
const QString RackGroup("Group");

const QString ChainsRoot("Chains");
const QString Chain("EffectChain");
const QString ChainSuperParameter("SuperParameterValue");
Expand Down

0 comments on commit 3239628

Please sign in to comment.