diff --git a/build.bat b/build.bat index b21c68c..382c738 100755 --- a/build.bat +++ b/build.bat @@ -5,13 +5,13 @@ cd bin set vst=../../../src/vstsdk2.4/ set vst2x=%vst%public.sdk/source/vst2.x/ set vstdef=%vst%public.sdk/samples/vst2.x/win/vstplug.def -set vst_c=/LD /I"%vst%" +set vst_c=/I"%vst%" set vst_ld=/DEF:"%vstdef%" set vstsrc=%vst2x%audioeffect.cpp %vst2x%audioeffectx.cpp %vst2x%vstplugmain.cpp -set wall=/Wall /wd4100 /wd4668 /wd4820 /wd4514 /wd4365 /wd4711 /wd4996 +set wall=/Wall /wd4100 /wd4668 /wd4820 /wd4514 /wd4365 /wd4711 /wd4996 /wd4127 REM the warning disabled below is function-not-inlined -set common_c=/I"../" /I"../include/" %wall% /wd4710 +set common_c=/LD /I"../" /I"../include/" %wall% /wd4710 set release_c=%common_c% /O2 /Oy- /GL /EHsc /fp:fast /analyze- /nologo set release_ld= @@ -28,6 +28,8 @@ goto:eof :compile set crap=%~1 -cscript ..\util\generate.vbs %crap% +cscript ..\util\generate.vbs %crap% vst +cscript ..\util\generate.vbs %crap% ladspa cl %release_c% %vst_c% ../crap/vst/%crap%.cpp %vstsrc% /link %release_ld% %vst_ld% /OUT:"vst/crap_%crap%.dll" +cl %release_c% ../crap/ladspa/%crap%.cpp /link %release_ld% /OUT:"ladspa/crap_%crap%.dll" goto:eof diff --git a/include/ladspa.hpp b/include/ladspa.hpp index 439be95..3e1d1d6 100644 --- a/include/ladspa.hpp +++ b/include/ladspa.hpp @@ -107,9 +107,9 @@ typedef struct _LADSPA_Descriptor { void (*deactivate)(LADSPA_Handle Instance); void (*cleanup)(LADSPA_Handle Instance); } LADSPA_Descriptor; -#ifdef WIN32 +#if WIN32 || _WIN32 // weird clang bug workaround -#if (__clang__ != 1) || (_X86_ != 1) +#if (__clang__ != 1) || (_X86_ != 1) || _MSC_VER __declspec(dllexport) #endif #endif diff --git a/template/ladspa.cpp b/template/ladspa.cpp index b06c4d6..3201971 100644 --- a/template/ladspa.cpp +++ b/template/ladspa.cpp @@ -1,10 +1,15 @@ -#include - -#include "ladspa.hpp" - //#INCLUDE //#REDEFINE +#include +#include +#ifdef _MSC_VER +// we need memcpy +#include +#endif + +#include "ladspa.hpp" + #ifndef PARAM_NAME_LEN #define PARAM_NAME_LEN 25 #endif @@ -60,9 +65,9 @@ struct plug_t { TEMPLATE struct LADSPA_Plugin { - //static constexpr ulong name_buf_size = (portcount)*PARAM_NAME_LEN; - static constexpr ulong portcount = IO_PLUGS + T::parameters; - static Param default_params[T::parameters]; + //static const ulong name_buf_size = (portcount)*PARAM_NAME_LEN; + static const ulong portcount = IO_PLUGS + T::parameters; + static Param *default_params; static LADSPA_PortDescriptor descs[portcount]; static LADSPA_PortRangeHint hints[portcount]; static char* names[portcount]; @@ -78,9 +83,12 @@ struct LADSPA_Plugin { memcpy(names[i], p_default_strings[i], PARAM_NAME_LEN); descs[i] = LADSPA_PORT_AUDIO; descs[i] |= (i < 2) ? LADSPA_PORT_INPUT : LADSPA_PORT_OUTPUT; - hints[i] = (LADSPA_PortRangeHint){.HintDescriptor = 0}; + hints[i] = {0, 0, 0}; } + default_params = NULL; + if (T::parameters) + default_params = new Param[T::parameters]; T::construct_params(default_params); for (int i = 0; i < T::parameters; i++) { int j = i + IO_PLUGS; @@ -172,7 +180,7 @@ struct LADSPA_Plugin { }; #define P LADSPA_Plugin -TEMPLATE Param P::default_params[T::parameters]; +TEMPLATE Param *P::default_params; TEMPLATE LADSPA_PortDescriptor P::descs[P::portcount]; TEMPLATE LADSPA_PortRangeHint P::hints[P::portcount]; TEMPLATE char* P::names[P::portcount]; diff --git a/template/vst.cpp b/template/vst.cpp index 7f456a9..a15b068 100644 --- a/template/vst.cpp +++ b/template/vst.cpp @@ -1,9 +1,10 @@ -#include -#include "public.sdk/source/vst2.x/audioeffectx.h" - //#INCLUDE //#REDEFINE +#include + +#include "public.sdk/source/vst2.x/audioeffectx.h" + // VST 2.4 by standard only holds 8 (+ 1 null) length strings, // but this is never the case in practice. I've seen up to 24. #define MAX_PARAM_LEN 24 diff --git a/util/generate.vbs b/util/generate.vbs index 8ef9311..72ee7db 100755 --- a/util/generate.vbs +++ b/util/generate.vbs @@ -1,9 +1,10 @@ Set FSO = CreateObject("Scripting.FileSystemObject") Name = WScript.Arguments(0) +Kind = WScript.Arguments(1) -IPath = "../template/vst.cpp" -OPath = "../crap/vst/"&Name&".cpp" +IPath = "../template/"&Kind&".cpp" +OPath = "../crap/"&Kind&"/"&Name&".cpp" Inc = "crap/"&Name&".hpp" Set File = FSO.OpenTextFile(IPath)