Implement IMessage

This commit is contained in:
Robbert van der Helm
2020-12-25 00:54:24 +01:00
parent 7cfd1982dd
commit 84b859c499
4 changed files with 124 additions and 0 deletions
+2
View File
@@ -92,6 +92,7 @@ vst3_plugin_sources = [
'src/common/serialization/vst3/component-handler-proxy.cpp', 'src/common/serialization/vst3/component-handler-proxy.cpp',
'src/common/serialization/vst3/event-list.cpp', 'src/common/serialization/vst3/event-list.cpp',
'src/common/serialization/vst3/host-context-proxy.cpp', 'src/common/serialization/vst3/host-context-proxy.cpp',
'src/common/serialization/vst3/message.cpp',
'src/common/serialization/vst3/param-value-queue.cpp', 'src/common/serialization/vst3/param-value-queue.cpp',
'src/common/serialization/vst3/parameter-changes.cpp', 'src/common/serialization/vst3/parameter-changes.cpp',
'src/common/serialization/vst3/plug-frame-proxy.cpp', 'src/common/serialization/vst3/plug-frame-proxy.cpp',
@@ -146,6 +147,7 @@ if with_vst3
'src/common/serialization/vst3/component-handler-proxy.cpp', 'src/common/serialization/vst3/component-handler-proxy.cpp',
'src/common/serialization/vst3/event-list.cpp', 'src/common/serialization/vst3/event-list.cpp',
'src/common/serialization/vst3/host-context-proxy.cpp', 'src/common/serialization/vst3/host-context-proxy.cpp',
'src/common/serialization/vst3/message.cpp',
'src/common/serialization/vst3/param-value-queue.cpp', 'src/common/serialization/vst3/param-value-queue.cpp',
'src/common/serialization/vst3/parameter-changes.cpp', 'src/common/serialization/vst3/parameter-changes.cpp',
'src/common/serialization/vst3/plug-frame-proxy.cpp', 'src/common/serialization/vst3/plug-frame-proxy.cpp',
+1
View File
@@ -38,6 +38,7 @@ implemented for serialization purposes:
| -------------------- | ------------------- | ---------------------------------------------------------------------- | | -------------------- | ------------------- | ---------------------------------------------------------------------- |
| `YaAttributeList` | `IAttributeList` | | | `YaAttributeList` | `IAttributeList` | |
| `YaEventList` | `IEventList` | Comes with a lot of serialization wrappers around the related structs. | | `YaEventList` | `IEventList` | Comes with a lot of serialization wrappers around the related structs. |
| `YaMessage` | `IMessage` | |
| `YaParameterChanges` | `IParameterChanges` | | | `YaParameterChanges` | `IParameterChanges` | |
| `YaParamValueQueue` | `IParamValueQueue` | | | `YaParamValueQueue` | `IParamValueQueue` | |
| `VectorStream` | `IBStream` | Used for serializing data streams. | | `VectorStream` | `IBStream` | Used for serializing data streams. |
+50
View File
@@ -0,0 +1,50 @@
// yabridge: a Wine VST bridge
// Copyright (C) 2020 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "message.h"
YaMessage::YaMessage(){FUNKNOWN_CTOR}
YaMessage::~YaMessage() {
FUNKNOWN_DTOR
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
IMPLEMENT_FUNKNOWN_METHODS(YaMessage,
Steinberg::Vst::IMessage,
Steinberg::Vst::IMessage::iid)
#pragma GCC diagnostic pop
Steinberg::FIDString PLUGIN_API YaMessage::getMessageID() {
if (message_id) {
return message_id->c_str();
} else {
return nullptr;
}
}
void PLUGIN_API YaMessage::setMessageID(Steinberg::FIDString id /*in*/) {
if (id) {
message_id = id;
} else {
message_id.reset();
}
}
Steinberg::Vst::IAttributeList* PLUGIN_API YaMessage::getAttributes() {
return &attribute_list;
}
+71
View File
@@ -0,0 +1,71 @@
// yabridge: a Wine VST bridge
// Copyright (C) 2020 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivstmessage.h>
#include "attribute-list.h"
#include "base.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
/**
* Wraps around `IMessage` for serialization purposes. We create instances of
* these in `IHostApplication::createInstance()` so the Windows VST3 plugin can
* send messages between objects. There is one huge caveat here: it is
* impossible to work with arbitrary `IMessage` objects, since there's no way to
* retrieve all of the keys in the attribute list. With this approach we support
* hosts that indirectly connect the processor and the controller through a
* proxy (like Ardour), but we still require a dynamic cast from the `IMessage*`
* passed to `YaConnectionPoint::notify()` to a `YaMessage*` for this to work
* for the above mentioned reason.
*/
class YaMessage : public Steinberg::Vst::IMessage {
public:
/**
* Default constructor with an empty message. The plugin can use this to
* write a message.
*/
YaMessage();
~YaMessage();
DECLARE_FUNKNOWN_METHODS
virtual Steinberg::FIDString PLUGIN_API getMessageID() override;
virtual void PLUGIN_API
setMessageID(Steinberg::FIDString id /*in*/) override;
virtual Steinberg::Vst::IAttributeList* PLUGIN_API getAttributes() override;
template <typename S>
void serialize(S& s) {
s.ext(message_id, bitsery::ext::StdOptional{},
[](S& s, std::string& id) { s.text1b(id, 1024); });
s.object(attribute_list);
}
private:
/**
* The implementation that comes with the SDK returns a null pointer when
* the ID has not yet been set, so we'll do the same thing.
*/
std::optional<std::string> message_id;
YaAttributeList attribute_list;
};