Skip to content

Commit

Permalink
add documentation for effects classes in the main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Apr 4, 2020
1 parent adc6692 commit 1784fc0
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 29 deletions.
3 changes: 1 addition & 2 deletions src/effects/effectbuttonparameterslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
class ControlObject;
class ControlPushButton;

// EffectButtonParameterSlot is a wrapper around the parameterX ControlObject
// that loaded with an EffectParameter into itself by the EffectSlot.
// Refer to EffectParameterSlotBase for documentation
class EffectButtonParameterSlot : public EffectParameterSlotBase {
Q_OBJECT
public:
Expand Down
25 changes: 25 additions & 0 deletions src/effects/effectchainslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,31 @@ class EffectsManager;
class EffectProcessor;
class EngineEffectChain;

// EffectChainSlot is the main thread representation of an effect chain which
// adds/removes exactly one EngineEffectChain from the engine. Unlike EffectSlot,
// EffectChainSlot does not add/remove EngineEffectChains apart from Mixxx
// startup and shutdown. The lifetime of EngineEffectChain is coupled with
// EffectChainSlot. Do not change this relationship; there is no use case for
// that.

// EffectChainSlot owns the ControlObjects for the routing switches that assign
// chains to process audio inputs (decks, microphones, auxiliary inputs,
// master mix). EffectChainSlot also owns the ControlObject for the superknob
// which manipulates the metaknob of each effect in the chain.

// The state of an EffectChainSlot can be saved to and loaded from an
// EffectChainPreset, which can serialize/deserialize that state to/from XML.
// Loading state from an EffectChainPreset is done by
// EffectsManager::loadEffectChainPreset rather than directly by EffectChainSlot
// because loading effects requires access to the EffectsBackends and default
// EffectPresets which are maintained by EffectsManager.

// Currently EffectChainSlot has a fixed number of EffectSlots. In the future
// this may be extended to create an Effect class to decouple an EngineEffect's
// state from the ControlObjects so that EffectChainSlot could arbitrarily hide
// and rearrange Effects by loading/unloading them from EffectSlots. This would
// be similar to the relationship between EffectSlot and
// EffectParameterSlotBase/EffectParameter.
class EffectChainSlot : public QObject {
Q_OBJECT
public:
Expand Down
3 changes: 1 addition & 2 deletions src/effects/effectknobparameterslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class ControlEffectKnob;
class SoftTakeover;
class EffectSlot;

// EffectKnobParameterSlot is a wrapper around the parameterX ControlObject
// that loaded with an EffectParameter into itself by the EffectSlot.
// Refer to EffectParameterSlotBase for documentation
class EffectKnobParameterSlot : public EffectParameterSlotBase {
Q_OBJECT
public:
Expand Down
13 changes: 8 additions & 5 deletions src/effects/effectmanifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
#include "effects/effectmanifestparameter.h"
#include "effects/defs.h"

// An EffectManifest is a full description of the metadata associated with an
// effect (e.g. name, author, version, description, etc.) and the parameters of
// the effect that are intended to be exposed to the rest of Mixxx for user or
// script control.
//
// An EffectManifest is a description of the metadata associated with an effect
// (ID, display name, author, description) and all the parameters of the effect.
// The pair of the ID string and EffectBackendType uniquely identifies an
// effect. EffectManifests are used by EffectBackends to create EffectProcessors
// which implement the DSP logic of the effect. The name string of effect
// parameters in the manifest is used to link EngineEffectParameters
// with member variables of the EffectProcessorImpl used in the DSP logic.

// EffectManifest is composed purely of simple data types, and when an
// EffectManifest is const, it should be completely immutable. EffectManifest is
// meant to be used in most cases as a reference, and in Qt collections, so it
Expand Down
18 changes: 12 additions & 6 deletions src/effects/effectparameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ class EffectsManager;
class EngineEffect;
class EffectParameterPreset;

// An EffectParameter is a wrapper around EffectManifestParameter that tracks a
// mutable value state and communicates that state to the engine. This class is
// NOT thread-safe and must only be used from the main thread. Separating this
// from the parameterX ControlObjects in EffectParameterSlot allows for decoupling
// the state of the parameters from the ControlObject states, which is required for
// parameter hiding and rearrangement.
// An EffectParameter is a main thread representation of the state of an
// EngineEffectParameter. EffectParameter tracks a mutable value state and
// communicates that state to the engine. Separating this from the parameterX
// ControlObjects in EffectParameterSlotBase allows for decoupling the state of
// the parameters from the ControlObject states, which is required for
// EffectSlot to do parameter hiding and rearrangement. EffectParameter is
// responsible for manipulating the value of knob parameters when the metaknob
// of the EffectSlot is changed (button parameters cannot be linked to the
// metaknob). For EffectParameter, there is no difference between knobs and
// buttons; only EffectSlot and
// EffectKnobParameterSlot/EffectButtonParameterSlot are responsible for taking
// care of that difference.
class EffectParameter {
public:
EffectParameter(EngineEffect* pEngineEffect, EffectsManager* pEffectsManager, int iParameterNumber, EffectManifestParameterPointer pParameter, EffectParameterPreset preset);
Expand Down
9 changes: 6 additions & 3 deletions src/effects/effectparameterslotbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ class ControlPushButton;
class EffectParameter;
class EffectSlot;


// EffectParameterSlotBase is a wrapper around the parameterX ControlObject
// that loaded with an EffectParameter into itself by the EffectSlot.
// EffectParameterSlotBase is a wrapper around the parameterX ControlObject.
// EffectSlot loads/unloads an EffectParameter from the EffectParameterSlotBase.
// The EffectParameter is responsible for communicating changes in the parameter
// value to the EngineEffectParameter. The separation of EffectParameter and
// EffectParameterSlotBase allows EffectSlot to arbitrarily hide and rearrange
// parameters.
class EffectParameterSlotBase : public QObject {
Q_OBJECT
public:
Expand Down
15 changes: 14 additions & 1 deletion src/effects/effectsbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@

class EffectProcessor;

// EffectsBackend enumerates available effects and instantiates EffectProcessors
// EffectsBackend is an abstract base class that enumerates available effects
// which are identified by EffectManifests. EffectsBackend creates
// EffectProcessors when provided with an EffectManifest from EffectsManager
// indicating which specific EffectProcessor type to create.

// The EffectProcessors implement the DSP logic specific to each effect.
// EffectManager sends the EffectProcessors down to the EffectChainSlot, which
// sends it down to the EffectSlot. The EffectSlot uses the EffectProcessor to
// create an EngineEffect and add/remove the EngineEffect from the engine.

// Currently the implemented EffectsBackend subclasses are for the effects
// built into Mixxx and LV2 plugins. Other plugin types such as VSTs could be
// added in the future by creating new subclasses of EffectsBackend,
// EffectManifest, EffectState, and EffectProcessorImpl.
class EffectsBackend {
public:
virtual ~EffectsBackend() {};
Expand Down
21 changes: 21 additions & 0 deletions src/effects/effectslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ class EffectKnobParameterSlot;

typedef QMap<EffectManifestParameter::ParameterType, QList<EffectParameterPointer>> ParameterMap;

// EffectSlot is a main thread class which creates EngineEffects and sends
// updates to them in response to changes in ControlObjects. It owns the
// ControlObjects for enabling/disabling effects and the effect metaknob.

// EffectSlot owns a list of EffectParameterSlotBases and EffectParameters.
// The EffectParameters are the main thread representation of the state of an
// EngineEffectParameter. EffectSlot creates and destroys EffectParameters
// together with the EngineEffect as it loads/unloads EngineEffects. The
// EffectParameterSlotBases own the ControlObjects for manipulating the
// EffectParameters and showing them in skins. The EffectParameterSlotBases are
// permanent for the lifetime the EffectSlot; they are not created or destroyed
// when loading/unloading effects.

// The separation of EffectParameters from EffectParameterSlotBases decouples
// the parameters available from manipulation via ControlObjects from the
// parameters of EngineEffects. This allows EffectSlot to arbitrarily hide and
// rearrange EffectParameters by loading/unloading them from the
// EffectParameterSlotBases without changing the audio processing in the engine.

// The state of an EffectSlot is loaded from an EffectPreset and a snapshot
// of EffectSlot's state can be serialized into a EffectPreset.
class EffectSlot : public QObject {
Q_OBJECT
public:
Expand Down
23 changes: 20 additions & 3 deletions src/effects/effectsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ class EffectManifest;

typedef QMap<EffectManifestParameter::ParameterType, QList<EffectParameterPointer>> ParameterMap;

// EffectsManager is the interface between the parts of the effects system in
// the main thread and the rest of Mixxx. It creates/destroys a fixed
// set of EffectChainSlots on Mixxx startup/shutdown. EffectManager uses
// EffectBackends and EffectManifests to create EffectProcessors. The
// EffectProcessors are sent down to the EffectChainSlots, then down to the
// EffectSlots which use the EffectProcessors to create EngineEffects and add
// them to the audio engine.

// EffectsManager saves/loads EffectChainPresets and EffectPresets.
// EffectsManager maintains a list of custom EffectChainPresets in the
// "effects/chains" folder in the user settings folder. The state of loaded
// effects are saved as EffectChainPresets in the effects.xml file in the user
// settings folder, which is used to restore the state of effects on startup.
// Additionally, EffectsManager saves/loads EffectPresets in the
// "effects/defaults" folder in the user settings folder to allow users to
// specify default states when each effect is loaded.

// To maintain clear separation of responsibilities, GUI classes should NOT
// access the EffectChainSlots or EffectSlots directly. They should interface
// with them indirectly through EffectsManager.
class EffectsManager : public QObject {
Q_OBJECT
public:
Expand Down Expand Up @@ -53,9 +73,6 @@ class EffectsManager : public QObject {
// EffectChainSlotPointer getNextEffectChain(EffectChainSlotPointer pEffectChainSlot);
// EffectChainSlotPointer getPrevEffectChain(EffectChainSlotPointer pEffectChainSlot);

// NOTE(Kshitij) : New functions for saving and loading
// bool saveEffectChains();

static const int kNumStandardEffectChains = 4;

bool isAdoptMetaknobValueEnabled() const;
Expand Down
1 change: 1 addition & 0 deletions src/effects/lv2/lv2backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "preferences/usersettings.h"
#include <lilv-0/lilv/lilv.h>

// Refer to EffectsBackend for documentation
class LV2Backend : public EffectsBackend {
public:
LV2Backend();
Expand Down
1 change: 1 addition & 0 deletions src/effects/lv2/lv2effectprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "effects/defs.h"
#include "engine/engine.h"

// Refer to EffectProcessor for documentation
class LV2EffectGroupState final: public EffectState {
public:
LV2EffectGroupState(const mixxx::EngineParameters& bufferParameters)
Expand Down
1 change: 1 addition & 0 deletions src/effects/lv2/lv2manifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "effects/defs.h"
#include <lilv-0/lilv/lilv.h>

// Refer to EffectManifest for documentation
class LV2Manifest : public EffectManifest {
public:
enum Status {
Expand Down
7 changes: 4 additions & 3 deletions src/effects/presets/effectchainpreset.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class EffectChainSlot;

// EffectChainPreset is a read-only snapshot of the state of an effect chain
// that can be serialized to/deserialized from XML. It is used to easily
// save/load user-defined chain presets as well as save the state of loaded
// effects when Mixxx shuts down and restarts.
// that can be serialized to/deserialized from XML. It is used by EffectsManager
// to easily save/load user-defined chain presets as well as save the state of
// loaded effects when Mixxx shuts down and restarts.
class EffectChainPreset {
public:
EffectChainPreset();
Expand All @@ -23,6 +23,7 @@ class EffectChainPreset {
return m_name.isEmpty();
}

// This is the only exception to EffectChainPreset being read-only.
void setName(const QString& newName) {
m_name = newName;
}
Expand Down
5 changes: 3 additions & 2 deletions src/effects/presets/effectparameterpreset.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include "effects/defs.h"
#include "effects/effectmanifestparameter.h"

// EffectParameterPreset is a read-only snapshot of the state of an effect parameter
// that can be serialized to/deserialized from XML.
// EffectParameterPreset is a read-only snapshot of the state of an effect
// parameter that can be serialized to/deserialized from XML. It is only used
// as a component of an EffectPreset; never on its own.
class EffectParameterPreset {
public:
EffectParameterPreset();
Expand Down
5 changes: 3 additions & 2 deletions src/effects/presets/effectpreset.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include "effects/presets/effectparameterpreset.h"

// EffectPreset is a read-only snapshot of the state of an effect that can be
// serialized to/deserialized from XML. It is used to save/load chain presets
// as well as save custom defaults for each effect.
// serialized to/deserialized from XML. It is used by EffectChainPreset to
// save/load chain presets. It is also used by EffectsManager to save custom
// defaults for each effect.
class EffectPreset {
public:
EffectPreset();
Expand Down

0 comments on commit 1784fc0

Please sign in to comment.