TEST_F(EffectChainSlotTest, ChainSlotMirrorsLoadedChain) { EffectChainPointer pChain(new EffectChain(m_pEffectsManager.data(), "org.mixxx.test.chain1")); int iRackNumber = 0; int iChainNumber = 0; StandardEffectRackPointer pRack = m_pEffectsManager->addStandardEffectRack(); EffectChainSlotPointer pSlot = pRack->addEffectChainSlot(); pSlot->clear(); QString group = StandardEffectRack::formatEffectChainSlotGroupString( iRackNumber, iChainNumber); pSlot->loadEffectChain(pChain); pChain->setEnabled(true); EXPECT_LT(0.0, ControlObject::get(ConfigKey(group, "enabled"))); pChain->setEnabled(false); EXPECT_DOUBLE_EQ(0.0, ControlObject::get(ConfigKey(group, "enabled"))); ControlObject::set(ConfigKey(group, "enabled"), 1.0); EXPECT_TRUE(pChain->enabled()); // Loaded is read-only. Sets to it should not do anything. ControlObject::set(ConfigKey(group, "loaded"), 0); EXPECT_TRUE(ControlObject::get(ConfigKey(group, "loaded")) > 0.0); // numEffects is read-only. Sets to it should not do anything. ControlObject::set(ConfigKey(group, "num_effects"), 1); EXPECT_EQ(0U, pChain->numEffects()); pChain->setMix(1.0); EXPECT_DOUBLE_EQ(pChain->mix(), ControlObject::get(ConfigKey(group, "mix"))); ControlObject::set(ConfigKey(group, "mix"), 0.5); EXPECT_DOUBLE_EQ(0.5, pChain->mix()); pChain->setInsertionType(EffectChain::SEND); EXPECT_DOUBLE_EQ(pChain->insertionType(), ControlObject::get(ConfigKey(group, "insertion_type"))); ControlObject::set(ConfigKey(group, "insertion_type"), EffectChain::INSERT); EXPECT_DOUBLE_EQ(EffectChain::INSERT, pChain->insertionType()); EXPECT_FALSE(pChain->enabledForChannel(m_master)); pChain->enableForChannel(m_master); EXPECT_LT(0.0, ControlObject::get(ConfigKey(group, "group_[Master]_enable"))); ControlObject::set(ConfigKey(group, "group_[Master]_enable"), 0); EXPECT_FALSE(pChain->enabledForChannel(m_master)); }
void WEffectButtonParameter::setup(QDomNode node, const SkinContext& context) { bool rackOk = false; int rackNumber = context.selectInt(node, "EffectRack", &rackOk) - 1; bool chainOk = false; int chainNumber = context.selectInt(node, "EffectUnit", &chainOk) - 1; bool effectOk = false; int effectNumber = context.selectInt(node, "Effect", &effectOk) - 1; bool parameterOk = false; int parameterNumber = context.selectInt(node, "EffectButtonParameter", ¶meterOk) - 1; // Tolerate no <EffectRack>. Use the default one. if (!rackOk) { rackNumber = 0; } if (!chainOk) { qDebug() << "EffectButtonParameterName node had invalid EffectUnit number:" << chainNumber; } if (!effectOk) { qDebug() << "EffectButtonParameterName node had invalid Effect number:" << effectNumber; } if (!parameterOk) { qDebug() << "EffectButtonParameterName node had invalid ButtonParameter number:" << parameterNumber; } EffectRackPointer pRack = m_pEffectsManager->getEffectRack(rackNumber); if (pRack) { EffectChainSlotPointer pChainSlot = pRack->getEffectChainSlot(chainNumber); if (pChainSlot) { EffectSlotPointer pEffectSlot = pChainSlot->getEffectSlot(effectNumber); if (pEffectSlot) { EffectParameterSlotBasePointer pParameterSlot = pEffectSlot->getEffectButtonParameterSlot(parameterNumber); if (pParameterSlot) { setEffectParameterSlot(pParameterSlot); } else { qDebug() << "EffectButtonParameterName node had invalid ButtonParameter number:" << parameterNumber; } } else { qDebug() << "EffectButtonParameterName node had invalid Effect number:" << effectNumber; } } else { qDebug() << "EffectButtonParameterName node had invalid EffectUnit number:" << chainNumber; } } else { qDebug() << "EffectButtonParameterName node had invalid EffectRack number:" << rackNumber; } }
void WEffectChain::setEffectChainSlot(EffectChainSlotPointer pEffectChainSlot) { if (pEffectChainSlot) { m_pEffectChainSlot = pEffectChainSlot; connect(pEffectChainSlot.data(), SIGNAL(updated()), this, SLOT(chainUpdated())); chainUpdated(); } }
TEST_F(EffectSlotTest, ControlsReflectSlotState) { EffectChainPointer pChain(new EffectChain(m_pEffectsManager.data(), "org.mixxx.test.chain1")); int iRackNumber = 0; int iChainNumber = 0; int iEffectNumber = 0; StandardEffectRackPointer pRack = m_pEffectsManager->addStandardEffectRack(); EffectChainSlotPointer pChainSlot = pRack->addEffectChainSlot(); // StandardEffectRack::addEffectChainSlot automatically adds 4 effect // slots. In the future we will probably remove this so this will just start // segfaulting. EffectSlotPointer pEffectSlot = pChainSlot->getEffectSlot(0); QString group = StandardEffectRack::formatEffectSlotGroupString( iRackNumber, iChainNumber, iEffectNumber); EffectManifest manifest; manifest.setId("org.mixxx.test.effect"); manifest.setName("Test Effect"); manifest.addParameter(); registerTestEffect(manifest, false); // Check the controls reflect the state of their loaded effect. EffectPointer pEffect = m_pEffectsManager->instantiateEffect(manifest.id()); // Enabled defaults to true in both effects and the slot. pEffect->setEnabled(false); EXPECT_DOUBLE_EQ(1.0, ControlObject::get(ConfigKey(group, "enabled"))); EXPECT_DOUBLE_EQ(0, ControlObject::get(ConfigKey(group, "num_parameters"))); pEffectSlot->loadEffect(pEffect); EXPECT_LE(0, ControlObject::get(ConfigKey(group, "enabled"))); EXPECT_DOUBLE_EQ(1, ControlObject::get(ConfigKey(group, "num_parameters"))); EXPECT_TRUE(pEffect->enabled()); // loaded is read-only. ControlObject::set(ConfigKey(group, "loaded"), 0.0); EXPECT_LE(0, ControlObject::get(ConfigKey(group, "loaded"))); // num_parameters is read-only. ControlObject::set(ConfigKey(group, "num_parameters"), 2.0); EXPECT_DOUBLE_EQ(1, ControlObject::get(ConfigKey(group, "num_parameters"))); }
TEST_F(EffectChainSlotTest, ChainSlotMirrorsLoadedChain_Clear) { EffectChainPointer pChain(new EffectChain(m_pEffectsManager.data(), "org.mixxx.test.chain1")); int iRackNumber = 0; int iChainNumber = 0; StandardEffectRackPointer pRack = m_pEffectsManager->addStandardEffectRack(); EffectChainSlotPointer pSlot = pRack->addEffectChainSlot(); // Clear the default chain. pSlot->clear(); QString group = StandardEffectRack::formatEffectChainSlotGroupString( iRackNumber, iChainNumber); EXPECT_DOUBLE_EQ(0.0, ControlObject::get(ConfigKey(group, "loaded"))); pSlot->loadEffectChain(pChain); EXPECT_DOUBLE_EQ(1.0, ControlObject::get(ConfigKey(group, "loaded"))); ControlObject::set(ConfigKey(group, "clear"), 1.0); EXPECT_DOUBLE_EQ(0.0, ControlObject::get(ConfigKey(group, "loaded"))); }