From b26c2e08a7c5d0134ec4aa431f0506eb08df9bcf Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 14 Dec 2020 16:55:21 +0100 Subject: [PATCH] Implement IAudioProcessor::getBusArrangement() --- src/common/logging/vst3.cpp | 20 +++++++++++ src/common/logging/vst3.h | 3 ++ src/common/serialization/vst3.h | 1 + src/common/serialization/vst3/component.h | 39 +++++++++++++++++++++ src/plugin/bridges/vst3-impls/component.cpp | 12 +++++-- src/wine-host/bridges/vst3.cpp | 10 ++++++ 6 files changed, 82 insertions(+), 3 deletions(-) diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 075609c1..91a43660 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -162,6 +162,15 @@ void Vst3Logger::log_request(bool is_host_vst, }); } +void Vst3Logger::log_request(bool is_host_vst, + const YaComponent::GetBusArrangement& request) { + log_request_base(is_host_vst, [&](auto& message) { + message << "::getBusArrangement(dir = " << request.dir + << ", index = " << request.index << ", &arr"; + }); +} + void Vst3Logger::log_request(bool is_host_vst, const YaPluginFactory::Construct&) { log_request_base(is_host_vst, @@ -237,6 +246,17 @@ void Vst3Logger::log_response(bool is_host_vst, }); } +void Vst3Logger::log_response( + bool is_host_vst, + const YaComponent::GetBusArrangementResponse& response) { + log_response_base(is_host_vst, [&](auto& message) { + message << response.result.string(); + if (response.result.native() == Steinberg::kResultOk) { + message << ", "; + } + }); +} + void Vst3Logger::log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs& args) { log_response_base(is_host_vst, [&](auto& message) { diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 7541abb2..d2a13011 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -69,6 +69,7 @@ class Vst3Logger { void log_request(bool is_host_vst, const YaComponent::SetState&); void log_request(bool is_host_vst, const YaComponent::GetState&); void log_request(bool is_host_vst, const YaComponent::SetBusArrangements&); + void log_request(bool is_host_vst, const YaComponent::GetBusArrangement&); void log_request(bool is_host_vst, const YaPluginFactory::Construct&); void log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&); void log_request(bool is_host_vst, const WantsConfiguration&); @@ -81,6 +82,8 @@ class Vst3Logger { void log_response(bool is_host_vst, const YaComponent::GetRoutingInfoResponse&); void log_response(bool is_host_vst, const YaComponent::GetStateResponse&); + void log_response(bool is_host_vst, + const YaComponent::GetBusArrangementResponse&); void log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs&); void log_response(bool is_host_vst, const Configuration&); diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 5a3f01c4..f81e893a 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -70,6 +70,7 @@ using ControlRequest = std::variant; diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index d51cca3d..e04ad807 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -457,6 +457,45 @@ class YaComponent : public Steinberg::Vst::IComponent, int32 numIns, Steinberg::Vst::SpeakerArrangement* outputs, int32 numOuts) override = 0; + + /** + * The response code and written state for a call to + * `IAudioProcessor::getBusArrangement(dir, index, arr)`. + */ + struct GetBusArrangementResponse { + UniversalTResult result; + Steinberg::Vst::SpeakerArrangement updated_arr; + + template + void serialize(S& s) { + s.object(result); + s.value8b(updated_arr); + } + }; + + /** + * Message to pass through a call to + * `IAudioProcessor::getBusArrangement(dir, index, arr)` to the Wine + * plugin host. + */ + struct GetBusArrangement { + using Response = GetBusArrangementResponse; + + native_size_t instance_id; + + Steinberg::Vst::BusDirection dir; + int32 index; + Steinberg::Vst::SpeakerArrangement arr; + + template + void serialize(S& s) { + s.value8b(instance_id); + s.value4b(dir); + s.value4b(index); + s.value8b(arr); + } + }; + virtual tresult PLUGIN_API getBusArrangement(Steinberg::Vst::BusDirection dir, int32 index, diff --git a/src/plugin/bridges/vst3-impls/component.cpp b/src/plugin/bridges/vst3-impls/component.cpp index 34863df9..34170d17 100644 --- a/src/plugin/bridges/vst3-impls/component.cpp +++ b/src/plugin/bridges/vst3-impls/component.cpp @@ -180,9 +180,15 @@ tresult PLUGIN_API YaComponentPluginImpl::getBusArrangement( Steinberg::Vst::BusDirection dir, int32 index, Steinberg::Vst::SpeakerArrangement& arr) { - // TODO: Implement - bridge.logger.log("TODO: IAudioProcessor::getBusArrangement()"); - return Steinberg::kNotImplemented; + const GetBusArrangementResponse response = bridge.send_message( + YaComponent::GetBusArrangement{.instance_id = arguments.instance_id, + .dir = dir, + .index = index, + .arr = arr}); + + arr = response.updated_arr; + + return response.result.native(); } tresult PLUGIN_API diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index ef291995..c154a629 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -175,6 +175,16 @@ void Vst3Bridge::run() { request.inputs.data(), request.num_ins, request.outputs.data(), request.num_outs); }, + [&](YaComponent::GetBusArrangement& request) + -> YaComponent::GetBusArrangement::Response { + const tresult result = + component_instances[request.instance_id] + .audio_processor->getBusArrangement( + request.dir, request.index, request.arr); + + return YaComponent::GetBusArrangementResponse{ + .result = result, .updated_arr = request.arr}; + }, [&](const YaPluginFactory::Construct&) -> YaPluginFactory::Construct::Response { return YaPluginFactory::ConstructArgs(