15#ifndef __AUDACITY_LV2_PORTS__
16#define __AUDACITY_LV2_PORTS__
22#include <unordered_map>
29#include "lv2/atom/forge.h"
37 LV2Port(
const LilvPort *port,
int index,
bool isInput,
38 const wxString &symbol,
const wxString &
name,
63 const wxString & symbol,
const wxString &
name,
65 uint32_t minimumSize,
bool isMidi,
bool wantsPosition
66 ) :
LV2Port{ port, index, isInput, symbol,
name, group }
82 : mpPort{ move(pPort) }
84 , mBuffer{
safenew uint8_t[mpPort->mMinimumSize] }
97 ResetForInstanceOutput();
105 void SendToInstance(LV2_Atom_Forge &forge, int64_t frameTime,
float speed);
106 void ResetForInstanceOutput();
109 void ReceiveFromInstance();
116 std::function<
void(
const LV2_Atom *atom, uint32_t
size)>
handler);
119 void ReceiveFromDialog(
const void *buffer, uint32_t buffer_size);
131 LV2CVPort(
const LilvPort *port,
int index,
bool isInput,
132 const wxString & symbol,
const wxString &
name,
134 float min,
float max,
float def,
bool hasLo,
bool hasHi
135 ) :
LV2Port(port, index, isInput, symbol,
name, group)
164 const wxString & symbol,
const wxString &
name,
166 std::vector<double> scaleValues, wxArrayString scaleLabels,
167 const wxString &units,
168 float min,
float max,
float def,
bool hasLo,
bool hasHi,
169 bool toggle,
bool enumeration,
bool integer,
bool sampleRate,
170 bool trigger,
bool logarithmic
171 ) :
LV2Port{ port, index, isInput, symbol,
name, group }
172 , mScaleValues{ move(scaleValues) }
173 , mScaleLabels(
std::move(scaleLabels) )
175 , mMin{
min }, mMax{ max }, mDef{ def }
176 , mHasLo{ hasLo }, mHasHi{ hasHi }
177 , mToggle{ toggle }, mEnumeration{ enumeration }, mInteger{ integer }
179 , mTrigger{ trigger }, mLogarithmic{ logarithmic }
200 size_t Discretize(
float value)
const;
210 mutable std::shared_ptr<const LilvState>
mpState;
230 std::unique_ptr<EffectOutputs> Clone()
const override;
260 explicit LV2Ports(
const LilvPlugin &plug);
266 const char *port_symbol, uint32_t *
size, uint32_t *type)
const;
269 const void *value, uint32_t
size, uint32_t type)
const;
272 unsigned mAudioIn{ 0 };
273 unsigned mAudioOut{ 0 };
276 std::optional<size_t> mControlInIdx{};
277 std::optional<size_t> mControlOutIdx{};
278 unsigned mMidiIn{ 0 };
279 unsigned mMidiOut{ 0 };
285 std::unordered_map<TranslatableString, std::vector<int>>
mGroupMap;
289 int mLatencyPort{ -1 };
std::vector< LV2CVPortState > LV2CVPortStateArray
No need yet for extra indirection.
std::shared_ptr< LV2AtomPortState > LV2AtomPortStatePtr
std::shared_ptr< LV2AudioPort > LV2AudioPortPtr
std::shared_ptr< LV2ControlPort > LV2ControlPortPtr
std::vector< LV2AtomPortPtr > LV2AtomPortArray
LV2EffectSettings & GetSettings(EffectSettings &settings)
std::vector< LV2CVPortPtr > LV2CVPortArray
std::vector< LV2AtomPortStatePtr > LV2AtomPortStateArray
std::shared_ptr< LV2CVPort > LV2CVPortPtr
std::vector< LV2AudioPortPtr > LV2AudioPortArray
std::vector< LV2ControlPortState > LV2ControlPortStateArray
No need yet for extra indirection.
std::shared_ptr< LV2AtomPort > LV2AtomPortPtr
std::vector< LV2ControlPortPtr > LV2ControlPortArray
std::unique_ptr< Type, Lilv_deleter< Type, f > > Lilv_ptr
Generate classes of smart pointers to lv2 resources.
static Settings & settings()
std::vector< TranslatableString > TranslatableStrings
Hold values to send to effect output meters.
Immutable description of an LV2 Atom port.
LV2AtomPort(const LilvPort *port, int index, bool isInput, const wxString &symbol, const wxString &name, const TranslatableString &group, uint32_t minimumSize, bool isMidi, bool wantsPosition)
const uint32_t mMinimumSize
const bool mWantsPosition
Immutable description of an LV2 Audio port.
Immutable description of an LV2 CV port (control data signal at sample rate)
LV2CVPort(const LilvPort *port, int index, bool isInput, const wxString &symbol, const wxString &name, const TranslatableString &group, float min, float max, float def, bool hasLo, bool hasHi)
Immutable description of an LV2 control port.
LV2ControlPort(const LilvPort *port, int index, bool isInput, const wxString &symbol, const wxString &name, const TranslatableString &group, std::vector< double > scaleValues, wxArrayString scaleLabels, const wxString &units, float min, float max, float def, bool hasLo, bool hasHi, bool toggle, bool enumeration, bool integer, bool sampleRate, bool trigger, bool logarithmic)
const wxArrayString mScaleLabels
const std::vector< double > mScaleValues
Immutable description of an LV2 port.
const TranslatableString mGroup
const LilvPort *const mPort
LV2Port(const LilvPort *port, int index, bool isInput, const wxString &symbol, const wxString &name, const TranslatableString &group)
LV2PortStates(const LV2PortStates &)=delete
LV2CVPortStateArray mCVPortStates
LV2PortStates & operator=(const LV2PortStates &)=delete
LV2AtomPortStateArray mAtomPortStates
LV2PortUIStates & operator=(const LV2PortUIStates &)=delete
LV2AtomPortStatePtr mControlIn
LV2ControlPortStateArray mControlPortStates
LV2AtomPortStatePtr mControlOut
LV2PortUIStates(const LV2PortUIStates &)=delete
std::unordered_map< TranslatableString, std::vector< int > > mGroupMap
TranslatableStrings mGroups
LV2ControlPortArray mControlPorts
LV2AtomPortArray mAtomPorts
std::unordered_map< uint32_t, size_t > mControlPortMap
LV2AudioPortArray mAudioPorts
Holds a msgid for the translation catalog; may also bind format arguments.
ZixRing * zix_ring_new(uint32_t size)
void zix_ring_mlock(ZixRing *ring)
constexpr auto sampleRate
AuthorizationHandler handler
Externalized state of a plug-in.
State of an instance of an LV2 Atom port.
const std::unique_ptr< uint8_t[]> mBuffer
const Lilv_ptr< ZixRing, zix_ring_free > mRing
LV2AtomPortState(LV2AtomPortPtr pPort)
const LV2AtomPortPtr mpPort
State of an instance of an LV2 CV port.
LV2CVPortState(LV2CVPortPtr pPort)
const LV2CVPortPtr mpPort
Other UI related state of an instance of an LV2 Control port.
float mLst
Value of mTmp last seen by idle-time updater.
float mLo
Lower bound, as scaled by sample rate if that is required.
float mHi
Upper bound, as scaled by sample rate if that is required.
float mTmp
Value of UI control, as scaled by sample rate if that is required.
const LV2ControlPortPtr mpPort
LV2ControlPortState(LV2ControlPortPtr pPort)
Carry output control port information back to main thread.
~LV2EffectOutputs() override
std::vector< float > values
vector of values in correspondence with the control ports
Storage locations to be connected to LV2 control ports.
std::vector< float > values
vector of values in correspondence with the control ports
std::shared_ptr< const LilvState > mpState
Result of last load of a preset; may be null.