Audacity 3.2.0
LV2Instance.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file LV2Instance.h
6 @brief Holds non-UI processing state for an instance of an LV2 effect
7
8 Paul Licameli split from LV2Effect.h
9
10 Audacity(R) is copyright (c) 1999-2013 Audacity Team.
11 License: GPL v2 or later. See License.txt.
12
13*********************************************************************/
14
15#ifndef __AUDACITY_LV2_INSTANCE__
16#define __AUDACITY_LV2_INSTANCE__
17
18
19#if USE_LV2
20
22#include "LV2Ports.h"
23#include "PerTrackEffect.h"
24
25class LV2Wrapper;
26
27class LV2_API LV2Instance final : public PerTrackEffect::Instance
28{
29public:
30 LV2Instance(const PerTrackEffect &effect,
31 const LV2FeaturesList &features, const LV2Ports &ports);
32 ~LV2Instance() override;
33
34 bool IsOk() const { return mFeatures.mOk; }
35
36 const LV2PortStates &GetPortStates() const { return mPortStates; }
37
39 ChannelNames chanMap) override;
41 const float *const *inBlock, float *const *outBlock, size_t blockLen)
42 override;
43 SampleCount GetLatency(
44 const EffectSettings &settings, double sampleRate) const override;
45
46 const LV2Wrapper *GetMaster() const { return mMaster.get(); }
47
51 void MakeMaster(const EffectSettings &settings, double sampleRate);
52
53 std::unique_ptr<LV2Wrapper> MakeWrapper(const EffectSettings &settings,
54 double sampleRate, EffectOutputs *pOutputs);
55
56 size_t GetBlockSize() const override;
57 size_t SetBlockSize(size_t maxBlockSize) override;
58
59 unsigned GetAudioInCount() const override;
60 unsigned GetAudioOutCount() const override;
61
63 override;
65 unsigned numChannels, float sampleRate) override;
66 bool RealtimeFinalize(EffectSettings &settings) noexcept override;
67 bool RealtimeSuspend() override;
68 bool RealtimeResume() override;
69 bool RealtimeProcessStart(MessagePackage &package) override;
70 size_t RealtimeProcess(size_t group, EffectSettings &settings,
71 const float *const *inbuf, float *const *outbuf, size_t numSamples)
72 override;
73 bool RealtimeProcessEnd(EffectSettings &settings) noexcept override;
74
75private:
78 LV2PortStates mPortStates{ mPorts };
79
81 std::unique_ptr<LV2Wrapper> mMaster;
82
84 std::vector<std::unique_ptr<LV2Wrapper>> mSlaves;
85
86 LV2_Atom_Forge mForge{};
87
88 // Position info
89 float mPositionSpeed{ 1.0f };
90 int64_t mPositionFrame{ 0 };
91
92 size_t mUserBlockSize{};
93
94 size_t mNumSamples{};
95 bool mRolling{ true };
96 bool mUseLatency{ false };
97};
98
99#endif
100#endif
ChannelName
static Settings & settings()
Definition: TrackInfo.cpp:51
virtual unsigned GetAudioInCount() const =0
How many input buffers to allocate at once.
virtual bool RealtimeAddProcessor(EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
virtual size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
Called for destructive effect computation.
virtual bool RealtimeSuspend()
virtual bool RealtimeResume()
virtual size_t SetBlockSize(size_t maxBlockSize)=0
virtual bool RealtimeInitialize(EffectSettings &settings, double sampleRate)
virtual bool RealtimeProcessEnd(EffectSettings &settings) noexcept
settings can be updated to let a dialog change appearance at idle
virtual bool RealtimeFinalize(EffectSettings &settings) noexcept
virtual SampleCount GetLatency(const EffectSettings &settings, double sampleRate) const
virtual unsigned GetAudioOutCount() const =0
How many output buffers to allocate at once.
virtual size_t GetBlockSize() const =0
virtual bool RealtimeProcessStart(MessagePackage &package)
settings are possibly changed, since last call, by an asynchronous dialog
virtual size_t RealtimeProcess(size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
Hold values to send to effect output meters.
std::vector< std::unique_ptr< LV2Wrapper > > mSlaves
Each holds lv2 library state for realtime processing of one track.
Definition: LV2Instance.h:84
LV2InstanceFeaturesList mFeatures
Definition: LV2Instance.h:76
std::unique_ptr< LV2Wrapper > mMaster
Holds lv2 library state for destructive processing.
Definition: LV2Instance.h:81
const LV2PortStates & GetPortStates() const
Definition: LV2Instance.h:36
const LV2Wrapper * GetMaster() const
Definition: LV2Instance.h:46
const LV2Ports & mPorts
Definition: LV2Instance.h:77
~LV2Instance() override
bool IsOk() const
Definition: LV2Instance.h:34
Manager of a handle to an LV2 plug-in instantiation.
Definition: LV2Wrapper.h:45
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
Base class for many of the effects in Audacity.
Externalized state of a plug-in.