diff --git a/meson.build b/meson.build index 3fb31e2d..103f814e 100644 --- a/meson.build +++ b/meson.build @@ -113,6 +113,7 @@ vst3_plugin_sources = [ 'src/common/serialization/vst3/plugin/edit-controller.cpp', 'src/common/serialization/vst3/plugin/edit-controller-2.cpp', 'src/common/serialization/vst3/plugin/edit-controller-host-editing.cpp', + 'src/common/serialization/vst3/plugin/keyswitch-controller.cpp', 'src/common/serialization/vst3/plugin/midi-mapping.cpp', 'src/common/serialization/vst3/plugin/note-expression-controller.cpp', 'src/common/serialization/vst3/plugin/plugin-base.cpp', @@ -184,6 +185,7 @@ if with_vst3 'src/common/serialization/vst3/plugin/edit-controller.cpp', 'src/common/serialization/vst3/plugin/edit-controller-2.cpp', 'src/common/serialization/vst3/plugin/edit-controller-host-editing.cpp', + 'src/common/serialization/vst3/plugin/keyswitch-controller.cpp', 'src/common/serialization/vst3/plugin/midi-mapping.cpp', 'src/common/serialization/vst3/plugin/note-expression-controller.cpp', 'src/common/serialization/vst3/plugin/plugin-base.cpp', diff --git a/src/common/serialization/vst3/README.md b/src/common/serialization/vst3/README.md index 3d6c3469..6ad0cdac 100644 --- a/src/common/serialization/vst3/README.md +++ b/src/common/serialization/vst3/README.md @@ -28,6 +28,7 @@ VST3 plugin interfaces are implemented as follows: | `YaEditController` | `Vst3PluginProxy` | `IEditController` | | `YaEditController2` | `Vst3PluginProxy` | `IEditController2` | | `YaEditControllerHostEditing` | `Vst3PluginProxy` | `IEditControllerHostEditing` | +| `YaKeyswitchController` | `Vst3PluginProxy` | `IKeyswitchController` | | `YaMidiMapping` | `Vst3PluginProxy` | `IMidiMapping` | | `YaNoteExpressionController` | `Vst3PluginProxy` | `INoteExpressionController` | | `YaPluginBase` | `Vst3PluginProxy` | `IPluginBase` | diff --git a/src/common/serialization/vst3/plugin/keyswitch-controller.cpp b/src/common/serialization/vst3/plugin/keyswitch-controller.cpp new file mode 100644 index 00000000..68cfbfd5 --- /dev/null +++ b/src/common/serialization/vst3/plugin/keyswitch-controller.cpp @@ -0,0 +1,27 @@ +// yabridge: a Wine VST bridge +// Copyright (C) 2020-2021 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 . + +#include "keyswitch-controller.h" + +YaKeyswitchController::ConstructArgs::ConstructArgs() {} + +YaKeyswitchController::ConstructArgs::ConstructArgs( + Steinberg::IPtr object) + : supported(Steinberg::FUnknownPtr( + object)) {} + +YaKeyswitchController::YaKeyswitchController(const ConstructArgs&& args) + : arguments(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/keyswitch-controller.h b/src/common/serialization/vst3/plugin/keyswitch-controller.h new file mode 100644 index 00000000..eedbd0fc --- /dev/null +++ b/src/common/serialization/vst3/plugin/keyswitch-controller.h @@ -0,0 +1,76 @@ +// yabridge: a Wine VST bridge +// Copyright (C) 2020-2021 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 . + +#pragma once + +#include + +#include "../../common.h" +#include "../base.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" + +/** + * Wraps around `IKeyswitchController` for serialization purposes. This is + * instantiated as part of `Vst3PluginProxy`. + */ +class YaKeyswitchController : public Steinberg::Vst::IKeyswitchController { + public: + /** + * These are the arguments for creating a `YaKeyswitchController`. + */ + struct ConstructArgs { + ConstructArgs(); + + /** + * Check whether an existing implementation implements + * `IKeyswitchController` and read arguments from it. + */ + ConstructArgs(Steinberg::IPtr object); + + /** + * Whether the object supported this interface. + */ + bool supported; + + template + void serialize(S& s) { + s.value1b(supported); + } + }; + + /** + * Instantiate this instance with arguments read from another interface + * implementation. + */ + YaKeyswitchController(const ConstructArgs&& args); + + inline bool supported() const { return arguments.supported; } + + virtual int32 PLUGIN_API getKeyswitchCount(int32 busIndex, + int16 channel) override = 0; + virtual tresult PLUGIN_API + getKeyswitchInfo(int32 busIndex, + int16 channel, + int32 keySwitchIndex, + Steinberg::Vst::KeyswitchInfo& info /*out*/) override = 0; + + protected: + ConstructArgs arguments; +}; + +#pragma GCC diagnostic pop