1 #pragma once 2 3 #include <QObject> 4 #include <QHash> 5 #include <QList> 6 #include <QSet> 7 #include <QScopedPointer> 8 #include <QPair> 9 10 #include "preferences/usersettings.h" 11 #include "control/controlpotmeter.h" 12 #include "control/controlpushbutton.h" 13 #include "engine/channelhandle.h" 14 #include "engine/effects/message.h" 15 #include "util/class.h" 16 #include "util/fifo.h" 17 18 class EngineEffectsManager; 19 class EffectChainManager; 20 class EffectManifest; 21 class EffectsBackend; 22 23 class EffectsManager : public QObject { 24 Q_OBJECT 25 public: 26 static const QString kNoEffectString; 27 28 typedef bool (*EffectManifestFilterFnc)(EffectManifest* pManifest); 29 30 EffectsManager(QObject* pParent, 31 UserSettingsPointer pConfig, 32 ChannelHandleFactoryPointer pChannelHandleFactory); 33 virtual ~EffectsManager(); 34 getEngineEffectsManager()35 EngineEffectsManager* getEngineEffectsManager() { 36 return m_pEngineEffectsManager; 37 } 38 getEffectChainManager()39 EffectChainManager* getEffectChainManager() { 40 return m_pEffectChainManager; 41 } 42 getMasterHandle()43 const ChannelHandle getMasterHandle() { 44 return m_pChannelHandleFactory->getOrCreateHandle("[Master]"); 45 } 46 47 // Add an effect backend to be managed by EffectsManager. EffectsManager 48 // takes ownership of the backend, and will delete it when EffectsManager is 49 // being deleted. Not thread safe -- use only from the GUI thread. 50 void addEffectsBackend(EffectsBackend* pEffectsBackend); 51 void registerInputChannel(const ChannelHandleAndGroup& handle_group); 52 void registerOutputChannel(const ChannelHandleAndGroup& handle_group); 53 const QSet<ChannelHandleAndGroup>& registeredInputChannels() const; 54 const QSet<ChannelHandleAndGroup>& registeredOutputChannels() const; 55 56 StandardEffectRackPointer addStandardEffectRack(); 57 StandardEffectRackPointer getStandardEffectRack(int rack); 58 59 EqualizerRackPointer addEqualizerRack(); 60 EqualizerRackPointer getEqualizerRack(int rack); 61 62 QuickEffectRackPointer addQuickEffectRack(); 63 QuickEffectRackPointer getQuickEffectRack(int rack); 64 65 OutputEffectRackPointer addOutputsEffectRack(); 66 OutputEffectRackPointer getOutputsEffectRack(); 67 68 void loadEffectChains(); 69 70 EffectRackPointer getEffectRack(const QString& group); 71 EffectSlotPointer getEffectSlot(const QString& group); 72 73 EffectParameterSlotPointer getEffectParameterSlot( 74 const ConfigKey& configKey); 75 EffectButtonParameterSlotPointer getEffectButtonParameterSlot( 76 const ConfigKey& configKey); 77 78 QString getNextEffectId(const QString& effectId); 79 QString getPrevEffectId(const QString& effectId); 80 getAvailableEffectManifests()81 inline const QList<EffectManifestPointer>& getAvailableEffectManifests() const { 82 return m_availableEffectManifests; 83 }; getVisibleEffectManifests()84 inline const QList<EffectManifestPointer>& getVisibleEffectManifests() const { 85 return m_visibleEffectManifests; 86 }; 87 const QList<EffectManifestPointer> getAvailableEffectManifestsFiltered( 88 EffectManifestFilterFnc filter) const; 89 bool isEQ(const QString& effectId) const; 90 void getEffectManifestAndBackend( 91 const QString& effectId, 92 EffectManifestPointer* ppManifest, EffectsBackend** ppBackend) const; 93 EffectManifestPointer getEffectManifest(const QString& effectId) const; 94 EffectPointer instantiateEffect(const QString& effectId); 95 96 void setEffectVisibility(EffectManifestPointer pManifest, bool visibility); 97 bool getEffectVisibility(EffectManifestPointer pManifest); 98 99 // Temporary, but for setting up all the default EffectChains and EffectRacks 100 void setup(); 101 102 // Reloads all effect to the slots to update parameter assignments 103 void refeshAllRacks(); 104 105 // Write an EffectsRequest to the EngineEffectsManager. EffectsManager takes 106 // ownership of request and deletes it once a response is received. 107 bool writeRequest(EffectsRequest* request); 108 109 signals: 110 // TODO() Not connected. Can be used when we implement effect PlugIn loading at runtime 111 void availableEffectsUpdated(EffectManifestPointer); 112 void visibleEffectsUpdated(); 113 114 private slots: 115 void slotBackendRegisteredEffect(EffectManifestPointer pManifest); 116 117 private: debugString()118 QString debugString() const { 119 return "EffectsManager"; 120 } 121 122 void processEffectsResponses(); 123 void collectGarbage(const EffectsRequest* pResponse); 124 125 ChannelHandleFactoryPointer m_pChannelHandleFactory; 126 127 EffectChainManager* m_pEffectChainManager; 128 QList<EffectsBackend*> m_effectsBackends; 129 QList<EffectManifestPointer> m_availableEffectManifests; 130 QList<EffectManifestPointer> m_visibleEffectManifests; 131 132 EngineEffectsManager* m_pEngineEffectsManager; 133 134 QScopedPointer<EffectsRequestPipe> m_pRequestPipe; 135 qint64 m_nextRequestId; 136 QHash<qint64, EffectsRequest*> m_activeRequests; 137 138 ControlObject* m_pNumEffectsAvailable; 139 // We need to create Control Objects for Equalizers' frequencies 140 ControlPotmeter* m_pLoEqFreq; 141 ControlPotmeter* m_pHiEqFreq; 142 143 bool m_underDestruction; 144 145 DISALLOW_COPY_AND_ASSIGN(EffectsManager); 146 }; 147