From aeac8e87fa98cce4207d88d0a35c86523d83c25b Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 26 Apr 2020 16:53:34 +0200 Subject: [PATCH] Implement effGetParameterProperties --- src/common/events.h | 6 ++++-- src/common/logging.cpp | 7 +++++++ src/common/serialization.h | 24 ++++++++++++++++++++++++ src/plugin/host-bridge.cpp | 10 ++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/common/events.h b/src/common/events.h index dd473687..af5ffdf1 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -210,6 +210,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, }, [&](WantsChunkBuffer&) -> void* { return string_buffer.data(); }, [&](VstIOProperties& props) -> void* { return &props; }, + [&](VstParameterProperties& props) -> void* { return &props; }, [&](WantsVstRect&) -> void* { return string_buffer.data(); }, [&](const WantsVstTimeInfo&) -> void* { return nullptr; }, [&](WantsString&) -> void* { return string_buffer.data(); }}, @@ -259,8 +260,9 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, return_value); }, [&](VstIOProperties& props) -> EventResposnePayload { - // The plugin has written a pointer to a VstRect struct - // into the data poitner + return props; + }, + [&](VstParameterProperties& props) -> EventResposnePayload { return props; }, [&](WantsVstRect&) -> EventResposnePayload { diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 361b3cd8..07333259 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -182,6 +182,9 @@ void Logger::log_event(bool is_dispatch, message << ""; }, [&](const VstIOProperties&) { message << ""; }, + [&](const VstParameterProperties&) { + message << ""; + }, [&](const WantsVstRect&) { message << ""; }, [&](const WantsVstTimeInfo&) { message << ""; }, [&](const WantsString&) { message << ""; }}, @@ -225,6 +228,10 @@ void Logger::log_event_response(bool is_dispatch, }, [&](const AEffect&) { message << ", "; }, [&](const VstIOProperties&) { message << ", "; }, + [&](const VstParameterProperties& props) { + message << ", "; + }, [&](const VstRect& rect) { message << ", {l: " << rect.left << ", t: " << rect.top << ", r: " << rect.right << ", b: " << rect.bottom diff --git a/src/common/serialization.h b/src/common/serialization.h index 3c133bfe..ebbffad9 100644 --- a/src/common/serialization.h +++ b/src/common/serialization.h @@ -92,6 +92,26 @@ void serialize(S& s, VstIOProperties& props) { s.container1b(props.data); } +template +void serialize(S& s, VstParameterProperties& props) { + s.value4b(props.stepFloat); + s.value4b(props.smallStepFloat); + s.value4b(props.largeStepFloat); + s.container1b(props.label); + s.value4b(props.flags); + s.value4b(props.minInteger); + s.value4b(props.maxInteger); + s.value4b(props.stepInteger); + s.value4b(props.largeStepInteger); + s.container1b(props.shortLabel); + s.value2b(props.displayIndex); + s.value2b(props.category); + s.value2b(props.numParametersInCategory); + s.value2b(props.reserved); + s.container1b(props.categoryLabel); + s.container1b(props.future); +} + template void serialize(S& s, VstRect& rect) { s.value2b(rect.top); @@ -220,6 +240,7 @@ using EventPayload = std::variant; @@ -242,6 +263,7 @@ void serialize(S& s, EventPayload& payload) { [](S& s, VstEvent& event) { s.container1b(event.dump); }); }, [](S& s, VstIOProperties& props) { s.object(props); }, + [](S& s, VstParameterProperties& props) { s.object(props); }, [](S&, WantsChunkBuffer&) {}, [](S&, WantsVstRect&) {}, [](S&, WantsVstTimeInfo&) {}, [](S&, WantsString&) {}}); } @@ -302,6 +324,7 @@ using EventResposnePayload = std::variant; @@ -318,6 +341,7 @@ void serialize(S& s, EventResposnePayload& payload) { }, [](S& s, AEffect& effect) { s.object(effect); }, [](S& s, VstIOProperties& props) { s.object(props); }, + [](S& s, VstParameterProperties& props) { s.object(props); }, [](S& s, VstRect& rect) { s.object(rect); }, [](S& s, VstTimeInfo& time_info) { s.object(time_info); }}); } diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index 04638ac9..45960b5e 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -221,6 +221,9 @@ class DispatchDataConverter : DefaultDataConverter { // data (or at least Bitwig does this) return *static_cast(data); break; + case effGetParameterProperties: + return *static_cast(data); + break; default: return DefaultDataConverter::read(opcode, index, value, data); break; @@ -256,6 +259,13 @@ class DispatchDataConverter : DefaultDataConverter { *static_cast(data) = properties; } break; + case effGetParameterProperties: { + // Same as the above + const auto properties = + std::get(response.payload); + + *static_cast(data) = properties; + } break; default: DefaultDataConverter::write(opcode, data, response); break;