From 7ce42e4306db48222f34b7c5f4b1d49e13d1f5dc Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 28 Apr 2020 12:54:36 +0200 Subject: [PATCH] Add support for effGetMidiKeyName Not a lot of plugins use it, but it's really nice to have when they do. --- src/common/events.h | 4 ++++ src/common/logging.cpp | 5 +++++ src/common/serialization.h | 9 +++++++++ src/common/vst24.h | 16 ++++++++++++++++ src/plugin/host-bridge.cpp | 9 +++++++++ 5 files changed, 43 insertions(+) diff --git a/src/common/events.h b/src/common/events.h index 1efb6509..ab861d6a 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -226,6 +226,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, return binary_buffer.data(); }, [&](VstIOProperties& props) -> void* { return &props; }, + [&](VstMidiKeyName& key_name) -> void* { return &key_name; }, [&](VstParameterProperties& props) -> void* { return &props; }, [&](WantsVstRect&) -> void* { return string_buffer.data(); }, [&](const WantsVstTimeInfo&) -> void* { return nullptr; }, @@ -276,6 +277,9 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, [&](VstIOProperties& props) -> EventResposnePayload { return props; }, + [&](VstMidiKeyName& key_name) -> EventResposnePayload { + return key_name; + }, [&](VstParameterProperties& props) -> EventResposnePayload { return props; }, diff --git a/src/common/logging.cpp b/src/common/logging.cpp index d500e22c..a9966c90 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -185,6 +185,7 @@ void Logger::log_event(bool is_dispatch, message << ""; }, [&](const VstIOProperties&) { message << ""; }, + [&](const VstMidiKeyName&) { message << ""; }, [&](const VstParameterProperties&) { message << ""; }, @@ -234,6 +235,7 @@ void Logger::log_event_response(bool is_dispatch, }, [&](const AEffect&) { message << ", "; }, [&](const VstIOProperties&) { message << ", "; }, + [&](const VstMidiKeyName&) { message << ", "; }, [&](const VstParameterProperties& props) { message << ", "; @@ -404,6 +406,9 @@ std::optional opcode_to_string(bool is_dispatch, int opcode) { case effGetOutputProperties: return "effGetOutputProperties"; break; + case effGetMidiKeyName: + return "effGetMidiKeyName"; + break; default: return std::nullopt; break; diff --git a/src/common/serialization.h b/src/common/serialization.h index ff761c5c..48f111af 100644 --- a/src/common/serialization.h +++ b/src/common/serialization.h @@ -92,6 +92,11 @@ void serialize(S& s, VstIOProperties& props) { s.container1b(props.data); } +template +void serialize(S& s, VstMidiKeyName& key_name) { + s.container1b(key_name.data); +} + template void serialize(S& s, VstParameterProperties& props) { s.value4b(props.stepFloat); @@ -248,6 +253,7 @@ using EventPayload = std::variant, AEffect, VstIOProperties, + VstMidiKeyName, VstParameterProperties, VstRect, VstTimeInfo>; @@ -350,6 +358,7 @@ void serialize(S& s, EventResposnePayload& payload) { }, [](S& s, AEffect& effect) { s.object(effect); }, [](S& s, VstIOProperties& props) { s.object(props); }, + [](S& s, VstMidiKeyName& key_name) { s.object(key_name); }, [](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/common/vst24.h b/src/common/vst24.h index 3b5afc14..d011fbdd 100644 --- a/src/common/vst24.h +++ b/src/common/vst24.h @@ -29,6 +29,12 @@ constexpr int effGetInputProperties = 33; constexpr int effGetOutputProperties = 34; +// Found on +// https://github.com/falkTX/Carla/blob/07e876a743c5e15c358be170af2e523eadc7dbfa/source/utils/CarlaVstUtils.hpp#L75 +// Used to assign names to MIDI keys, for some reason uses the `VstMidiKeyName` +// struct defined below rather than a simple string. +constexpr int effGetMidiKeyName = 66; + /** * The struct that's being passed through the data parameter during the * `effGetInputProperties` and `effGetOutputProperties` opcodes. Reverse @@ -38,3 +44,13 @@ constexpr int effGetOutputProperties = 34; struct VstIOProperties { char data[128]; }; + +/** + * The struct that's passed during `effGetMidiKeyName`. Will be used to write + * the name of a key to (i.e. the name of a sample for drum machines). Again, + * not sure about the exact contents of this struct, but at least the size is + * right! + */ +struct VstMidiKeyName { + char data[80]; +}; diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index 82f2d32f..6398dff5 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -226,6 +226,8 @@ class DispatchDataConverter : DefaultDataConverter { case effGetParameterProperties: return *static_cast(data); break; + case effGetMidiKeyName: + return *static_cast(data); default: return DefaultDataConverter::read(opcode, index, value, data); break; @@ -268,6 +270,13 @@ class DispatchDataConverter : DefaultDataConverter { *static_cast(data) = properties; } break; + case effGetMidiKeyName: { + // Ditto + const auto properties = + std::get(response.payload); + + *static_cast(data) = properties; + } break; default: DefaultDataConverter::write(opcode, data, response); break;