Audacity 3.2.0
LadspaInstance.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 LadspaInstance.h
6
7 Dominic Mazzoni
8 Paul Licameli split from LadspaEffect.cpp
9
10**********************************************************************/
11#ifndef __AUDACITY_LADSPA_INSTANCE__
12#define __AUDACITY_LADSPA_INSTANCE__
13
14#include "PerTrackEffect.h"
15#include "ladspa.h"
16
18 explicit LadspaEffectSettings(size_t nPorts = 0)
19 : controls( nPorts )
20 {}
21
22 // Allocate as many slots as there are ports, although some may correspond
23 // to audio, not control, ports and so rest unused
24 std::vector<float> controls;
25};
26
30 std::unique_ptr<EffectOutputs> Clone() const override;
31
32 void Assign(EffectOutputs &&src) override;
33
34 // Allocate as many slots as there are ports, although some may correspond
35 // to input and audio ports and remain unused
36 std::vector<float> controls;
37};
38
39struct LADSPA_API LadspaInstance
42{
44 static bool LoadUseLatency(
45 const EffectDefinitionInterface &effect);
47 static bool SaveUseLatency(
48 const EffectDefinitionInterface &effect, bool value);
49
52 {
53 auto pSettings = settings.cast<LadspaEffectSettings>();
54 assert(pSettings);
55 return *pSettings;
56 }
58 static inline const LadspaEffectSettings &
60 {
61 return GetSettings(const_cast<EffectSettings &>(settings));
62 }
63
64 LadspaInstance(const PerTrackEffect &processor,
65 const LADSPA_Descriptor *pData,
66 const ArrayOf<unsigned long> &inputPorts,
67 const ArrayOf<unsigned long> &outputPorts,
68 unsigned audioIns, unsigned audioOuts, int latencyPort);
69 bool ProcessInitialize(EffectSettings &settings, double sampleRate,
70 ChannelNames chanMap) override;
71 bool ProcessFinalize() noexcept override;
72 size_t ProcessBlock(EffectSettings &settings,
73 const float *const *inBlock, float *const *outBlock, size_t blockLen)
74 override;
75
76 SampleCount GetLatency(const EffectSettings &settings, double sampleRate)
77 const override;
78
79 bool RealtimeInitialize(EffectSettings &settings, double sampleRate)
80 override;
81 bool RealtimeAddProcessor(EffectSettings &settings,
82 EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
83 override;
84 bool RealtimeSuspend() override;
85 bool RealtimeResume() override;
86 bool RealtimeProcessStart(MessagePackage &package) override;
87 size_t RealtimeProcess(size_t group, EffectSettings &settings,
88 const float *const *inBuf, float *const *outBuf, size_t numSamples)
89 override;
90 bool RealtimeProcessEnd(EffectSettings &settings) noexcept override;
91 bool RealtimeFinalize(EffectSettings &settings) noexcept override;
92
93 unsigned GetAudioInCount() const override;
94 unsigned GetAudioOutCount() const override;
95
96 LADSPA_Handle InitInstance(
98 LadspaEffectOutputs *pOutputs) const;
99 void FreeInstance(LADSPA_Handle handle) const;
100
101 const LADSPA_Descriptor *const mData;
102 const ArrayOf<unsigned long> &mInputPorts;
103 const ArrayOf<unsigned long> &mOutputPorts;
104
105 bool mReady{ false };
106 LADSPA_Handle mMaster{};
107
108 // Realtime processing
109 std::vector<LADSPA_Handle> mSlaves;
110
111 const unsigned mAudioIns;
112 const unsigned mAudioOuts;
113 const int mLatencyPort;
114 const bool mUseLatency;
115};
116
117#endif
ChannelName
static Settings & settings()
Definition: TrackInfo.cpp:51
EffectDefinitionInterface is a ComponentInterface that adds some basic read-only information about ef...
Inherit to add a state variable to an EffectInstance subclass.
Hold values to send to effect output meters.
virtual std::unique_ptr< EffectOutputs > Clone() const =0
virtual void Assign(EffectOutputs &&src)=0
Update one Outputs object from another.
Base class for many of the effects in Audacity.
void * LADSPA_Handle
Definition: ladspa.h:363
DynamicRangeProcessorSettings GetSettings(EffectSettingsAccess &access)
_LADSPA_Descriptor is a structure that provides the API to a LADSPA (Linux Audio Plugin Architecture)...
Definition: ladspa.h:373
Externalized state of a plug-in.
Carry output control port information back to main thread.
~LadspaEffectOutputs() override
std::vector< float > controls
std::vector< float > controls
LadspaEffectSettings(size_t nPorts=0)
static LadspaEffectSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
const bool mUseLatency
static const LadspaEffectSettings & GetSettings(const EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
const unsigned mAudioIns
const unsigned mAudioOuts
std::vector< LADSPA_Handle > mSlaves
const int mLatencyPort