-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an effects framework. #180
Merged
Merged
Changes from all commits
Commits
Show all changes
337 commits
Select commit
Hold shift + click to select a range
3ca1986
Convert the group names for EffectSlotParameter's to EffectChainI_Eff…
rryan 33bc350
Merging from lp:mixxx
rryan f91a601
Refactor EffectChain to split it into EffectChain and EffectChainSlot…
rryan 066bec4
Move all effects code from a SCons Feature to the MixxxCore Dependenc…
rryan 66811ae
Backpedal a little bit on my earlier design. EffectChain's should not…
rryan e9e0759
Rewrote the way that EffectsBackends provide and represent effects. T…
rryan 220c59e
Merging from lp:mixxx
rryan c7aef22
Change name of prev/next preset controls to prev_chain next_chain.
rryan af9bde1
Adding EffectChainManager for loading/saving EffectChains from DB and…
rryan 4ea3252
Add EffectChainManager methods to give out the next/prev effectchain.…
rryan 1582929
OS X compile fix in LADSPALoader
asantoni 41a2cbb
Update EffectsManager to have more built in support for enumerating e…
rryan 9ee5c23
Fix parameter syncing between EffectChainSlot/EffectChain and EffectS…
rryan a54b92f
Adding custom WidgetGroup layout hacks. I'll have to clean these up w…
rryan 52b60c0
Adding 2 EffectChains to Deere1280x1024. Again, I'll have to back out…
rryan 2da1ada
Fix prev_chain behavior. Also, update 2nd effect chain name widget.
rryan b5f91c8
Switch a bunch of 0.0-1.0 knob controls to be ControlPotmeter's. Remo…
rryan bd6e5f9
Rename EffectSlotParameter to EffectParameterSlot to match the parall…
rryan ec88242
Merging from lp:mixxx
rryan 0035034
Remove merge conflict skin.
rryan d14d3a6
Merging from lp:mixxx
rryan 42afd43
Add effects demo skin based on Deere 1280x1024
rryan 44f769f
Update flanger parameter knobs to control the current effect chain pa…
rryan 03e2b3c
Minor fixes.
rryan 5a4fb03
Remove Deere1280x1024-SXGA.moved.
rryan 4bff8b1
Merge branch 'master' into features_effects
rryan c59f6e2
Remove src/util.h.moved.
rryan 284de45
Remove all effectsunit code from Bruno's GSoC project.
rryan 325ee4f
Fix the build.
rryan 665a83e
Change EffectManifest and EffectManifestParameter to be plain-old-data.
rryan b83d785
No need to clamp values coming from a ControlPotmeter.
rryan 5a9fa53
Fix debug text.
rryan 0cdf471
Change EffectManifest / EffectManifestParameter to use const referenc…
rryan 42e9103
Add EngineEffect and EngineEffectParameter.
rryan 1a49690
Add EffectProcessor, an interface for bundling the core logic of an e…
rryan 4991ff7
Use a ControlValueAtomic<QVariant> for EngineEffectParameter.
rryan bd9aeb9
Add parameter lookup methods to EngineEffect.
rryan 4c52659
Change the effects system drastically.
rryan 5f6b7e8
Const references.
rryan 67e4931
Remove QMutex from EffectParameter since it no longer has to deal wit…
rryan 089bfd0
Get rid of mutexes in Effect now that the engine is not calling its m…
rryan d172db9
More const references.
rryan f62fd9e
More const references. Delete EffectChainSlot::process.
rryan 52d6c28
Merge branch 'master' into features_effects
rryan 414a7e8
Delete res/effectsunits.
rryan f96b986
Merge branch 'master' into features_effects
rryan ff62388
Merge branch 'master' into features_effects
rryan c000def
Merge branch 'master' into features_effects
rryan b32d5cc
Merge branch 'master' into features_effects
rryan 138eb9c
Merge branch 'master' into features_effects
rryan fc96a26
Merge branch 'master' into features_effects
rryan a5a6f14
Comment run. Remove locking from places that won't need it anymore.
rryan b5f65ac
Change terminology of TwoWayMessagePipe to use 'receiver' instead of …
rryan 5c8e3c7
Refactor TwoWayMessagePipe to separate the sender and receiver so the…
rryan b5fa9fe
Get rid of EngineMaster::getEffectsManager().
rryan bae67e3
Add BaseReferenceHolder/ReferenceHolder for holding a reference witho…
rryan 4634b8b
Add EngineEffectsManager, an engine-side representation of the effect…
rryan 9771729
Shorten message class names.
rryan 5fd62fc
Add simple EngineEffectChain implementation.
rryan b1f0cd0
Re-structure messages to use unions (again). Non-POD can be stored ou…
rryan 62476b8
Handle add/remove effect chain messages in EngineEffectsManager.
rryan efa3a0a
Add a set-parameters request for EngineEffectChain and handle it.
rryan 0b69122
Add EffectRequest processing/dispatch loop.
rryan dde9200
Add tracking of active EngineEffects to EngineEffectsManager.
rryan fdb35e9
Add CLEAR_STRUCT macro for clearing the structs.
rryan 5616676
Remove CHAIN_SLOT message types.
rryan d4c9d28
Add SET_EFFECT_PARAMETER message for setting an effect parameter's va…
rryan 31fe9aa
Use a pointer for the EffectsRequest in the TwoWayMessagePipe because…
rryan d4ae9ed
Add EffectsResponse handling to EffectsManager.
rryan a729e45
Make id required for creating an EffectChain. Add an EngineEffectChai…
rryan e8a9581
Send an ADD_EFFECT_CHAIN message when one is added.
rryan 46a486e
Write EffectChain updates to the EngineEffectsManager.
rryan 9108932
Remove unused MessageType from EffectsResponse.
rryan 89af205
Add enabled/enabledForGroup tracking to EffectChain.
rryan 90ffcee
Handle ENABLE_EFFECT_CHAIN_FOR_GROUP/DISABLE_EFFECT_CHAIN_FOR_GROUP m…
rryan a92363d
Add mix accessor/setter in EffectChain.
rryan 9f30751
Get rid of some old assumptions in EffectChainSlot.
rryan 37f1386
Create new EffectParameterSlots as needed.
rryan bffd265
Escape mutex hell. Remove mutexes from the Effect*Slot.
rryan 7a663df
Send updates when EffectChain parameters change.
rryan 9e65659
Listen for updates to EffectChain properties in EffectChainSlot. valu…
rryan 2afe8e6
Don't leak channel enable controls on shutdown.
rryan d372650
Unify terminology to use group instead of channelId.
rryan d208bef
Add very simple process implementation. So much better without the lo…
rryan e2900db
Fix more uses of channelId instead of group.
rryan 29c199e
Merge branch 'master' into features_effects
rryan 30307a8
Merge branch 'master' into features_effects
rryan 40f0503
Fix EngineMasterTest.
rryan 9f321c1
Oops, forgot engineeffect.cpp.
rryan c46b09c
Remove mutex in EffectsManager.
rryan 0e99496
Get rid of some of the boilerplate involved when registering an effec…
rryan ad802a0
Send SET_EFFECT_PARAMETER messages whenever an effect's parameter cha…
rryan 10be1ab
Refactor message handling to prevent having to iterate all EngineEffe…
rryan caf18c3
Fix segfault on chain switch.
rryan 835495d
Some FlangerEffectProcessor fixes.
rryan 828c2f6
EngineEffectChain enabled accessor.
rryan e0a5b67
Warn on failed EffectsRequest.
rryan 1f40e8f
Fix default chain setup order.
rryan 370ba81
Add EffectsRequest processing debug statements.
rryan 650a9c0
Initialize the EngineEffect's EffectProcessor.
rryan 0931fec
Don't process a chain if it is not enabled.
rryan e8064c0
Add InsertionType property to EffectChain for insert vs. send effects…
rryan ae20265
Handle insert and send mode in EngineEffectChain::process().
rryan 225c418
Use ramping gain when processing EffectChains.
rryan 25fa5ac
Load sane default values for EngineEffectParameter from the manifest.
rryan 2f0afa4
Fix goofy initialization order requirements for EffectChains by makin…
rryan 48ee114
Change SEND mode processing to not double the signal when fully dry.
rryan 693cb05
Add virtual destructor to EffectInstantiator.
rryan c1c0162
Add DISALLOW_COPY_AND_ASSIGN to EngineEffectChain.
rryan aa64f58
Add clear control to EffectChainSlot to clear the chain slot.
rryan 470ed71
Prefix all slot groups with EffectRack1 to make room for future effec…
rryan 359b21e
Add EffectRack to wrap EffectChainSlots and contain logic related to …
rryan 9e5df4a
Doh. Re-add the EffectsManager creation.
rryan be4e9f3
Rename EffectRack clear control to be less redundant.
rryan 0dddd01
Fix spelling.
rryan 674562d
Rename FlangerEffectProcessor to FlangerProcessor.
rryan 8c8dbfb
Make enabled just reflect whether the chain is loaded.
rryan d88c8cb
Add BitCrusher effect and effect chain.
rryan 1ef6c89
Simplify effect registration.
rryan b5a738a
Improve my dumb first-pass at a bit crusher.
rryan 5c9366b
Rename BitCrusherProcessor and FlangerProcessor to BitCrusherEffect a…
rryan 2a7735d
Merge branch 'master' into features_effects
rryan af4acd7
Merge branch 'master' into features_effects
rryan 60e4102
Merge branch 'master' into features_effects
rryan f718de9
Don't load the same chain to a chain slot twice.
rryan 8a2204e
Add FilterEffect, based on EngineFilterEffect. Filter sweeps!
rryan a0b983a
Remove EngineFilterEffect tooltips.
rryan 2c0cef8
Delete EngineFlanger and its tooltips.
rryan 030526f
Add temporary effects hacks to Deere1280x800-WXGA. Delete Deere1280x1…
rryan c9f937c
Get rid of some of the boilerplate required in making an effect proce…
rryan c185a7c
Fix segfault caused by instantiating effect processors before the Eng…
rryan 977db8f
Merge branch 'master' into features_effects
rryan 616197c
Merge branch 'master' into features_effects
rryan 972558b
Fix tests to use EffectsManager.
rryan 1c18b2a
Merge branch 'master' into features_effects
rryan 1043726
Oops.
rryan 4f40522
Add quick and dirty EffectChain / Effect / EffectParameter XML serial…
rryan 3ae65df
Add WEffect and WEffectParameter widgets.
rryan 03a6228
Add option for a validation check to XmlParse::selectNodeInt/Float.
rryan 8508744
Create WEffect and WEffectParameter widgets for <EffectName> and <Eff…
rryan ca97573
Merge branch 'master' into features_effects
rryan 9d044fd
Add updated() signal to EffectSlot.
rryan e627997
Add usage of EffectName / EffectParameterName as example.
rryan a8eada9
Support updating other parts of Mixxx when effects are registered.
rryan edb2e43
Merge branch 'master' into features_effects
rryan 3a1579a
First pass at porting SWH plate reverb to Mixxx effect system.
ywwg 3d40c46
Fix inline issue and typo
ywwg a142872
Use GroupState properly. Other notes.
ywwg 8ec6a42
Merge pull request #3 from ywwg/features_effects-reverb
rryan 5190b6a
Merge branch 'master' into features_effects
rryan b9fd7b2
Update BitCrusher to account for [-1, 1] sample range.
rryan eb21626
Make EffectChain emit its update signals when it is changed.
rryan cd612fd
Protect against invalid indexes in EffectRack.
rryan e638fc1
Emit updated signals on clear and other misc fixes.
rryan 37a6930
Properly parse effect widgets with SkinContext.
rryan 21e860a
Fix FlangerEffect to keep state for left and right channel.
rryan 74d32f7
Add support for "OK" pointer to SkinContext::selectInt.
rryan f6203a4
Merge branch 'master' into features_effects
rryan b237857
Register effect chains with the EffectChainManager when loading them …
rryan 9246ea7
Fix mysterious FlangerEffect segfault.
rryan 0d8ff35
Move effect widget setup out of LegacySkinParser and into the setup()…
rryan e420261
Merge branch 'master' into features_effects
rryan 9723fb0
Write an echo effect from scratch.
ywwg 0f1d383
Fix order of math.
ywwg a622d12
Address notes, and write pingponging
ywwg c8912a4
Merge pull request #4 from ywwg/features_effects-echo-squash
rryan 1493f8a
Merge branch 'features_effects' of github.com:rryan/mixxx into featur…
rryan 3f87fc3
Merge branch 'master' into features_effects
rryan 434cf44
Reduce effect name widget duplication with setupLabelWidget.
rryan 69831e4
Set parameter slot control default values so that reset works properly.
rryan 91ad331
remove unnecessary assignments.
ywwg e82b793
Merge pull request #5 from ywwg/rryan-features_effects
rryan 5fdfff7
Add description to EffectChain.
rryan a130464
Show description in tooltip for WEffectChain, WEffect, and WEffectPar…
rryan 8e90a61
Add GroupEffectProcessor, a helper class for defining effects with au…
rryan ed9b27d
Convert all native effects to use GroupEffectProcessor.
rryan 280ba59
Apply master volume after effects are processed.
rryan 76b294d
Begin port of CAPS Reverb plugin -- doesn't quite build.
ywwg b073af8
Fixed missing semicolon, reverb plugin builds
ywwg 3cb90ab
Reimplement reverb effect with newly-ported CAPS Reverb effect.
ywwg caf6314
Revert accidental edits
ywwg a0ac79f
clean up basics.h
ywwg ae889e0
In the echo effect, pingpong should be off by default.
ywwg b18f46b
Use a crossfade buffer to reduce static on parameter changes more.
ywwg d34c033
Remove unnecessary file.
ywwg ee9a29f
Merge pull request #7 from ywwg/rryan-features_effects
rryan 5613c98
Merge pull request #6 from ywwg/rryan-features_effects-reverbV2
rryan 2c2d5c0
Merge branch 'master' into features_effects
rryan 485a87e
Merge branch 'master' into features_effects
rryan 14e2d96
Make group enable buttons toggle buttons.
rryan b080193
Merge branch 'features_effects' of github.com:rryan/mixxx into featur…
rryan fb6015c
Revert changes to res/skins/Deere1280x800-WXGA/skin.xml.
rryan 909ad44
Merge branch 'master' into features_effects
rryan b7cb250
Fix accidentally applying master volume twice (missed this during mer…
rryan 1450795
Revert unneeded changes.
rryan 486d3ec
Set clear control type.
rryan a6cfbcd
Improve control definitions in EffectChainSlot.
rryan 28b8724
Add some accessors.
rryan 210744b
Allow controlling of EffectChain insertion type via chain slot contro…
rryan 5d4e4fb
Basic EffectChainSlot tests that exercise the control interface.
rryan 436efbd
Add accessor.
rryan e4d1fb6
Misc. renames and notes.
rryan 156aa7a
Use more specific control types and make read-only controls use value…
rryan ee1ef78
Add a simple test for EffectsManager that we can instantiate an effec…
rryan 2908b97
Make enabled and num_parameters read-only.
rryan ed4a8e1
Add BaseEffectTest.
rryan fc1b8dd
Add EffectSlotTest.
rryan 3961255
Merge branch 'master' into features_effects
rryan 44256d9
Merge branch 'master' into features_effects
rryan c8981c5
Merge branch 'master' into features_effects
rryan 3fd5217
Rename channel_%1 to group_%1_enable.
rryan 6f35964
Merge branch 'master' into features_effects
rryan 6422aa5
Introduce the concept of EffectChain prototypes.
rryan ea443d3
Add in-order processing of effect chains in their racks.
rryan 0131e6e
Try to prevent memory allocation by reserving space in engine effect …
rryan ddcb4f8
Make Effect responsible for adding itself to a chain in the engine.
rryan 43463e1
Pre-allocate group state before adding effects to the engine.
rryan 008054d
Add LinkType definition to EffectManifestParameter for describing lin…
rryan 0433bd0
Add LinkType to EffectParameter.
rryan da6ff6f
Send a signal when an EffectParameter's value changes.
rryan 4b3b6a3
Broadcast chain parameter changes to its effects.
rryan e97edf2
Handle parameter value changes and link type changes in EffectParamet…
rryan 79b8656
Add some parameter linking to the native effects for testing.
rryan a27dc8c
Make mix, parameter, and group enable settings properties of the chai…
rryan 5cd5027
Make group enable buttons behave in power-window mode.
rryan 38e6875
Merge branch 'master' into features_effects
rryan 60ab19f
Add [EffectRack%1],num_effectchain_slots control.
rryan f5fe608
Change effect CO API to refer to EffectChainSlots as EffectUnits.
rryan 44e8068
Rename <EffectChain> option to WEffect, WEffectChain, and WEffectPara…
rryan 7c18675
Merge branch 'master' into features_effects
rryan 881c747
Allow chains to have null effects.
rryan 53f03e5
Add EffectChain::replaceEffect for swapping one effect for another.
rryan 885e13c
Add support for iterating the global ordering of effect IDs in Effect…
rryan 79bcc22
Add next/previous effect buttons to EffectSlot and wire them up to a …
rryan 693c92d
Load an empty chain to EffectChainSlot so that users can load effects…
rryan 825f5a5
Add EffectSlot effect selector knob for infinite +1/-1 knobs.
rryan cbe0bb7
Add effect chain selector control for +1/-1 infinite spinner knobs.
rryan 3553767
Add a clear control to EffectSlot.
rryan d21bf51
Rename 'enabled' control of the EffectChainSlot, EffectSlot, and Effe…
rryan 4bd5c25
Fix EngineEffectRack to support NULL chains.
rryan 48a3669
Fix build, oops.
rryan e4a2c48
Guard all engine effect debug output with a flag.
rryan e92f048
Wrap more debug statements in conditional checks.
rryan 105c53f
Remove chains and effects by index instead of pointer.
rryan 5e6f8f2
Don't communicate EffectChain parameter to the engine since it's not …
rryan 365cef9
Add 'enabled' state to Effects and an 'enabled' control to EffectSlot…
rryan 03098ea
Make EffectChainSlot responsible for adding/removing its chains from …
rryan 0717ce5
Add num_effectslots and num_parameterslots controls.
rryan c751aec
Delete leaking controls.
rryan 2b68514
Restore chain-level enable control.
rryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
#include <QtDebug> | ||
|
||
#include "effects/effect.h" | ||
#include "effects/effectprocessor.h" | ||
#include "effects/effectsmanager.h" | ||
#include "engine/effects/engineeffectchain.h" | ||
#include "engine/effects/engineeffect.h" | ||
#include "xmlparse.h" | ||
|
||
Effect::Effect(QObject* pParent, EffectsManager* pEffectsManager, | ||
const EffectManifest& manifest, | ||
EffectInstantiatorPointer pInstantiator) | ||
: QObject(pParent), | ||
m_pEffectsManager(pEffectsManager), | ||
m_manifest(manifest), | ||
m_pEngineEffect(new EngineEffect(manifest, | ||
pEffectsManager->registeredGroups(), | ||
pInstantiator)), | ||
m_bAddedToEngine(false), | ||
m_bEnabled(true) { | ||
foreach (const EffectManifestParameter& parameter, m_manifest.parameters()) { | ||
EffectParameter* pParameter = new EffectParameter( | ||
this, pEffectsManager, m_parameters.size(), parameter); | ||
m_parameters.append(pParameter); | ||
if (m_parametersById.contains(parameter.id())) { | ||
qDebug() << debugString() << "WARNING: Loaded EffectManifest that had parameters with duplicate IDs. Dropping one of them."; | ||
} | ||
m_parametersById[parameter.id()] = pParameter; | ||
} | ||
} | ||
|
||
Effect::~Effect() { | ||
qDebug() << debugString() << "destroyed"; | ||
m_parametersById.clear(); | ||
for (int i = 0; i < m_parameters.size(); ++i) { | ||
EffectParameter* pParameter = m_parameters.at(i); | ||
m_parameters[i] = NULL; | ||
delete pParameter; | ||
} | ||
} | ||
|
||
void Effect::addToEngine(EngineEffectChain* pChain, int iIndex) { | ||
EffectsRequest* request = new EffectsRequest(); | ||
request->type = EffectsRequest::ADD_EFFECT_TO_CHAIN; | ||
request->pTargetChain = pChain; | ||
request->AddEffectToChain.pEffect = m_pEngineEffect; | ||
request->AddEffectToChain.iIndex = iIndex; | ||
m_pEffectsManager->writeRequest(request); | ||
m_bAddedToEngine = true; | ||
foreach (EffectParameter* pParameter, m_parameters) { | ||
pParameter->addToEngine(); | ||
} | ||
} | ||
|
||
void Effect::removeFromEngine(EngineEffectChain* pChain, int iIndex) { | ||
EffectsRequest* request = new EffectsRequest(); | ||
request->type = EffectsRequest::REMOVE_EFFECT_FROM_CHAIN; | ||
request->pTargetChain = pChain; | ||
request->RemoveEffectFromChain.pEffect = m_pEngineEffect; | ||
request->RemoveEffectFromChain.iIndex = iIndex; | ||
m_pEffectsManager->writeRequest(request); | ||
m_bAddedToEngine = false; | ||
foreach (EffectParameter* pParameter, m_parameters) { | ||
pParameter->removeFromEngine(); | ||
} | ||
} | ||
|
||
void Effect::updateEngineState() { | ||
if (!m_bAddedToEngine) { | ||
return; | ||
} | ||
sendParameterUpdate(); | ||
foreach (EffectParameter* pParameter, m_parameters) { | ||
pParameter->updateEngineState(); | ||
} | ||
} | ||
|
||
EngineEffect* Effect::getEngineEffect() { | ||
return m_pEngineEffect; | ||
} | ||
|
||
const EffectManifest& Effect::getManifest() const { | ||
return m_manifest; | ||
} | ||
|
||
void Effect::setEnabled(bool enabled) { | ||
if (enabled != m_bEnabled) { | ||
m_bEnabled = enabled; | ||
updateEngineState(); | ||
emit(enabledChanged(m_bEnabled)); | ||
} | ||
} | ||
|
||
bool Effect::enabled() const { | ||
return m_bEnabled; | ||
} | ||
|
||
void Effect::sendParameterUpdate() { | ||
if (!m_bAddedToEngine) { | ||
return; | ||
} | ||
EffectsRequest* pRequest = new EffectsRequest(); | ||
pRequest->type = EffectsRequest::SET_EFFECT_PARAMETERS; | ||
pRequest->pTargetEffect = m_pEngineEffect; | ||
pRequest->SetEffectParameters.enabled = m_bEnabled; | ||
m_pEffectsManager->writeRequest(pRequest); | ||
} | ||
|
||
unsigned int Effect::numParameters() const { | ||
return m_parameters.size(); | ||
} | ||
|
||
void Effect::onChainParameterChanged(double chainParameter) { | ||
foreach (EffectParameter* pParameter, m_parameters) { | ||
pParameter->onChainParameterChanged(chainParameter); | ||
} | ||
} | ||
|
||
EffectParameter* Effect::getParameterById(const QString& id) const { | ||
EffectParameter* pParameter = m_parametersById.value(id, NULL); | ||
if (pParameter == NULL) { | ||
qDebug() << debugString() << "getParameterById" | ||
<< "WARNING: parameter for id does not exist:" << id; | ||
} | ||
return pParameter; | ||
} | ||
|
||
EffectParameter* Effect::getParameter(unsigned int parameterNumber) { | ||
EffectParameter* pParameter = m_parameters.value(parameterNumber, NULL); | ||
if (pParameter == NULL) { | ||
qDebug() << debugString() << "WARNING: Invalid parameter index."; | ||
} | ||
return pParameter; | ||
} | ||
|
||
QDomElement Effect::toXML(QDomDocument* doc) const { | ||
QDomElement element = doc->createElement("Effect"); | ||
XmlParse::addElement(*doc, element, "Id", m_manifest.id()); | ||
XmlParse::addElement(*doc, element, "Version", m_manifest.version()); | ||
|
||
QDomElement parameters = doc->createElement("Parameters"); | ||
foreach (EffectParameter* pParameter, m_parameters) { | ||
const EffectManifestParameter& parameterManifest = | ||
pParameter->manifest(); | ||
QDomElement parameter = doc->createElement("Parameter"); | ||
XmlParse::addElement(*doc, parameter, "Id", parameterManifest.id()); | ||
// TODO(rryan): Do smarter QVariant formatting? | ||
XmlParse::addElement(*doc, parameter, "Value", | ||
pParameter->getValue().toString()); | ||
// TODO(rryan): Output link state, etc. | ||
parameters.appendChild(parameter); | ||
} | ||
element.appendChild(parameters); | ||
|
||
return element; | ||
} | ||
|
||
// static | ||
EffectPointer Effect::fromXML(EffectsManager* pEffectsManager, | ||
const QDomElement& element) { | ||
QString effectId = XmlParse::selectNodeQString(element, "Id"); | ||
EffectPointer pEffect = pEffectsManager->instantiateEffect(effectId); | ||
// TODO(rryan): Load parameter values / etc. from element. | ||
return pEffect; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#ifndef EFFECT_H | ||
#define EFFECT_H | ||
|
||
#include <QSharedPointer> | ||
#include <QDomDocument> | ||
|
||
#include "defs.h" | ||
#include "util.h" | ||
#include "effects/effectmanifest.h" | ||
#include "effects/effectparameter.h" | ||
#include "effects/effectinstantiator.h" | ||
|
||
class EffectProcessor; | ||
class EngineEffectChain; | ||
class EngineEffect; | ||
class EffectsManager; | ||
|
||
class Effect; | ||
typedef QSharedPointer<Effect> EffectPointer; | ||
|
||
// The Effect class is the main-thread representation of an instantiation of an | ||
// effect. This class is NOT thread safe and must only be used by the main | ||
// thread. The getEngineEffect() method can be used to get a pointer to the | ||
// Engine-thread representation of the effect. | ||
class Effect : public QObject { | ||
Q_OBJECT | ||
public: | ||
Effect(QObject* pParent, EffectsManager* pEffectsManager, | ||
const EffectManifest& manifest, | ||
EffectInstantiatorPointer pInstantiator); | ||
virtual ~Effect(); | ||
|
||
const EffectManifest& getManifest() const; | ||
|
||
unsigned int numParameters() const; | ||
EffectParameter* getParameter(unsigned int parameterNumber); | ||
EffectParameter* getParameterById(const QString& id) const; | ||
|
||
void setEnabled(bool enabled); | ||
bool enabled() const; | ||
|
||
EngineEffect* getEngineEffect(); | ||
|
||
void onChainParameterChanged(double chainParameter); | ||
|
||
void addToEngine(EngineEffectChain* pChain, int iIndex); | ||
void removeFromEngine(EngineEffectChain* pChain, int iIndex); | ||
void updateEngineState(); | ||
|
||
QDomElement toXML(QDomDocument* doc) const; | ||
static EffectPointer fromXML(EffectsManager* pEffectsManager, | ||
const QDomElement& element); | ||
|
||
signals: | ||
void enabledChanged(bool enabled); | ||
|
||
private: | ||
QString debugString() const { | ||
return QString("Effect(%1)").arg(m_manifest.name()); | ||
} | ||
|
||
void sendParameterUpdate(); | ||
|
||
EffectsManager* m_pEffectsManager; | ||
EffectManifest m_manifest; | ||
EngineEffect* m_pEngineEffect; | ||
bool m_bAddedToEngine; | ||
bool m_bEnabled; | ||
QList<EffectParameter*> m_parameters; | ||
QMap<QString, EffectParameter*> m_parametersById; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(Effect); | ||
}; | ||
|
||
#endif /* EFFECT_H */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused