vst sdk aeffect.h
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
The C interface relies on the structure being identical, so I would suggest not to change it, as it should be integrated inside the host, so recompiling it would not help.
-
- KVRAF
- Topic Starter
- 7400 posts since 17 Feb, 2005
How does this code work? I see that with the preprocessor definition, the 'future' array is 4 bytes smaller. Is it supposed to be making room for the function pointer? If so, would x64 function pointer be 8 bytes?
Code: Select all
typedef void (VSTCALLBACK *AEffectProcessProc)
...
#if VST_2_4_EXTENSIONS
/** Process double-precision audio samples in replacing mode @see AudioEffect::processDoubleReplacing */
AEffectProcessDoubleProc processDoubleReplacing;
char future[56]; ///< reserved for future use (please zero)
#else
char future[60]; ///< reserved for future use (please zero)
#endif
- KVRian
- 519 posts since 12 Apr, 2010 from The Netherlands
Yeah, pointers are 64-bit i.e. 8 bytes on x64.camsr wrote:If so, would x64 function pointer be 8 bytes?
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
I think you can't compare the 32bits to the 64bits versions. They are actually different interfaces with no real overlap. I don't know if there is any 64bits VST plugin that isn't 2.4 compliant, so the #if is always true IMHO.
edit: http://www.steinberg.net/index.php?id=334&L=1
If you try 64bits, you are at least 2.4 compliant, so no surprise here.
edit: http://www.steinberg.net/index.php?id=334&L=1
If you try 64bits, you are at least 2.4 compliant, so no surprise here.
-
- KVRist
- 377 posts since 16 Apr, 2004 from Antwerp
Until char future[60] you can't modify, but you can add members after that.camsr wrote:can the struct AEffect be redefined (in affect.h), or is this type "the standard" and hosts will depend on it?
On 64bit, all 8byte integers are 16byte aligned.
-
- KVRAF
- Topic Starter
- 7400 posts since 17 Feb, 2005
Are you sure? Anything in a struct would be packed tight if I recall, but the struct would be 16 byte aligned.SQ4 wrote: On 64bit, all 8byte integers are 16byte aligned.
If I am targeting 2.4, should I be using the future[56] declare? (I know it's obvious, just thought it's better to ask)
I am going through the sdk bit by bit to look for MinGW pitfalls and MSVC specifics.
-
- KVRist
- 377 posts since 16 Apr, 2004 from Antwerp
You can check that easlily : "Magic" = 4 bytes, the next member is "*dispatcher".camsr wrote:Are you sure? Anything in a struct would be packed tight if I recall, but the struct would be 16 byte aligned.SQ4 wrote: On 64bit, all 8byte integers are 16byte aligned.
If I am targeting 2.4, should I be using the future[56] declare? (I know it's obvious, just thought it's better to ask)
I am going through the sdk bit by bit to look for MinGW pitfalls and MSVC specifics.
In 32bit = offset of "*dispatcher" = 4 bytes
In 64bit = offset of "*dispatcher" = 8 bytes
The same goes for member "resvd1".
-
- KVRist
- 377 posts since 16 Apr, 2004 from Antwerp
If it doesn't, all you have to do is add 2 extra members to AEffect.camsr wrote:At the beginning of the header there is a pragma pack(8), will this work the same for -m64?
One before *dispatcher and one before resvd1 :
Something like this
VstInt32 fill4a;
VstInt32 fill4b;
But like I said, you can easilly test it with offsetof().
- KVRAF
- 12555 posts since 7 Dec, 2004
Pragma pack is used to specify the struct packing.
Normally if you have a struct like this:
struct chars_t
{
int8_t a, b, c, d;
};
These are packed into a single dword int32_t as expected.
If you mix sizes however:
struct mix_t
{
int8_t a;
int16_t b;
int32_t c;
int8_t d;
};
Now each will be padded into the size of the largest element. This is something I'd normally need to use a reference to be sure of, but I guess it might work out like this:
a = 24.8 (low = a)
b = 16.16 (low = b)
c = 32
d = 24.8 (low = d)
This is not alignment, this is packing which is completely different.
The VST structs must all be packed to 8-bits.
You can modify everything about the aeffect struct but the offset of each element must remain the same. If you do not use the vst sdk classes pointed to by *object, you must use *user to point to whatever you require and zero *object.
Normally if you have a struct like this:
struct chars_t
{
int8_t a, b, c, d;
};
These are packed into a single dword int32_t as expected.
If you mix sizes however:
struct mix_t
{
int8_t a;
int16_t b;
int32_t c;
int8_t d;
};
Now each will be padded into the size of the largest element. This is something I'd normally need to use a reference to be sure of, but I guess it might work out like this:
a = 24.8 (low = a)
b = 16.16 (low = b)
c = 32
d = 24.8 (low = d)
This is not alignment, this is packing which is completely different.
The VST structs must all be packed to 8-bits.
You can modify everything about the aeffect struct but the offset of each element must remain the same. If you do not use the vst sdk classes pointed to by *object, you must use *user to point to whatever you require and zero *object.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
-
- KVRAF
- Topic Starter
- 7400 posts since 17 Feb, 2005
So I have gone over this again, the size of all elements (without considering packing) in aeffect is 144 bytes x86 and 184 bytes x64, for the vst2.4 defines. Is that what everyone else has?
It should be correct to typedef VstIntPtr as long int on x64 (defined LP64) and int on x86?
And for everything else like vstint32 etc, it should be correct to use int32_t etc?
It should be correct to typedef VstIntPtr as long int on x64 (defined LP64) and int on x86?
And for everything else like vstint32 etc, it should be correct to use int32_t etc?
-
Christian Schüler Christian Schüler https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=48996
- KVRist
- 266 posts since 23 Nov, 2004 from Hamburg, Germany
If I am not reading the header backwards, sizeof( AEffect ) in 64 bit mode should be exactly the size of 24 pointers (or 192 bytes).
EDIT: for VstIntPtr, you use intptr_t
http://www.cplusplus.com/reference/cstdint/
EDIT: for VstIntPtr, you use intptr_t
http://www.cplusplus.com/reference/cstdint/
-
- KVRAF
- Topic Starter
- 7400 posts since 17 Feb, 2005
Thanks. I have the x86 size at 144 bytes and the x64 size at 192 bytes. I think my confusion with this struct started when trying to load a x64 build of my plugin into a x86 host (FL using its built in bridge), while it loaded, parameter controls were not responsive and the parameter value display was not updating. It also will not pass audio. IDK if this is a bug in the FLv10 bit bridge, or my plugin, but the x64 versions work fine in x64 hosts.