summaryrefslogtreecommitdiffstats
path: root/src/effects/chains
diff options
context:
space:
mode:
authorBe <be@mixxx.org>2021-03-12 14:21:03 -0600
committerBe <be@mixxx.org>2021-03-12 14:31:32 -0600
commit7b0a0d524db99e2b3511e1c196dd15a68ca92371 (patch)
treeab28fc16b600aca12e9110646d9f63a2c8abdcf7 /src/effects/chains
parent341f6e9fa2e72f6cb613c5abcba95ce28f76660b (diff)
split EffectChain subclasses into separate files
Diffstat (limited to 'src/effects/chains')
-rw-r--r--src/effects/chains/equalizereffectchain.cpp77
-rw-r--r--src/effects/chains/equalizereffectchain.h25
-rw-r--r--src/effects/chains/outputeffectchain.cpp37
-rw-r--r--src/effects/chains/outputeffectchain.h14
-rw-r--r--src/effects/chains/pergroupeffectchain.cpp32
-rw-r--r--src/effects/chains/pergroupeffectchain.h14
-rw-r--r--src/effects/chains/quickeffectchain.cpp58
-rw-r--r--src/effects/chains/quickeffectchain.h25
-rw-r--r--src/effects/chains/standardeffectchain.cpp42
-rw-r--r--src/effects/chains/standardeffectchain.h18
10 files changed, 342 insertions, 0 deletions
diff --git a/src/effects/chains/equalizereffectchain.cpp b/src/effects/chains/equalizereffectchain.cpp
new file mode 100644
index 0000000000..4b5e7ce347
--- /dev/null
+++ b/src/effects/chains/equalizereffectchain.cpp
@@ -0,0 +1,77 @@
+#include "effects/chains/equalizereffectchain.h"
+
+#include "effects/effectslot.h"
+
+EqualizerEffectChain::EqualizerEffectChain(const QString& group,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger)
+ : PerGroupEffectChain(group,
+ formatEffectChainGroup(group),
+ SignalProcessingStage::Prefader,
+ pEffectsManager,
+ pEffectsMessenger),
+ m_pCOFilterWaveform(
+ new ControlObject(ConfigKey(group, "filterWaveformEnable"))) {
+ // Add a single effect slot
+ addEffectSlot(formatEffectSlotGroup(group));
+ m_effectSlots[0]->setEnabled(true);
+ // DlgPrefEq loads the Effect with loadEffectToGroup
+
+ setupLegacyAliasesForGroup(group);
+}
+
+void EqualizerEffectChain::setFilterWaveform(bool state) {
+ m_pCOFilterWaveform->set(state);
+}
+
+QString EqualizerEffectChain::formatEffectChainGroup(const QString& group) {
+ return QString("[EqualizerRack1_%1]").arg(group);
+}
+
+QString EqualizerEffectChain::formatEffectSlotGroup(const QString& group) {
+ return QString("[EqualizerRack1_%1_Effect1]")
+ .arg(group);
+}
+
+void EqualizerEffectChain::setupLegacyAliasesForGroup(const QString& group) {
+ // Create aliases for legacy EQ controls.
+ EffectSlotPointer pEffectSlot = getEffectSlot(0);
+ if (pEffectSlot) {
+ const QString& effectSlotGroup = pEffectSlot->getGroup();
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterLow"),
+ ConfigKey(effectSlotGroup, "parameter1"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterMid"),
+ ConfigKey(effectSlotGroup, "parameter2"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterHigh"),
+ ConfigKey(effectSlotGroup, "parameter3"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterLowKill"),
+ ConfigKey(effectSlotGroup, "button_parameter1"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterMidKill"),
+ ConfigKey(effectSlotGroup, "button_parameter2"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterHighKill"),
+ ConfigKey(effectSlotGroup, "button_parameter3"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterLow_loaded"),
+ ConfigKey(effectSlotGroup, "parameter1_loaded"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterMid_loaded"),
+ ConfigKey(effectSlotGroup, "parameter2_loaded"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterHigh_loaded"),
+ ConfigKey(effectSlotGroup, "parameter3_loaded"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterLowKill_loaded"),
+ ConfigKey(effectSlotGroup, "button_parameter1_loaded"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterMidKill_loaded"),
+ ConfigKey(effectSlotGroup, "button_parameter2_loaded"));
+
+ ControlDoublePrivate::insertAlias(ConfigKey(group, "filterHighKill_loaded"),
+ ConfigKey(effectSlotGroup, "button_parameter3_loaded"));
+ }
+}
diff --git a/src/effects/chains/equalizereffectchain.h b/src/effects/chains/equalizereffectchain.h
new file mode 100644
index 0000000000..153ca1b864
--- /dev/null
+++ b/src/effects/chains/equalizereffectchain.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "effects/chains/pergroupeffectchain.h"
+
+/// EqualizerEffectChain is specifically for the equalizers only.
+/// It only has a single effect in the chain. The user can pick the
+/// effect in the preferences. In the main GUI, only the parameters of
+/// that single effect are presented, not the metaknob nor superknob.
+/// EqualizerEffectChain is hardwired to one input channel, always
+/// enabled, and has the mix knob fully enabled.
+class EqualizerEffectChain : public PerGroupEffectChain {
+ public:
+ EqualizerEffectChain(const QString& group,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger);
+
+ void setFilterWaveform(bool state);
+
+ static QString formatEffectChainGroup(const QString& group);
+ static QString formatEffectSlotGroup(const QString& group);
+
+ private:
+ void setupLegacyAliasesForGroup(const QString& group);
+ std::unique_ptr<ControlObject> m_pCOFilterWaveform;
+};
diff --git a/src/effects/chains/outputeffectchain.cpp b/src/effects/chains/outputeffectchain.cpp
new file mode 100644
index 0000000000..6a47f3ad25
--- /dev/null
+++ b/src/effects/chains/outputeffectchain.cpp
@@ -0,0 +1,37 @@
+#include "effects/chains/outputeffectchain.h"
+
+#include "effects/effectslot.h"
+
+OutputEffectChain::OutputEffectChain(EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger)
+ : EffectChain(formatEffectChainGroup("[Master]"),
+ pEffectsManager,
+ pEffectsMessenger,
+ SignalProcessingStage::Postfader) {
+ addEffectSlot("[OutputEffectRack_[Master]_Effect1]");
+ m_effectSlots[0]->setEnabled(true);
+
+ // Register the master channel
+ const ChannelHandleAndGroup* masterHandleAndGroup = nullptr;
+
+ // TODO(Be): Remove this hideous hack to get the ChannelHandleAndGroup
+ const QSet<ChannelHandleAndGroup>& registeredChannels =
+ m_pEffectsManager->registeredInputChannels();
+ for (const ChannelHandleAndGroup& handle_group : registeredChannels) {
+ if (handle_group.name() == "[MasterOutput]") {
+ masterHandleAndGroup = &handle_group;
+ break;
+ }
+ }
+ DEBUG_ASSERT(masterHandleAndGroup != nullptr);
+
+ registerInputChannel(*masterHandleAndGroup);
+ enableForInputChannel(*masterHandleAndGroup);
+ m_pControlChainMix->set(1.0);
+ sendParameterUpdate();
+}
+
+QString OutputEffectChain::formatEffectChainGroup(
+ const QString& group) {
+ return QString("[OutputEffectRack_%1]").arg(group);
+}
diff --git a/src/effects/chains/outputeffectchain.h b/src/effects/chains/outputeffectchain.h
new file mode 100644
index 0000000000..195594b8bd
--- /dev/null
+++ b/src/effects/chains/outputeffectchain.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "effects/effectchain.h"
+
+/// OutputEffectChain is hardwired to only one of Mixxx's outputs.
+/// This is used for the main mix equalizer.
+class OutputEffectChain : public EffectChain {
+ public:
+ OutputEffectChain(EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger);
+
+ private:
+ static QString formatEffectChainGroup(const QString& group);
+};
diff --git a/src/effects/chains/pergroupeffectchain.cpp b/src/effects/chains/pergroupeffectchain.cpp
new file mode 100644
index 0000000000..2ec903bbb4
--- /dev/null
+++ b/src/effects/chains/pergroupeffectchain.cpp
@@ -0,0 +1,32 @@
+#include "effects/chains/pergroupeffectchain.h"
+
+#include "effects/effectsmanager.h"
+
+PerGroupEffectChain::PerGroupEffectChain(const QString& group,
+ const QString& chainSlotGroup,
+ SignalProcessingStage stage,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger)
+ : EffectChain(chainSlotGroup,
+ pEffectsManager,
+ pEffectsMessenger,
+ stage) {
+ // Set the chain to be fully wet.
+ m_pControlChainMix->set(1.0);
+ sendParameterUpdate();
+
+ // TODO(rryan): remove.
+ const ChannelHandleAndGroup* handleAndGroup = nullptr;
+ for (const ChannelHandleAndGroup& handle_group :
+ m_pEffectsManager->registeredInputChannels()) {
+ if (handle_group.name() == group) {
+ handleAndGroup = &handle_group;
+ break;
+ }
+ }
+ DEBUG_ASSERT(handleAndGroup != nullptr);
+
+ // Register this channel alone with the chain slot.
+ registerInputChannel(*handleAndGroup);
+ enableForInputChannel(*handleAndGroup);
+}
diff --git a/src/effects/chains/pergroupeffectchain.h b/src/effects/chains/pergroupeffectchain.h
new file mode 100644
index 0000000000..4517461052
--- /dev/null
+++ b/src/effects/chains/pergroupeffectchain.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "effects/effectchain.h"
+
+/// PerGroupEffectChain is a base class hardwired for one input channel.
+/// The routing switches are not presented to the user.
+class PerGroupEffectChain : public EffectChain {
+ public:
+ PerGroupEffectChain(const QString& group,
+ const QString& chainSlotGroup,
+ SignalProcessingStage stage,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger);
+};
diff --git a/src/effects/chains/quickeffectchain.cpp b/src/effects/chains/quickeffectchain.cpp
new file mode 100644
index 0000000000..65b7653e2a
--- /dev/null
+++ b/src/effects/chains/quickeffectchain.cpp
@@ -0,0 +1,58 @@
+#include "effects/chains/quickeffectchain.h"
+
+#include "effects/effectslot.h"
+#include "effects/presets/effectchainpresetmanager.h"
+
+QuickEffectChain::QuickEffectChain(const QString& group,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger)
+ : PerGroupEffectChain(group,
+ formatEffectChainGroup(group),
+ SignalProcessingStage::Postfader,
+ pEffectsManager,
+ pEffectsMessenger) {
+ for (int i = 0; i < kNumEffectsPerUnit; ++i) {
+ addEffectSlot(formatEffectSlotGroup(group, i));
+ m_effectSlots.at(i)->setEnabled(true);
+ }
+ disconnect(m_pChainPresetManager.data(),
+ &EffectChainPresetManager::effectChainPresetListUpdated,
+ this,
+ &QuickEffectChain::slotPresetListUpdated);
+ m_pControlNumPresetsAvailable->forceSet(m_pChainPresetManager->numQuickEffectPresets());
+ connect(m_pChainPresetManager.data(),
+ &EffectChainPresetManager::quickEffectChainPresetListUpdated,
+ this,
+ &QuickEffectChain::slotPresetListUpdated);
+}
+
+QString QuickEffectChain::formatEffectChainGroup(const QString& group) {
+ return QString("[QuickEffectRack1_%1]").arg(group);
+}
+
+QString QuickEffectChain::formatEffectSlotGroup(
+ const QString& group, const int iEffectSlotNumber) {
+ return QString("[QuickEffectRack1_%1_Effect%2]")
+ .arg(group,
+ QString::number(iEffectSlotNumber + 1));
+}
+
+int QuickEffectChain::presetIndex() const {
+ return m_pChainPresetManager->quickEffectPresetIndex(m_presetName);
+}
+
+EffectChainPresetPointer QuickEffectChain::presetAtIndex(int index) const {
+ return m_pChainPresetManager->quickEffectPresetAtIndex(index);
+}
+
+void QuickEffectChain::loadChainPreset(EffectChainPresetPointer pPreset) {
+ EffectChain::loadChainPreset(pPreset);
+ setSuperParameter(pPreset->superKnob(), true);
+}
+
+int QuickEffectChain::numPresets() const {
+ VERIFY_OR_DEBUG_ASSERT(m_pChainPresetManager) {
+ return 0;
+ }
+ return m_pChainPresetManager->numQuickEffectPresets();
+}
diff --git a/src/effects/chains/quickeffectchain.h b/src/effects/chains/quickeffectchain.h
new file mode 100644
index 0000000000..7f35486219
--- /dev/null
+++ b/src/effects/chains/quickeffectchain.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "effects/chains/pergroupeffectchain.h"
+
+/// QuickEffectChain is a simplified interface for effect chains.
+/// It only presents the superknob and chain enable switch to the user.
+/// The user can design complex EffectChainPresets with a StandardEffectChain
+/// then load it into QuickEffectChain. QuickEffectChain is hardwired to one
+/// input channel with the mix knob fully enabled.
+class QuickEffectChain : public PerGroupEffectChain {
+ public:
+ QuickEffectChain(const QString& group,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger);
+
+ static QString formatEffectChainGroup(const QString& group);
+ static QString formatEffectSlotGroup(const QString& group,
+ const int iEffectSlotNumber = 0);
+
+ int presetIndex() const override;
+ EffectChainPresetPointer presetAtIndex(int index) const override;
+
+ void loadChainPreset(EffectChainPresetPointer pPreset) override;
+ int numPresets() const override;
+};
diff --git a/src/effects/chains/standardeffectchain.cpp b/src/effects/chains/standardeffectchain.cpp
new file mode 100644
index 0000000000..a2dc01d766
--- /dev/null
+++ b/src/effects/chains/standardeffectchain.cpp
@@ -0,0 +1,42 @@
+#include "effects/chains/standardeffectchain.h"
+
+#include "effects/effectsmanager.h"
+#include "mixer/playermanager.h"
+
+StandardEffectChain::StandardEffectChain(unsigned int iChainNumber,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger)
+ : EffectChain(formatEffectChainGroup(iChainNumber),
+ pEffectsManager,
+ pEffectsMessenger,
+ SignalProcessingStage::Postfader) {
+ for (int i = 0; i < kNumEffectsPerUnit; ++i) {
+ addEffectSlot(formatEffectSlotGroup(iChainNumber, i));
+ }
+
+ const QSet<ChannelHandleAndGroup>& registeredChannels =
+ m_pEffectsManager->registeredInputChannels();
+ for (const ChannelHandleAndGroup& handle_group : registeredChannels) {
+ int deckNumber;
+ if (PlayerManager::isDeckGroup(handle_group.name(), &deckNumber) &&
+ (iChainNumber + 1) == (unsigned)deckNumber) {
+ registerInputChannel(handle_group, 1.0);
+ } else {
+ registerInputChannel(handle_group, 0.0);
+ }
+ }
+}
+
+QString StandardEffectChain::formatEffectChainGroup(const int iChainNumber) {
+ // EffectRacks never did anything and there was never more than one of them,
+ // but it remains in the ControlObject group name for backwards compatibility.
+ return QString("[EffectRack1_EffectUnit%1]")
+ .arg(QString::number(iChainNumber + 1));
+}
+
+QString StandardEffectChain::formatEffectSlotGroup(const int iChainSlotNumber,
+ const int iEffectSlotNumber) {
+ return QString("[EffectRack1_EffectUnit%1_Effect%2]")
+ .arg(QString::number(iChainSlotNumber + 1),
+ QString::number(iEffectSlotNumber + 1));
+}
diff --git a/src/effects/chains/standardeffectchain.h b/src/effects/chains/standardeffectchain.h
new file mode 100644
index 0000000000..9a470e41f7
--- /dev/null
+++ b/src/effects/chains/standardeffectchain.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "effects/effectchain.h"
+
+/// StandardEffectChain is a chain shown in the GUI with the
+/// detail of the input routing switches, mix knob, superknob,
+/// all effects, their parameters, enable switches, and metaknob
+/// linkings. However, the chain enable switch is hidden because it
+/// is redundant with the input routing switches and effect enable switches.
+class StandardEffectChain : public EffectChain {
+ public:
+ StandardEffectChain(unsigned int iChainNumber,
+ EffectsManager* pEffectsManager,
+ EffectsMessengerPointer pEffectsMessenger);
+ static QString formatEffectChainGroup(const int iChainNumber);
+ static QString formatEffectSlotGroup(const int iChainSlotNumber,
+ const int iEffectSlotNumber);
+};