mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-16 16:33:55 +02:00
Pass through getParameter and setParameter
This commit is contained in:
@@ -57,6 +57,7 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
|
||||
socket_endpoint(socket_endpoint_path),
|
||||
host_vst_dispatch(io_context),
|
||||
vst_host_callback(io_context),
|
||||
host_vst_parameters(io_context),
|
||||
vst_host_aeffect(io_context) {
|
||||
// Got to love these C APIs
|
||||
if (plugin_handle == nullptr) {
|
||||
@@ -86,6 +87,7 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
|
||||
// in the Linus plugin
|
||||
host_vst_dispatch.connect(socket_endpoint);
|
||||
vst_host_callback.connect(socket_endpoint);
|
||||
host_vst_parameters.connect(socket_endpoint);
|
||||
vst_host_aeffect.connect(socket_endpoint);
|
||||
|
||||
// Initialize after communication has been set up We'll try to do the same
|
||||
@@ -117,6 +119,30 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
|
||||
passthrough_event(host_vst_dispatch, plugin, plugin->dispatcher);
|
||||
}
|
||||
});
|
||||
|
||||
parameters_handler = std::thread([&]() {
|
||||
while (true) {
|
||||
// Both `getParameter` and `setParameter` functions are passed
|
||||
// through on this socket since they have a lot of overlap. The
|
||||
// presence of the `value` field tells us which one we're dealing
|
||||
// with.
|
||||
auto request = read_object<Parameter>(host_vst_parameters);
|
||||
if (request.value.has_value()) {
|
||||
// `setParameter`
|
||||
plugin->setParameter(plugin, request.index,
|
||||
request.value.value());
|
||||
|
||||
ParameterResult response{std::nullopt};
|
||||
write_object(host_vst_parameters, response);
|
||||
} else {
|
||||
// `getParameter`
|
||||
float value = plugin->getParameter(plugin, request.index);
|
||||
|
||||
ParameterResult response{value};
|
||||
write_object(host_vst_parameters, response);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void PluginBridge::wait() {
|
||||
|
||||
@@ -77,6 +77,11 @@ class PluginBridge {
|
||||
// plugin (through the Wine VST host).
|
||||
boost::asio::local::stream_protocol::socket host_vst_dispatch;
|
||||
boost::asio::local::stream_protocol::socket vst_host_callback;
|
||||
/**
|
||||
* Used for both `getParameter` and `setParameter` since they mostly
|
||||
* overlap.
|
||||
*/
|
||||
boost::asio::local::stream_protocol::socket host_vst_parameters;
|
||||
|
||||
/**
|
||||
* This socket only handles updates of the `AEffect` struct instead of
|
||||
@@ -89,6 +94,10 @@ class PluginBridge {
|
||||
* The thread that handles dispatch events from the host.
|
||||
*/
|
||||
std::thread dispatch_handler;
|
||||
/**
|
||||
* The thread that responds to `getParameter` and `setParameter` requests.
|
||||
*/
|
||||
std::thread parameters_handler;
|
||||
|
||||
// TODO: Set up all other callback handlers
|
||||
// TODO: Set up process and processReplacing callback handlers
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user