17#pragma GCC diagnostic ignored "-Wparentheses"
18#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
19#elif defined(__clang__)
20#pragma clang diagnostic ignored "-Wparentheses"
21#pragma clang diagnostic ignored "-Wdeprecated-declarations"
29#include <wx/msw/wrapwin.h>
38 auto &plug = baseFeatures.
mPlug;
40 std::unique_ptr<LV2Wrapper> wrapper;
42 wrapper = std::make_unique<LV2Wrapper>(
CreateToken{},
44 }
catch(
const std::exception&) {
48 const auto instance = &wrapper->GetInstance();
49 wrapper->SendBlockSize();
50 wrapper->ConnectPorts(ports, portStates,
settings, pOutputs);
54 lilv_instance_activate(instance);
55 lilv_instance_deactivate(instance);
59 state->ReceiveFromInstance();
69 static float blackHole;
75 lilv_instance_connect_port(instance, latencyPort, &
mLatency);
80 void *
const location = port->mIsInput
83 ? &
const_cast<float&
>(
values[index])
84 : pValues ? &pValues->values[index]
87 lilv_instance_connect_port(instance, port->mIndex, location);
101 lilv_instance_connect_port(instance,
102 state->mpPort->mIndex, state->mBuffer.get());
106 lilv_instance_connect_port(instance, state.mpPort->mIndex,
107 state.mBuffer.get());
126) : mFeaturesList{ baseFeatures,
sampleRate, &mWorkerSchedule }
127, mInstance{ [&instanceFeaturesList = mFeaturesList, &plugin,
sampleRate](){
128 auto features = instanceFeaturesList.GetFeaturePointers();
130#if defined(__WXMSW__)
133 const auto libNode = lilv_plugin_get_library_uri(&plugin);
134 const auto libUri = lilv_node_as_uri(libNode);
135 LilvCharsPtr libPath{ lilv_file_uri_parse(libUri,
nullptr) };
136 const auto path = wxPathOnly(libPath.get());
137 SetDllDirectory(path.c_str());
138 auto cleanup =
finally([]{ SetDllDirectory(
nullptr); });
141 auto result = lilv_plugin_instantiate(&plugin,
sampleRate, features.data());
142 return result ? result :
throw std::exception{};
144, mHandle{ lilv_instance_get_handle(mInstance.get()) }
145, mOptionsInterface{
static_cast<const LV2_Options_Interface *
>(
146 lilv_instance_get_extension_data(mInstance.get(), LV2_OPTIONS__interface))
148, mStateInterface{
static_cast<const LV2_State_Interface *
>(
149 lilv_instance_get_extension_data(mInstance.get(), LV2_STATE__interface))
151, mWorkerInterface{
static_cast<const LV2_Worker_Interface *
>(
152 lilv_instance_get_extension_data(mInstance.get(), LV2_WORKER__interface))
155 if (mWorkerInterface)
156 mThread = std::thread{
203 LV2_Options_Option options[2]{ *pOption, {} };
227 while (
mResponses.ReceiveTimeout(0, work) == wxMSGQUEUE_NO_ERROR)
239 uint32_t
size,
const void *data)
253 return (err == wxMSGQUEUE_NO_ERROR)
254 ? LV2_WORKER_SUCCESS : LV2_WORKER_ERR_UNKNOWN;
261 LV2_Worker_Respond_Handle handle, uint32_t
size,
const void *data)
271 return (err == wxMSGQUEUE_NO_ERROR)
272 ? LV2_WORKER_SUCCESS : LV2_WORKER_ERR_UNKNOWN;
Lilv_ptr< char, free_chars > LilvCharsPtr
static Settings & settings()
Hold values to send to effect output meters.
LV2CVPortStateArray mCVPortStates
LV2AtomPortStateArray mAtomPortStates
LV2ControlPortArray mControlPorts
Manager of a handle to an LV2 plug-in instantiation.
static LV2_Worker_Status respond(LV2_Worker_Respond_Handle handle, uint32_t size, const void *data)
static std::unique_ptr< LV2Wrapper > Create(LV2InstanceFeaturesList &baseFeatures, const LV2Ports &ports, LV2PortStates &portStates, const LV2EffectSettings &settings, float sampleRate, EffectOutputs *pOutputs)
Factory.
const LilvInstancePtr mInstance
LV2_Worker_Status ScheduleWork(uint32_t size, const void *data)
LV2_Worker_Status Respond(uint32_t size, const void *data)
wxMessageQueue< LV2Work > mRequests
void ConnectPorts(const LV2Ports &ports, LV2PortStates &portStates, const LV2EffectSettings &settings, EffectOutputs *pOutputs)
~LV2Wrapper()
If a thread was started, joins it.
const LV2_Options_Interface *const mOptionsInterface
LV2_Handle GetHandle() const
void SetFreeWheeling(bool enable)
static LV2_Worker_Status schedule_work(LV2_Worker_Schedule_Handle handle, uint32_t size, const void *data)
LV2WrapperFeaturesList mFeaturesList
void ConnectControlPorts(const LV2Ports &ports, const LV2EffectSettings &settings, EffectOutputs *pOutputs)
const LV2_Worker_Interface *const mWorkerInterface
LV2Wrapper(CreateToken &&, LV2InstanceFeaturesList &baseFeatures, const LilvPlugin &plugin, float sampleRate)
Constructor may spawn a thread.
bool mFreeWheeling
If true, do not spawn extra worker threads.
wxMessageQueue< LV2Work > mResponses
LilvInstance & GetInstance() const
constexpr auto sampleRate
Carry output control port information back to main thread.
Storage locations to be connected to LV2 control ports.
const LV2_Options_Option * NominalBlockLengthOption() const
To compel use of the factory.
const LV2InstanceFeaturesList & Base() const