Skip to content

Commit

Permalink
implement setting super and meta knobs from effect presets
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Apr 3, 2020
1 parent 720f61d commit 06af565
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/effects/effectchainslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ void EffectChainSlot::setDescription(const QString& description) {
void EffectChainSlot::loadEffect(const unsigned int iEffectSlotNumber,
const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pPreset) {
m_effectSlots[iEffectSlotNumber]->loadEffect(pManifest, std::move(pProcessor), pPreset, m_enabledInputChannels);
EffectPresetPointer pPreset,
bool adoptMetaknobFromPreset) {
m_effectSlots[iEffectSlotNumber]->loadEffect(pManifest, std::move(pProcessor), pPreset, m_enabledInputChannels, adoptMetaknobFromPreset);
}

void EffectChainSlot::sendParameterUpdate() {
Expand Down
3 changes: 2 additions & 1 deletion src/effects/effectchainslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class EffectChainSlot : public QObject {
virtual void loadEffect(const unsigned int iEffectSlotNumber,
const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pPreset);
EffectPresetPointer pPreset,
bool adoptMetaknobFromPreset = false);

signals:
// Signal that whoever is in charge of this EffectChainSlot should load the
Expand Down
17 changes: 12 additions & 5 deletions src/effects/effectslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ EffectParameterSlotBasePointer EffectSlot::getEffectParameterSlot(
void EffectSlot::loadEffect(const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pEffectPreset,
const QSet<ChannelHandleAndGroup>& activeChannels) {
const QSet<ChannelHandleAndGroup>& activeChannels,
bool adoptMetaknobFromPreset) {
if (kEffectDebugOutput) {
if (pManifest != nullptr) {
qDebug() << this << m_group << "loading effect" << pManifest->id() << pEffectPreset.get() << pProcessor.get();
Expand Down Expand Up @@ -283,12 +284,18 @@ void EffectSlot::loadEffect(const EffectManifestPointer pManifest,

m_pControlLoaded->forceSet(1.0);

// TODO: load meta knob from preset
if (m_pEffectsManager->isAdoptMetaknobValueEnabled()) {
slotEffectMetaParameter(m_pControlMetaParameter->get(), true);
if (adoptMetaknobFromPreset) {
// Update the ControlObject value, but do not sync the parameters
// with slotEffectMetaParameter. This allows presets to intentionally
// save parameters in a state inconsistent with the metaknob.
m_pControlMetaParameter->set(pEffectPreset->metaParameter());
} else {
slotEffectMetaParameter(m_pControlMetaParameter->get(), true);
}
} else {
m_pControlMetaParameter->set(m_pManifest->metaknobDefault());
slotEffectMetaParameter(m_pManifest->metaknobDefault(), true);
m_pControlMetaParameter->set(pEffectPreset->metaParameter());
slotEffectMetaParameter(pEffectPreset->metaParameter(), true);
}

emit effectChanged();
Expand Down
3 changes: 2 additions & 1 deletion src/effects/effectslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class EffectSlot : public QObject {
void loadEffect(const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pPreset,
const QSet<ChannelHandleAndGroup>& activeChannels);
const QSet<ChannelHandleAndGroup>& activeChannels,
bool adoptMetaknobFromPreset = false);

inline int getEffectSlotNumber() const {
return m_iEffectNumber;
Expand Down
12 changes: 8 additions & 4 deletions src/effects/effectsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ void EffectsManager::loadEqualizerEffect(const QString& deckGroup,
void EffectsManager::loadEffect(EffectChainSlotPointer pChainSlot,
const int iEffectSlotNumber,
const EffectManifestPointer pManifest,
EffectPresetPointer pPreset) {
EffectPresetPointer pPreset,
bool adoptMetaknobFromPreset) {
if (pPreset == nullptr) {
pPreset = m_defaultPresets.value(pManifest);
}
pChainSlot->loadEffect(iEffectSlotNumber, pManifest, createProcessor(pManifest), pPreset);
pChainSlot->loadEffect(iEffectSlotNumber, pManifest, createProcessor(pManifest), pPreset, adoptMetaknobFromPreset);
}

std::unique_ptr<EffectProcessor> EffectsManager::createProcessor(
Expand All @@ -188,6 +189,10 @@ void EffectsManager::loadEffectChainPreset(EffectChainSlotPointer pChainSlot,
VERIFY_OR_DEBUG_ASSERT(pPreset) {
return;
}
// Set the superknob before loading the effects so it does not change their
// metaknobs
pChainSlot->setSuperParameter(pPreset->superKnob());

int effectSlot = 0;
for (const auto& pEffectPreset : pPreset->effectPresets()) {
if (pEffectPreset->isNull()) {
Expand All @@ -200,11 +205,10 @@ void EffectsManager::loadEffectChainPreset(EffectChainSlotPointer pChainSlot,
continue;
}
EffectManifestPointer pManifest = pBackend->getManifest(pEffectPreset->id());
pChainSlot->loadEffect(effectSlot, pManifest, createProcessor(pManifest), pEffectPreset);
pChainSlot->loadEffect(effectSlot, pManifest, createProcessor(pManifest), pEffectPreset, true);
effectSlot++;
}
pChainSlot->setMixMode(pPreset->mixMode());
pChainSlot->setSuperParameter(pPreset->superKnob());
}

const QList<EffectManifestPointer> EffectsManager::getAvailableEffectManifestsFiltered(
Expand Down
3 changes: 2 additions & 1 deletion src/effects/effectsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class EffectsManager : public QObject {
EffectChainSlotPointer pChainSlot,
const int iEffectSlotNumber,
const EffectManifestPointer pManifest,
EffectPresetPointer pPreset = nullptr);
EffectPresetPointer pPreset = nullptr,
bool adoptMetaknobFromPreset = false);

std::unique_ptr<EffectProcessor> createProcessor(
const EffectManifestPointer pManifest);
Expand Down
4 changes: 4 additions & 0 deletions src/effects/presets/effectpreset.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class EffectPreset {
return m_id;
}

bool isNull() const {
return m_id.isEmpty();
}

EffectBackendType backendType() const {
return m_backendType;
}
Expand Down
10 changes: 6 additions & 4 deletions src/effects/specialeffectchainslots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ void QuickEffectChainSlot::loadEffect(
const unsigned int iEffectSlotNumber,
const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pPreset) {
EffectChainSlot::loadEffect(iEffectSlotNumber, pManifest, std::move(pProcessor), pPreset);
EffectPresetPointer pPreset,
bool adoptMetaknobFromPreset) {
EffectChainSlot::loadEffect(iEffectSlotNumber, pManifest, std::move(pProcessor), pPreset, adoptMetaknobFromPreset);
slotControlChainSuperParameter(m_pControlChainSuperParameter->get(), true);
}

Expand Down Expand Up @@ -150,10 +151,11 @@ void EqualizerEffectChainSlot::loadEffect(
const unsigned int iEffectSlotNumber,
const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pPreset) {
EffectPresetPointer pPreset,
bool adoptMetaknobFromPreset) {
// TODO: preserve effect parameters when loading new effect. This will allow
// for easy comparison of the sound of different equalizer effects.
EffectChainSlot::loadEffect(iEffectSlotNumber, pManifest, std::move(pProcessor), pPreset);
EffectChainSlot::loadEffect(iEffectSlotNumber, pManifest, std::move(pProcessor), pPreset, adoptMetaknobFromPreset);
m_pCOFilterWaveform->set(pManifest->isMixingEQ());
}

Expand Down
6 changes: 4 additions & 2 deletions src/effects/specialeffectchainslots.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class QuickEffectChainSlot : public PerGroupEffectChainSlot {
void loadEffect(const unsigned int iEffectSlotNumber,
const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pPreset) override;
EffectPresetPointer pPreset,
bool adoptMetaknobFromPreset = false) override;

static QString formatEffectChainSlotGroup(const QString& group);
static QString formatEffectSlotGroup(const QString& group,
Expand All @@ -55,7 +56,8 @@ class EqualizerEffectChainSlot : public PerGroupEffectChainSlot {
void loadEffect(const unsigned int iEffectSlotNumber,
const EffectManifestPointer pManifest,
std::unique_ptr<EffectProcessor> pProcessor,
EffectPresetPointer pPreset) override;
EffectPresetPointer pPreset,
bool adoptMetaknobFromPreset = false) override;

static QString formatEffectChainSlotGroup(const QString& group);
static QString formatEffectSlotGroup(const QString& group);
Expand Down

0 comments on commit 06af565

Please sign in to comment.