2 * travesty, pure C VST3-compatible interface
3 * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 struct v3_factory_info
{
29 int32_t flags
; // set to 0x10 (unicode)
32 struct v3_class_info
{
34 int32_t cardinality
; // set to 0x7FFFFFFF (many instances)
39 struct v3_plugin_factory
{
43 v3_result (V3_API
*get_factory_info
)(void* self
, struct v3_factory_info
*);
44 int32_t (V3_API
*num_classes
)(void* self
);
45 v3_result (V3_API
*get_class_info
)(void* self
, int32_t idx
, struct v3_class_info
*);
46 v3_result (V3_API
*create_instance
)(void* self
, const v3_tuid class_id
, const v3_tuid iid
, void** instance
);
49 static constexpr const v3_tuid v3_plugin_factory_iid
=
50 V3_ID(0x7A4D811C, 0x52114A1F, 0xAED9D2EE, 0x0B43BF9F);
57 V3_DISTRIBUTABLE
= 1 << 0,
58 V3_SIMPLE_MODE
= 1 << 1
61 struct v3_class_info_2
{
63 int32_t cardinality
; // set to 0x7FFFFFFF
67 char sub_categories
[128];
73 struct v3_plugin_factory_2
{
75 struct v3_plugin_factory
;
77 v3_result (V3_API
*get_class_info_2
)(void* self
, int32_t idx
, struct v3_class_info_2
*);
80 static constexpr const v3_tuid v3_plugin_factory_2_iid
=
81 V3_ID(0x0007B650, 0xF24B4C0B, 0xA464EDB9, 0xF00B2ABB);
85 * (we got it right this time I swear)
87 * same as above, but "unicode" (really just utf-16, thanks microsoft!)
90 struct v3_class_info_3
{
92 int32_t cardinality
; // set to 0x7FFFFFFF
96 char sub_categories
[128];
99 int16_t sdk_version
[64];
102 struct v3_plugin_factory_3
{
104 struct v3_plugin_factory_2
;
106 v3_result (V3_API
*get_class_info_utf16
)(void* self
, int32_t idx
, struct v3_class_info_3
*);
107 v3_result (V3_API
*set_host_context
)(void* self
, struct v3_funknown
** host
);
110 static constexpr const v3_tuid v3_plugin_factory_3_iid
=
111 V3_ID(0x4555A2AB, 0xC1234E57, 0x9B122910, 0x36878931);
119 struct v3_plugin_factory_cpp
: v3_funknown
{
120 v3_plugin_factory v1
;
121 v3_plugin_factory_2 v2
;
122 v3_plugin_factory_3 v3
;
126 constexpr v3_plugin_factory_2
* v3_cpp_obj(v3_plugin_factory_2
** obj
)
129 * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default,
130 * but we need everything to be `static_cast` for it to be `constexpr` compatible.
132 return static_cast<v3_plugin_factory_2
*>(
133 static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj
)) + sizeof(void*)*7));
137 constexpr v3_plugin_factory_3
* v3_cpp_obj(v3_plugin_factory_3
** obj
)
140 * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default,
141 * but we need everything to be `static_cast` for it to be `constexpr` compatible.
143 return static_cast<v3_plugin_factory_3
*>(
144 static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj
)) + sizeof(void*)*8));