diff --git a/dep/dep.7z b/dep/dep.7z index b3fae2a2..1289fd6d 100644 Binary files a/dep/dep.7z and b/dep/dep.7z differ diff --git a/include/global.hpp b/include/global.hpp index 934597c4..1a7ae93f 100644 --- a/include/global.hpp +++ b/include/global.hpp @@ -12,7 +12,7 @@ #ifdef USE_VST2 -struct VSTPluginWrapper; +class VSTPluginWrapper; #endif // USE_VST2 diff --git a/include/global_ui.hpp b/include/global_ui.hpp index 6d1c19be..b10d0c3a 100644 --- a/include/global_ui.hpp +++ b/include/global_ui.hpp @@ -8,7 +8,6 @@ #include "widgets.hpp" -struct GLFWwindow; struct NVGcontext; @@ -31,7 +30,7 @@ struct Model; struct GlobalUI { struct { - GLFWwindow *gWindow; + void *lglw; // lglw_t NVGcontext *gVg; NVGcontext *gFramebufferVg; std::shared_ptr gGuiFont; @@ -92,28 +91,16 @@ struct GlobalUI { int bnd_font; } blendish; -#ifdef USE_VST2 - struct { - volatile int b_close_window; - volatile int b_hide_window; -#ifdef WIN32 - void *parent_hwnd; - bool b_queued_maximize_window; -#endif // WIN32 - } vst2; -#endif // USE_VST2 void init(void) { - window.gWindow = NULL; + + window.lglw = NULL; window.gVg = NULL; window.gFramebufferVg = NULL; window.gPixelRatio = 1.0; window.gWindowRatio = 1.0; -// #ifdef USE_VST2 -// window.gAllowCursorLock = false; -// #else window.gAllowCursorLock = true; -// #endif // USE_VST2 + window.gGuiFrame = 0; window.windowX = 0; window.windowY = 0; window.windowWidth = 0; @@ -143,15 +130,6 @@ struct GlobalUI { blendish.bnd_icon_image = -1; blendish.bnd_font = -1; - -#ifdef USE_VST2 - vst2.b_close_window = 0; - vst2.b_hide_window = 0; -#ifdef WIN32 - vst2.parent_hwnd = 0; - vst2.b_queued_maximize_window = false; -#endif -#endif // USE_VST2 } }; diff --git a/include/settings.hpp b/include/settings.hpp index 5f89d5a8..15822700 100644 --- a/include/settings.hpp +++ b/include/settings.hpp @@ -9,7 +9,7 @@ namespace rack { extern bool gSkipAutosaveOnLaunch; void settingsSave(std::string filename); -void settingsLoad(std::string filename); +void settingsLoad(std::string filename, bool bWindowSizeOnly); } // namespace rack diff --git a/include/window.hpp b/include/window.hpp index 7c9c56d7..040f32fe 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -2,7 +2,8 @@ #include "widgets.hpp" #define GLEW_STATIC #include -#include +////#include +#include #ifdef ARCH_MAC @@ -12,12 +13,19 @@ #endif +// backwards compatibility: +// (note) currently only used by Bidoo.ACNE module +#define RACK_MOUSE_BUTTON_LEFT 0 +#define RACK_MOUSE_BUTTON_RIGHT 1 +#define RACK_MOUSE_BUTTON_MIDDLE 2 + + extern const char *g_program_dir; namespace rack { -extern GLFWwindow *gWindow; +// extern GLFWwindow *gWindow; extern NVGcontext *gVg; extern NVGcontext *gFramebufferVg; /** The default font to use for GUI elements */ diff --git a/make.objects b/make.objects index acb919ef..c2f58a40 100644 --- a/make.objects +++ b/make.objects @@ -40,7 +40,6 @@ COMMON_OBJ= \ src/audio.o \ src/dsp/minblep.o \ src/engine.o \ - src/keyboard.o \ src/midi.o \ src/plugin.o \ src/settings.o \ @@ -83,6 +82,8 @@ COMMON_OBJ= \ src/window.o \ src/vstmidi.o +# src/keyboard.o + HOST_OBJ= \ src/Core/AudioInterface.o \ src/Core/Blank.o \ @@ -98,7 +99,8 @@ LIB_OBJ= \ $(HOST_OBJ) LIB_OBJ_WIN= \ - src/util/dirent_win32/dirent.o + src/util/dirent_win32/dirent.o \ + dep/lglw/lglw_windows.o SHARED_LIB_OBJ= \ $(COMMON_OBJ) diff --git a/makefile.msvc b/makefile.msvc index 0d22d26b..42ebd220 100644 --- a/makefile.msvc +++ b/makefile.msvc @@ -23,9 +23,9 @@ vst: lib rm -f src/vst2_main.o make -f makefile_vst_effect.msvc bin -j $(NUM_JOBS) # (note) cannot use both instrument and effect plugin at the same time! - mv veeseevstrack_instr.dll vst2_bin/veeseevstrack_instr.dll__ + mv veeseevstrack_instr.dll vst2_bin/ mv veeseevstrack_effect.dll vst2_bin/ - @ls -l vst2_bin/veeseevstrack_instr.dll__ + @ls -l vst2_bin/veeseevstrack_instr.dll @ls -l vst2_bin/veeseevstrack_effect.dll clean: diff --git a/makefile_lib.msvc b/makefile_lib.msvc index a54fc956..57169ddc 100644 --- a/makefile_lib.msvc +++ b/makefile_lib.msvc @@ -7,7 +7,8 @@ include dep/yac/install_msvc.mk TARGET_BASENAME=Rack -EXTRAFLAGS= -DVERSION=0.6.1 -DARCH_WIN -D_USE_MATH_DEFINES -DRACK_HOST -DUSE_VST2 -DVST2_REPARENT_WINDOW_HACK -Iinclude/ -Idep/include +EXTRAFLAGS= -DVERSION=0.6.1 -DARCH_WIN -D_USE_MATH_DEFINES -DRACK_HOST -DUSE_VST2 -Iinclude/ -Idep/include -Idep/ +#-DVST2_REPARENT_WINDOW_HACK ifeq ($(BUILD_64),y) EXTRALIBS= -LIBPATH:dep/lib/msvc/x64 diff --git a/plugins/build_plugin_pre.mk b/plugins/build_plugin_pre.mk index 508f5f32..22151090 100644 --- a/plugins/build_plugin_pre.mk +++ b/plugins/build_plugin_pre.mk @@ -7,7 +7,7 @@ include ../../../../dep/yac/install_msvc.mk TARGET_BASENAME=$(SLUG) -EXTRAFLAGS+= -DVERSION=0.6.1 -D_USE_MATH_DEFINES -DUSE_VST2 -DRACK_PLUGIN -DSLUG=$(SLUG) -I../../../../include/ -I../../../../dep/include -Idep/include +EXTRAFLAGS+= -DVERSION=0.6.1 -D_USE_MATH_DEFINES -DUSE_VST2 -DRACK_PLUGIN -DSLUG=$(SLUG) -I../../../../include/ -I../../../../dep/include -I../../../../dep/ -Idep/include EXTRAFLAGS+= EXTRALIBS+= diff --git a/plugins/community/repos/Bidoo/make.objects b/plugins/community/repos/Bidoo/make.objects index 37da3f0f..64ec7bee 100644 --- a/plugins/community/repos/Bidoo/make.objects +++ b/plugins/community/repos/Bidoo/make.objects @@ -23,8 +23,9 @@ ALL_OBJ= \ src/TOCANTE.o \ src/VOID.o \ src/ZINC.o \ - src/dep/kiss_fft130/kiss_fft.o \ - src/dep/minimp3/minimp3_test.o + src/dep/kiss_fft130/kiss_fft.o + +# src/dep/minimp3/minimp3_test.o # already used in AS modules diff --git a/plugins/community/repos/Bidoo/src/ACNE.cpp b/plugins/community/repos/Bidoo/src/ACNE.cpp index 4ce6983a..e8f6ddcf 100644 --- a/plugins/community/repos/Bidoo/src/ACNE.cpp +++ b/plugins/community/repos/Bidoo/src/ACNE.cpp @@ -227,7 +227,7 @@ struct ACNETrimPot : BidooColoredTrimpot { ACNEWidget *parent = dynamic_cast(this->parent); ACNE *module = dynamic_cast(this->module); if (parent && module) { - if ((e.button == GLFW_MOUSE_BUTTON_MIDDLE) || ((e.button == GLFW_MOUSE_BUTTON_LEFT) && (windowIsShiftPressed()))) { + if ((e.button == RACK_MOUSE_BUTTON_MIDDLE) || ((e.button == RACK_MOUSE_BUTTON_LEFT) && (windowIsShiftPressed()))) { this->setValue(10); module->snapshots[module->currentSnapshot][(int)((this->paramId - ACNE::FADERS_PARAMS)/ACNE_NB_TRACKS)][(this->paramId - ACNE::FADERS_PARAMS)%ACNE_NB_TRACKS] = 10; } diff --git a/plugins/community/repos/Template_shared/Template_shared.dll b/plugins/community/repos/Template_shared/Template_shared.dll new file mode 100644 index 00000000..9973762c Binary files /dev/null and b/plugins/community/repos/Template_shared/Template_shared.dll differ diff --git a/plugins/community/repos/Template_shared/makefile.msvc b/plugins/community/repos/Template_shared/makefile.msvc index 58b3fd3a..4c04b8d1 100644 --- a/plugins/community/repos/Template_shared/makefile.msvc +++ b/plugins/community/repos/Template_shared/makefile.msvc @@ -4,4 +4,8 @@ include ../../../build_shared_plugin_pre.mk include make.objects +define BIN_POST_FXN + cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll +endef + include ../../../build_shared_plugin_post.mk diff --git a/plugins/community/repos/dBiz/dBiz.dll b/plugins/community/repos/dBiz/dBiz.dll new file mode 100644 index 00000000..57408b1b Binary files /dev/null and b/plugins/community/repos/dBiz/dBiz.dll differ diff --git a/plugins/community/repos/dBiz/makefile.msvc b/plugins/community/repos/dBiz/makefile.msvc index 746ae96f..eaeb0380 100644 --- a/plugins/community/repos/dBiz/makefile.msvc +++ b/plugins/community/repos/dBiz/makefile.msvc @@ -4,4 +4,8 @@ include ../../../build_shared_plugin_pre.mk include make.objects +define BIN_POST_FXN + cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll +endef + include ../../../build_shared_plugin_post.mk diff --git a/plugins/community/repos/trowaSoft/src/TSTextField.cpp b/plugins/community/repos/trowaSoft/src/TSTextField.cpp index eab6c626..2b82c103 100644 --- a/plugins/community/repos/trowaSoft/src/TSTextField.cpp +++ b/plugins/community/repos/trowaSoft/src/TSTextField.cpp @@ -5,7 +5,7 @@ // for gVg #include "window.hpp" // for key codes -#include +// // #include #include "global_ui.hpp" using namespace rack; @@ -217,7 +217,7 @@ void TSTextField::onKey(EventKey &e) { //// Flag if we need to validate/cleanse this character (only if printable and if we are doing validation). //bool checkKey = (this->allowedTextType != TextType::Any) && isPrintableKey(e.key); switch (e.key) { - case GLFW_KEY_TAB: + case LGLW_VKEY_TAB/*GLFW_KEY_TAB*/: // If we have an event to fire, then do it if (windowIsShiftPressed())//(guiIsShiftPressed()) { @@ -297,13 +297,13 @@ void TSTextField::onKey(EventKey &e) { } } // end if next field break; - case GLFW_KEY_KP_ENTER: - { - // Key pad enter should also trigger event action - EventAction evt; - onAction(evt); - } - break; + // case GLFW_KEY_KP_ENTER: + // { + // // Key pad enter should also trigger event action + // EventAction evt; + // onAction(evt); + // } + // break; default: // Call base method TextField::onKey(e); @@ -324,58 +324,58 @@ bool isPrintableKey(int key) bool isPrintable = false; switch (key) { - case GLFW_KEY_SPACE: - case GLFW_KEY_APOSTROPHE: - case GLFW_KEY_COMMA: - case GLFW_KEY_MINUS: - case GLFW_KEY_PERIOD: - case GLFW_KEY_SLASH: - case GLFW_KEY_0: - case GLFW_KEY_1: - case GLFW_KEY_2: - case GLFW_KEY_3: - case GLFW_KEY_4: - case GLFW_KEY_5: - case GLFW_KEY_6: - case GLFW_KEY_7: - case GLFW_KEY_8: - case GLFW_KEY_9: - case GLFW_KEY_SEMICOLON: - case GLFW_KEY_EQUAL: - case GLFW_KEY_A: - case GLFW_KEY_B: - case GLFW_KEY_C: - case GLFW_KEY_D: - case GLFW_KEY_E: - case GLFW_KEY_F: - case GLFW_KEY_G: - case GLFW_KEY_H: - case GLFW_KEY_I: - case GLFW_KEY_J: - case GLFW_KEY_K: - case GLFW_KEY_L: - case GLFW_KEY_M: - case GLFW_KEY_N: - case GLFW_KEY_O: - case GLFW_KEY_P: - case GLFW_KEY_Q: - case GLFW_KEY_R: - case GLFW_KEY_S: - case GLFW_KEY_T: - case GLFW_KEY_U: - case GLFW_KEY_V: - case GLFW_KEY_W: - case GLFW_KEY_X: - case GLFW_KEY_Y: - case GLFW_KEY_Z: - case GLFW_KEY_LEFT_BRACKET: - case GLFW_KEY_BACKSLASH: - case GLFW_KEY_RIGHT_BRACKET: - case GLFW_KEY_GRAVE_ACCENT: - case GLFW_KEY_WORLD_1: - case GLFW_KEY_WORLD_2: - isPrintable = true; - break; + case ' '/*GLFW_KEY_SPACE*/: + case '\''/*GLFW_KEY_APOSTROPHE*/: + case ','/*GLFW_KEY_COMMA*/: + case '-'/*GLFW_KEY_MINUS*/: + case '.'/*GLFW_KEY_PERIOD*/: + case '/'/*GLFW_KEY_SLASH*/: + case '0'/*GLFW_KEY_0*/: + case '1'/*GLFW_KEY_1*/: + case '2'/*GLFW_KEY_2*/: + case '3'/*GLFW_KEY_3*/: + case '4'/*GLFW_KEY_4*/: + case '5'/*GLFW_KEY_5*/: + case '6'/*GLFW_KEY_6*/: + case '7'/*GLFW_KEY_7*/: + case '8'/*GLFW_KEY_8*/: + case '9'/*GLFW_KEY_9*/: + case ';'/*GLFW_KEY_SEMICOLON*/: + case '='/*GLFW_KEY_EQUAL*/: + case 'a'/*GLFW_KEY_A*/: + case 'b'/*GLFW_KEY_B*/: + case 'c'/*GLFW_KEY_C*/: + case 'd'/*GLFW_KEY_D*/: + case 'e'/*GLFW_KEY_E*/: + case 'f'/*GLFW_KEY_F*/: + case 'g'/*GLFW_KEY_G*/: + case 'h'/*GLFW_KEY_H*/: + case 'i'/*GLFW_KEY_I*/: + case 'j'/*GLFW_KEY_J*/: + case 'k'/*GLFW_KEY_K*/: + case 'l'/*GLFW_KEY_L*/: + case 'm'/*GLFW_KEY_M*/: + case 'n'/*GLFW_KEY_N*/: + case 'o'/*GLFW_KEY_O*/: + case 'p'/*GLFW_KEY_P*/: + case 'q'/*GLFW_KEY_Q*/: + case 'r'/*GLFW_KEY_R*/: + case 's'/*GLFW_KEY_S*/: + case 't'/*GLFW_KEY_T*/: + case 'u'/*GLFW_KEY_U*/: + case 'v'/*GLFW_KEY_V*/: + case 'w'/*GLFW_KEY_W*/: + case 'x'/*GLFW_KEY_X*/: + case 'y'/*GLFW_KEY_Y*/: + case 'z'/*GLFW_KEY_Z*/: + case '['/*GLFW_KEY_LEFT_BRACKET*/: + case '\\'/*GLFW_KEY_BACKSLASH*/: + case ']'/*GLFW_KEY_RIGHT_BRACKET*/: + case '^'/*GLFW_KEY_GRAVE_ACCENT*/: + // case GLFW_KEY_WORLD_1: + // case GLFW_KEY_WORLD_2: + isPrintable = true; + break; } return isPrintable; } // end isPrintableKey() diff --git a/src/Core/MIDICCToCVInterface.cpp b/src/Core/MIDICCToCVInterface.cpp index eb791a50..3580dd6a 100644 --- a/src/Core/MIDICCToCVInterface.cpp +++ b/src/Core/MIDICCToCVInterface.cpp @@ -166,7 +166,8 @@ struct MidiCcChoice : GridChoice { void onKey(EventKey &e) override { if (global_ui->widgets.gFocusedWidget == this) { - if (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) { + // if (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) { + if(LGLW_VKEY_RETURN == e.key) { EventDefocus eDefocus; onDefocus(eDefocus); global_ui->widgets.gFocusedWidget = NULL; diff --git a/src/app/ModuleBrowser.cpp b/src/app/ModuleBrowser.cpp index 8fc03918..6bfb93ad 100644 --- a/src/app/ModuleBrowser.cpp +++ b/src/app/ModuleBrowser.cpp @@ -497,32 +497,32 @@ void SearchModuleField::onTextChange() { void SearchModuleField::onKey(EventKey &e) { switch (e.key) { - case GLFW_KEY_ESCAPE: { + case LGLW_VKEY_ESCAPE/*GLFW_KEY_ESCAPE*/: { global_ui->ui.gScene->setOverlay(NULL); e.consumed = true; return; } break; - case GLFW_KEY_UP: { + case LGLW_VKEY_UP/*GLFW_KEY_UP*/: { moduleBrowser->moduleList->incrementSelection(-1); moduleBrowser->moduleList->scrollSelected(); e.consumed = true; } break; - case GLFW_KEY_DOWN: { + case LGLW_VKEY_DOWN/*GLFW_KEY_DOWN*/: { moduleBrowser->moduleList->incrementSelection(1); moduleBrowser->moduleList->scrollSelected(); e.consumed = true; } break; - case GLFW_KEY_PAGE_UP: { + case LGLW_VKEY_PAGEUP/*GLFW_KEY_PAGE_UP*/: { moduleBrowser->moduleList->incrementSelection(-5); moduleBrowser->moduleList->scrollSelected(); e.consumed = true; } break; - case GLFW_KEY_PAGE_DOWN: { + case LGLW_VKEY_PAGEDOWN/*GLFW_KEY_PAGE_DOWN*/: { moduleBrowser->moduleList->incrementSelection(5); moduleBrowser->moduleList->scrollSelected(); e.consumed = true; } break; - case GLFW_KEY_ENTER: { + case LGLW_VKEY_RETURN/*GLFW_KEY_ENTER*/: { BrowserListItem *item = moduleBrowser->moduleList->getSelectedItem(); if (item) { item->doAction(); diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 26564ee4..936b35dd 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -8,7 +8,7 @@ #ifdef USE_VST2 -extern "C" void glfw_hack_makeContextCurrent(GLFWwindow *handle); +// // extern "C" void glfw_hack_makeContextCurrent(GLFWwindow *handle); // #include #endif // USE_VST2 @@ -310,51 +310,81 @@ void ModuleWidget::onMouseDown(EventMouseDown &e) { void ModuleWidget::onMouseMove(EventMouseMove &e) { OpaqueWidget::onMouseMove(e); - // Don't delete the ModuleWidget if a TextField is focused - if (!global_ui->widgets.gFocusedWidget) { - // Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. - if (glfwGetKey(global_ui->window.gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { - if (!windowIsModPressed() && !windowIsShiftPressed()) { - global_ui->app.gRackWidget->deleteModule(this); - this->finalizeEvents(); - delete this; - e.consumed = true; - return; - } - } - } +// // #if 0 +// // // Don't delete the ModuleWidget if a TextField is focused +// // if (!global_ui->widgets.gFocusedWidget) { +// // // Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. +// // if (glfwGetKey(global_ui->window.gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { +// // if (!windowIsModPressed() && !windowIsShiftPressed()) { +// // global_ui->app.gRackWidget->deleteModule(this); +// // this->finalizeEvents(); +// // delete this; +// // e.consumed = true; +// // return; +// // } +// // } +// // } +// // #endif } void ModuleWidget::onHoverKey(EventHoverKey &e) { switch (e.key) { - case GLFW_KEY_I: { + + case 'i'/*GLFW_KEY_I*/: if (windowIsModPressed() && !windowIsShiftPressed()) { reset(); e.consumed = true; return; } - } break; - case GLFW_KEY_R: { + break; + + case 'r'/*GLFW_KEY_R*/: if (windowIsModPressed() && !windowIsShiftPressed()) { randomize(); e.consumed = true; return; } - } break; - case GLFW_KEY_D: { + break; + + case 'd'/*GLFW_KEY_D*/: if (windowIsModPressed() && !windowIsShiftPressed()) { global_ui->app.gRackWidget->cloneModule(this); e.consumed = true; return; } - } break; - case GLFW_KEY_U: { + break; + + case 'u'/*GLFW_KEY_U*/: if (windowIsModPressed() && !windowIsShiftPressed()) { disconnect(); e.consumed = true; return; } - } break; + break; + + case LGLW_VKEY_DELETE: + case LGLW_VKEY_BACKSPACE: + if (!global_ui->widgets.gFocusedWidget) { + if (!windowIsModPressed() && !windowIsShiftPressed()) { + global_ui->app.gRackWidget->deleteModule(this); + this->finalizeEvents(); + delete this; + e.consumed = true; + return; + } + } + break; + + case 'w': + if (windowIsModPressed() && !windowIsShiftPressed()) { + global_ui->app.gRackWidget->deleteModule(this); + this->finalizeEvents(); + delete this; + e.consumed = true; + return; + } + break; + } Widget::onHoverKey(e); diff --git a/src/app/RackScene.cpp b/src/app/RackScene.cpp index 7de7c551..fb6d0637 100644 --- a/src/app/RackScene.cpp +++ b/src/app/RackScene.cpp @@ -65,19 +65,19 @@ void RackScene::onHoverKey(EventHoverKey &e) { if (!e.consumed) { switch (e.key) { - case GLFW_KEY_N: { + case 'n'/*GLFW_KEY_N*/: if (windowIsModPressed() && !windowIsShiftPressed()) { global_ui->app.gRackWidget->reset(); e.consumed = true; } - } break; - case GLFW_KEY_Q: { + break; + case 'q'/*GLFW_KEY_Q*/: if (windowIsModPressed() && !windowIsShiftPressed()) { windowClose(); e.consumed = true; } - } break; - case GLFW_KEY_O: { + break; + case 'o'/*GLFW_KEY_O*/: if (windowIsModPressed() && !windowIsShiftPressed()) { global_ui->app.gRackWidget->openDialog(); e.consumed = true; @@ -86,8 +86,8 @@ void RackScene::onHoverKey(EventHoverKey &e) { global_ui->app.gRackWidget->revert(); e.consumed = true; } - } break; - case GLFW_KEY_S: { + break; + case 's'/*GLFW_KEY_S*/: if (windowIsModPressed() && !windowIsShiftPressed()) { global_ui->app.gRackWidget->saveDialog(); e.consumed = true; @@ -96,15 +96,15 @@ void RackScene::onHoverKey(EventHoverKey &e) { global_ui->app.gRackWidget->saveAsDialog(); e.consumed = true; } - } break; - case GLFW_KEY_ENTER: - case GLFW_KEY_KP_ENTER: { + break; + case LGLW_VKEY_RETURN/*GLFW_KEY_ENTER*/: + // case GLFW_KEY_KP_ENTER: appModuleBrowserCreate(); e.consumed = true; - } break; - case GLFW_KEY_F11: { + break; + case LGLW_VKEY_F11/*GLFW_KEY_F11*/: windowSetFullScreen(!windowGetFullScreen()); - } + break; } } } diff --git a/src/main.cpp b/src/main.cpp index 7ec4b116..3ef19b25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,16 +21,12 @@ #include "global.hpp" #include "global_ui.hpp" -// #if defined(YAC_WIN32) && defined(VST2_REPARENT_WINDOW_HACK) -// #include -// extern "C" extern HWND __hack__glfwGetHWND (GLFWwindow *window); -// #endif - using namespace rack; -/*__declspec(dllexport) won't link*/ YAC_TLS rack::Global *rack::global; -/*__declspec(dllexport) won't link*/ YAC_TLS rack::GlobalUI *rack::global_ui; +YAC_TLS rack::Global *rack::global; +YAC_TLS rack::GlobalUI *rack::global_ui; + #ifdef USE_VST2 int vst2_init(int argc, char* argv[]) { @@ -74,12 +70,13 @@ int vst2_init(int argc, char* argv[]) { bridgeInit(); #endif // USE_VST2 vstmidiInit(); - keyboardInit(); #ifndef USE_VST2 + keyboardInit(); gamepadInit(); - windowInit(); // must be done in vst2 ui thread #endif // USE_VST2 + windowInit(); appInit(devMode); + settingsLoad(assetLocal("settings.json"), false/*bWindowSizeOnly*/); #if 0 if (patchFile.empty()) { @@ -108,20 +105,6 @@ int vst2_init(int argc, char* argv[]) { return 0; } -void vst2_editor_create(void) { - windowInit(); - settingsLoad(assetLocal("settings.json")); - glfwHideWindow(rack::global_ui->window.gWindow); -} - -void vst2_editor_destroy(void) { - windowDestroy(); -} - -void vst2_editor_loop(void) { - windowRun(); -} - void vst2_exit(void) { // Destroy namespaces // // engineStop(); @@ -129,26 +112,36 @@ void vst2_exit(void) { // global_ui->app.gRackWidget->savePatch(assetLocal("autosave.vcv")); // settingsSave(assetLocal("settings.json")); printf("xxx vst2_exit 2\n"); -#if 0 // (note) setting this to 1 seems to work fine (and it fixes the obvious mem leaks) + +#if 1 + lglw_glcontext_push(global_ui->window.lglw); appDestroy(); + lglw_glcontext_pop(global_ui->window.lglw); +#endif + printf("xxx vst2_exit 3\n"); + windowDestroy(); + +#if 0 #ifndef USE_VST2 - windowDestroy(); bridgeDestroy(); #endif // USE_VST2 printf("xxx vst2_exit 4\n"); engineDestroy(); printf("xxx vst2_exit 5\n"); #endif + printf("xxx vst2_exit destroy midi\n"); midiDestroy(); printf("xxx vst2_exit destroy midi done\n"); -#if 0 + +#if 1 printf("xxx vst2_exit 6\n"); pluginDestroy(); printf("xxx vst2_exit 7\n"); loggerDestroy(); #endif + printf("xxx vst2_exit 8 (leave)\n"); } diff --git a/src/settings.cpp b/src/settings.cpp index d6251607..a505f3b6 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -9,6 +9,8 @@ #include "global_ui.hpp" +extern void vst2_window_size_set (int _width, int _height); + namespace rack { @@ -76,7 +78,7 @@ static json_t *settingsToJson() { return rootJ; } -static void settingsFromJson(json_t *rootJ) { +static void settingsFromJson(json_t *rootJ, bool bWindowSizeOnly) { // token json_t *tokenJ = json_object_get(rootJ, "token"); if (tokenJ) @@ -89,6 +91,13 @@ static void settingsFromJson(json_t *rootJ) { json_unpack(windowSizeJ, "[F, F]", &width, &height); #ifdef USE_VST2 // (note) calling windowSetWindowSize() causes the window to be not resizable initially, and when it is moved, it reverts to a default size (TBI) + if(bWindowSizeOnly) + { + global_ui->window.windowWidth = int(width); + global_ui->window.windowHeight = int(height); + vst2_window_size_set((int)width, (int)height); + return; + } #else windowSetWindowSize(Vec(width, height)); #endif // USE_VST2 @@ -181,7 +190,7 @@ void settingsSave(std::string filename) { } } -void settingsLoad(std::string filename) { +void settingsLoad(std::string filename, bool bWindowSizeOnly) { info("Loading settings %s", filename.c_str()); FILE *file = fopen(filename.c_str(), "r"); if (!file) @@ -190,7 +199,7 @@ void settingsLoad(std::string filename) { json_error_t error; json_t *rootJ = json_loadf(file, 0, &error); if (rootJ) { - settingsFromJson(rootJ); + settingsFromJson(rootJ, bWindowSizeOnly); json_decref(rootJ); } else { diff --git a/src/ui/MenuOverlay.cpp b/src/ui/MenuOverlay.cpp index 275b0e13..607c29fd 100644 --- a/src/ui/MenuOverlay.cpp +++ b/src/ui/MenuOverlay.cpp @@ -27,11 +27,13 @@ void MenuOverlay::onMouseDown(EventMouseDown &e) { void MenuOverlay::onHoverKey(EventHoverKey &e) { switch (e.key) { - case GLFW_KEY_ESCAPE: { + default: + break; + + case LGLW_VKEY_ESCAPE/*GLFW_KEY_ESCAPE*/: global_ui->ui.gScene->setOverlay(NULL); e.consumed = true; return; - } break; } if (!e.consumed) { diff --git a/src/ui/ScrollWidget.cpp b/src/ui/ScrollWidget.cpp index 65507a37..269566da 100644 --- a/src/ui/ScrollWidget.cpp +++ b/src/ui/ScrollWidget.cpp @@ -111,6 +111,7 @@ void ScrollWidget::step() { void ScrollWidget::onMouseMove(EventMouseMove &e) { // Scroll with arrow keys +#if 0 if (!global_ui->widgets.gFocusedWidget) { float arrowSpeed = 30.0; if (windowIsShiftPressed() && windowIsModPressed()) @@ -133,7 +134,7 @@ void ScrollWidget::onMouseMove(EventMouseMove &e) { offset.y += arrowSpeed; } } - +#endif Widget::onMouseMove(e); } diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp index 6a607964..eeeafec0 100644 --- a/src/ui/TextField.cpp +++ b/src/ui/TextField.cpp @@ -63,7 +63,8 @@ void TextField::onText(EventText &e) { void TextField::onKey(EventKey &e) { switch (e.key) { - case GLFW_KEY_BACKSPACE: { + + case LGLW_VKEY_BACKSPACE/*GLFW_KEY_BACKSPACE*/: if (cursor == selection) { cursor--; if (cursor >= 0) { @@ -78,8 +79,9 @@ void TextField::onKey(EventKey &e) { onTextChange(); cursor = selection = begin; } - } break; - case GLFW_KEY_DELETE: { + break; + + case LGLW_VKEY_DELETE/*GLFW_KEY_DELETE*/: if (cursor == selection) { text.erase(cursor, 1); onTextChange(); @@ -90,8 +92,9 @@ void TextField::onKey(EventKey &e) { onTextChange(); cursor = selection = begin; } - } break; - case GLFW_KEY_LEFT: { + break; + + case LGLW_VKEY_LEFT/*GLFW_KEY_LEFT*/: if (windowIsModPressed()) { while (--cursor > 0) { if (text[cursor] == ' ') @@ -104,8 +107,9 @@ void TextField::onKey(EventKey &e) { if (!windowIsShiftPressed()) { selection = cursor; } - } break; - case GLFW_KEY_RIGHT: { + break; + + case LGLW_VKEY_RIGHT/*GLFW_KEY_RIGHT*/: if (windowIsModPressed()) { while (++cursor < (int) text.size()) { if (text[cursor] == ' ') @@ -118,21 +122,28 @@ void TextField::onKey(EventKey &e) { if (!windowIsShiftPressed()) { selection = cursor; } - } break; - case GLFW_KEY_HOME: { + break; + + case LGLW_VKEY_HOME/*GLFW_KEY_HOME*/: selection = cursor = 0; - } break; - case GLFW_KEY_END: { + break; + + case LGLW_VKEY_END/*GLFW_KEY_END*/: selection = cursor = text.size(); - } break; - case GLFW_KEY_V: { + break; + + case 'v'/*GLFW_KEY_V*/: +#if 0 if (windowIsModPressed()) { const char *newText = glfwGetClipboardString(global_ui->window.gWindow); if (newText) insertText(newText); } - } break; - case GLFW_KEY_X: { +#endif + break; + + case 'x'/*GLFW_KEY_X*/: +#if 0 if (windowIsModPressed()) { if (cursor != selection) { int begin = min(cursor, selection); @@ -141,8 +152,11 @@ void TextField::onKey(EventKey &e) { insertText(""); } } - } break; - case GLFW_KEY_C: { +#endif + break; + + case 'c'/*GLFW_KEY_C*/: +#if 0 if (windowIsModPressed()) { if (cursor != selection) { int begin = min(cursor, selection); @@ -150,14 +164,18 @@ void TextField::onKey(EventKey &e) { glfwSetClipboardString(global_ui->window.gWindow, selectedText.c_str()); } } - } break; - case GLFW_KEY_A: { +#endif + break; + + case 'a'/*GLFW_KEY_A*/: if (windowIsModPressed()) { selection = 0; cursor = text.size(); } - } break; - case GLFW_KEY_ENTER: { + break; + + case LGLW_VKEY_RETURN/*GLFW_KEY_ENTER*/: + // printf("xxx TextField::onKey: RETURN\n"); if (multiline) { insertText("\n"); } @@ -165,7 +183,7 @@ void TextField::onKey(EventKey &e) { EventAction e; onAction(e); } - } break; + break; } cursor = clamp(cursor, 0, (int) text.size()); diff --git a/src/vst2_main.cpp b/src/vst2_main.cpp index c589d2c3..d1a78407 100644 --- a/src/vst2_main.cpp +++ b/src/vst2_main.cpp @@ -17,7 +17,7 @@ /// /// created: 25Jun2018 /// changed: 26Jun2018, 27Jun2018, 29Jun2018, 01Jul2018, 02Jul2018, 06Jul2018, 13Jul2018 -/// 26Jul2018 +/// 26Jul2018, 04Aug2018, 05Aug2018 /// /// /// @@ -45,11 +45,16 @@ YAC_Host *yac_host; // not actually used, just to satisfy the linker #include "global.hpp" #include "global_ui.hpp" +#define EDITWIN_X 0 +#define EDITWIN_Y 0 +#define EDITWIN_W 1200 +#define EDITWIN_H 800 + extern int vst2_init (int argc, char* argv[]); extern void vst2_exit (void); -extern void vst2_editor_create (void); -extern void vst2_editor_loop (void); -extern void vst2_editor_destroy (void); +namespace rack { +extern void vst2_editor_redraw (void); +} extern void vst2_set_samplerate (sF32 _rate); extern void vst2_engine_process (float *const*_in, float **_out, unsigned int _numFrames); extern void vst2_process_midi_input_event (sU8 _a, sU8 _b, sU8 _c); @@ -59,6 +64,10 @@ extern float vst2_get_param (int uniqueParamId); extern void vst2_get_param_name (int uniqueParamId, char *s, int sMaxLen); extern void vst2_set_shared_plugin_tls_globals (void); +namespace rack { + extern void settingsLoad(std::string filename, bool bWindowSizeOnly); +} + #include "../include/window.hpp" #include "../dep/include/osdialog.h" @@ -76,9 +85,6 @@ extern void vst2_set_shared_plugin_tls_globals (void); EXTERN_C IMAGE_DOS_HEADER __ImageBase; -extern "C" extern HWND g_glfw_vst2_parent_hwnd; // read by modified version of GLFW (see glfw/src/win32_window.c) -extern "C" extern HWND __hack__glfwGetHWND (GLFWwindow *window); - // Windows: #define VST_EXPORT extern "C" __declspec(dllexport) @@ -378,7 +384,7 @@ const VstInt32 PLUGIN_VERSION = 1000; */ class VSTPluginWrapper { public: - static const uint32_t MIN_SAMPLE_RATE = 8192u; // (note) cannot be float in C++ + static const uint32_t MIN_SAMPLE_RATE = 8192u; static const uint32_t MAX_SAMPLE_RATE = 384000u; static const uint32_t MIN_BLOCK_SIZE = 64u; static const uint32_t MAX_BLOCK_SIZE = 65536u; @@ -404,38 +410,13 @@ public: bool b_processing; // true=generate output, false=suspended ERect editor_rect; + sBool b_editor_open; char *last_program_chunk_str; static sSI instance_count; sSI instance_id; - // // sU8 glfw_internal[64*1024]; // far larger than it needs to be, must be >=sizeof(_GLFWlibrary) - -public: -#ifdef YAC_LINUX - pthread_t pthread_id; -#endif -#ifdef YAC_WIN32 - HANDLE hThread; - DWORD dwThreadId; -#endif - sBool b_thread_created; - volatile sBool b_thread_started; - volatile sBool b_thread_running; - volatile sBool b_thread_done; - - volatile sBool b_queued_open_editor; - volatile sBool b_queued_destroy_editor; - volatile sBool b_editor_open; - volatile sBool b_editor_created; - - struct { - volatile uint32_t size; - volatile uint8_t *addr; - volatile bool b_ret; - } queued_load_patch; - sF32 tmp_input_buffers[NUM_INPUTS * MAX_BLOCK_SIZE]; public: @@ -454,13 +435,9 @@ public: return &_vstPlugin; } - void startUIThread (void); - void stopUIThread (void); - void setGlobals(void) { rack::global = &rack_global; rack::global_ui = &rack_global_ui; - // // glfwSetInstance((void*)glfw_internal); } sSI openEffect(void) { @@ -468,16 +445,6 @@ public: printf("xxx vstrack_plugin::openEffect\n"); // (todo) use mutex - - if(1 == instance_count) - { - int err = glfwInit(); - if (err != GLFW_TRUE) { - osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Could not initialize GLFW."); - return 0; - } - } - instance_id = instance_count; printf("xxx vstrack_plugin::openEffect: instance_id=%d\n", instance_id); @@ -494,7 +461,6 @@ public: rack_global.init(); rack_global_ui.init(); rack::global->vst2.last_seen_instance_count = instance_count; - // // ::memset((void*)glfw_internal, 0, sizeof(glfw_internal)); char oldCWD[1024]; char dllnameraw[1024]; @@ -518,24 +484,56 @@ public: (void)vst2_init(argc, argv); printf("xxx vstrack_plugin::openEffect: vst2_init() done\n"); - queued_load_patch.size = 0u; - queued_load_patch.addr = NULL; - queued_load_patch.b_ret = false; - - startUIThread(); + vst2_set_shared_plugin_tls_globals(); printf("xxx vstrack_plugin::openEffect: restore cwd=\"%s\"\n", oldCWD); ::SetCurrentDirectory(oldCWD); setSampleRate(sample_rate); - b_open = 1; + b_open = true; + b_editor_open = false; + printf("xxx vstrack_plugin::openEffect: LEAVE\n"); return 1; } + void setWindowSize(int _width, int _height) { + if(_width < 640) + _width = 640; + if(_height < 480) + _height = 480; + + editor_rect.right = EDITWIN_X + _width; + editor_rect.bottom = EDITWIN_Y + _height; + } + + void openEditor(void *_hwnd) { + printf("xxx vstrack_plugin: openEditor() parentHWND=%p\n", _hwnd); + setGlobals(); + (void)lglw_window_open(rack_global_ui.window.lglw, + _hwnd, + 0/*x*/, 0/*y*/, + (editor_rect.right - editor_rect.left), + (editor_rect.bottom - editor_rect.top) + ); + b_editor_open = true; + } + + void closeEditor(void) { + printf("xxx vstrack_plugin: closeEditor() b_editor_open=%d\n", b_editor_open); + if(b_editor_open) + { + setGlobals(); + lglw_window_close(rack_global_ui.window.lglw); + b_editor_open = false; + } + } + void closeEffect(void) { + closeEditor(); + // (todo) use mutex printf("xxx vstrack_plugin::closeEffect: last_program_chunk_str=%p\n", last_program_chunk_str); if(NULL != last_program_chunk_str) @@ -548,32 +546,17 @@ public: if(b_open) { - b_open = 0; + b_open = false; setGlobals(); rack::global->vst2.last_seen_instance_count = instance_count; - b_queued_destroy_editor = true; - rack::global_ui->vst2.b_close_window = 1; - while(b_queued_destroy_editor) - { - printf("[dbg] vstrack_plugin: wait until editor's been destroyed\n"); - sleepMillisecs(100); // (todo) condition - } - - stopUIThread(); - printf("xxx vstrack_plugin: call vst2_exit()\n"); vst2_exit(); printf("xxx vstrack_plugin: vst2_exit() done\n"); - if(1 == instance_count) - { - glfwTerminate(); - } - #ifdef USE_CONSOLE // FreeConsole(); #endif // USE_CONSOLE @@ -581,54 +564,6 @@ public: } -#ifdef YAC_WIN32 - void openEditor(HWND _hwnd) { - //g_glfw_vst2_parent_hwnd = _hwnd; - g_glfw_vst2_parent_hwnd = 0; -#else -#error implement me (openEditor) -#endif - printf("xxx vstrack_plugin: openEditor()\n"); - b_queued_open_editor = true; - -#ifdef YAC_WIN32 - rack::global_ui->vst2.parent_hwnd = (void*)_hwnd; - printf("xxx vstrack_plugin: DAW parent hwnd=%p\n", rack::global_ui->vst2.parent_hwnd); -#endif // YAC_WIN32 - - int iter = 0; - while(iter++ < 50) - { - if(b_editor_open) - break; - sleepMillisecs(100); // (todo) condition - } - - if(100 == iter) - printf("xxx vstrack_plugin: failed to show editor after %d milliseconds!!\n", (iter*100)); - else - printf("xxx vstrack_plugin: editor opened after %d milliseconds\n", (iter*100)); - // // vst2_show_editor(); - } - - void hideEditor(void) { - printf("xxx vstrack_plugin: hideEditor() b_editor_open=%d\n", b_editor_open); - if(b_editor_open) - { - setGlobals(); - rack::global_ui->vst2.b_hide_window = 1; - } - } - - void closeEditor(void) { - printf("xxx vstrack_plugin: closeEditor() b_editor_open=%d\n", b_editor_open); - if(b_editor_open) - { - setGlobals(); - rack::global_ui->vst2.b_close_window = 1; - } - } - void lockAudio(void) { mtx_audio.lock(); } @@ -686,7 +621,7 @@ public: return 0; } - sUI getProgramChunk(uint8_t **_addr) { + sUI getProgramChunk(uint8_t**_addr) { setGlobals(); if(NULL != last_program_chunk_str) { @@ -696,61 +631,29 @@ public: if(NULL != last_program_chunk_str) { *_addr = (uint8_t*)last_program_chunk_str; - return strlen(last_program_chunk_str) + 1/*ASCIIZ*/; + return (sUI)strlen(last_program_chunk_str) + 1/*ASCIIZ*/; } return 0; } - bool setBankChunk(size_t _size, uint8_t*_addr) { + bool setBankChunk(size_t _size, uint8_t *_addr) { bool r = false; return r; } - bool setProgramChunk_Async(size_t _size, uint8_t*_addr) { - bool r = false; + bool setProgramChunk(size_t _size, uint8_t *_addr) { setGlobals(); - - if(NULL != _addr) - { - queued_load_patch.b_ret = false; - queued_load_patch.size = _size; - queued_load_patch.addr = _addr; // triggers loader in UI thread - - int iter = 0; - for(;;) - { - if(NULL == queued_load_patch.addr) - { - queued_load_patch.b_ret = r; - break; - } - else if(++iter > 500) - { - printf("[---] vstrack_plugin:queueSetProgramChunk: timeout while waiting for UI thread.\n"); - break; - } - sleepMillisecs(10); - } - } - return r; - } - - void handleSetQueuedProgramChunk(void) { - if(NULL != queued_load_patch.addr) - { - setGlobals(); - lockAudio(); + lockAudio(); #if 0 - printf("xxx vstrack_plugin:setProgramChunk: size=%u str=\n-------------------%s\n------------------\n", queued_load_patch.size, (const char*)queued_load_patch.addr); -#else - printf("xxx vstrack_plugin:setProgramChunk: size=%u\n", queued_load_patch.size); + printf("xxx vstrack_plugin:setProgramChunk: size=%u\n", _size); #endif - bool r = rack::global_ui->app.gRackWidget->loadPatchFromString((const char*)queued_load_patch.addr); - printf("xxx vstrack_plugin:setProgramChunk: r=%d\n", r); - queued_load_patch.b_ret = r; - queued_load_patch.addr = NULL; - unlockAudio(); - } + lglw_glcontext_push(rack::global_ui->window.lglw); + bool r = rack::global_ui->app.gRackWidget->loadPatchFromString((const char*)_addr); + rack::global_ui->ui.gScene->step(); // w/o this the patch is bypassed + lglw_glcontext_pop(rack::global_ui->window.lglw); + printf("xxx vstrack_plugin:setProgramChunk: r=%d\n", r); + unlockAudio(); + return r; } #ifdef HAVE_WINDOWS @@ -799,7 +702,7 @@ public: if(0 != (timeInfo->flags & kVstPpqPosValid)) { - *_retSongPosPPQ = timeInfo->ppqPos; + *_retSongPosPPQ = (float)timeInfo->ppqPos; } } } @@ -816,171 +719,6 @@ private: sSI VSTPluginWrapper::instance_count = 0; -#ifdef YAC_LINUX -static void *vst2_ui_thread_entry(VSTPluginWrapper *_wrapper) { -#elif defined(YAC_WIN32) -static DWORD WINAPI vst2_ui_thread_entry(VSTPluginWrapper *_wrapper) { -#endif - - printf("xxx vstrack_plugin: UI thread started\n"); - _wrapper->setGlobals(); - printf("xxx vstrack_plugin: global=%p global_ui=%p\n", rack::global, rack::global_ui); - - printf("xxx vstrack_plugin: call vst2_editor_create()\n"); - _wrapper->lockAudio(); - vst2_editor_create(); - printf("xxx vstrack_plugin: vst2_editor_create() done\n"); - _wrapper->b_editor_created = YAC_TRUE; - _wrapper->unlockAudio(); - - _wrapper->b_thread_started = YAC_TRUE; - - vst2_set_shared_plugin_tls_globals(); - - while(_wrapper->b_thread_running || _wrapper->b_queued_destroy_editor || _wrapper->queued_load_patch.addr) - { - // printf("xxx vstrack_plugin: idle loop\n"); - if(_wrapper->b_queued_open_editor && !_wrapper->b_editor_open) - { - if(!_wrapper->b_editor_created) - { - } - - _wrapper->b_queued_open_editor = YAC_FALSE; - - // Show previously hidden window -#if defined(YAC_WIN32) && defined(VST2_REPARENT_WINDOW_HACK) -#if 0 - HWND glfwHWND = __hack__glfwGetHWND(rack::global_ui->window.gWindow); - ::SetParent(glfwHWND, - (HWND)rack::global_ui->vst2.parent_hwnd - ); - printf("xxx vstrack: SetParent(glfwHWND=%p, dawParentHWND=%p)\n", (void*)glfwHWND, rack::global_ui->vst2.parent_hwnd); -#endif -#endif // YAC_WIN32 - - glfwShowWindow(rack::global_ui->window.gWindow); - -#ifdef VST2_REPARENT_WINDOW_HACK - // maximize window once it starts to receive events (see window.cpp) - rack::global_ui->vst2.b_queued_maximize_window = true; -#endif // VST2_REPARENT_WINDOW_HACK - - _wrapper->b_editor_open = YAC_TRUE; - - rack::global_ui->vst2.b_close_window = 0; - printf("xxx vstrack_plugin[%d]: entering editor_loop\n", _wrapper->instance_id); - vst2_editor_loop(); // sets b_editor_open=true and b_queued_open_editor=false (must be delayed until window is actually visible or window create/focus tracking will not work) - _wrapper->b_editor_open = YAC_FALSE; - printf("xxx vstrack_plugin[%d]: editor_loop finished\n", _wrapper->instance_id); - // if(!_wrapper->b_window_created) - // { - // ShowUIWindow(); - // use metahost_onTimer for SDL.onTimer; - // b_window_created = true; - - // trace "[dbg] eureka: entering eventloop 2"; - // b_editor_open = true; - // UI.Run(); - // } - } - else if(_wrapper->b_queued_destroy_editor) - { - printf("xxx vstrack: _wrapper->b_queued_destroy_editor is 1, b_editor_created=%d\n", _wrapper->b_editor_created); - if(_wrapper->b_editor_created) - { -#if 0 -#if defined(YAC_WIN32) && defined(VST2_REPARENT_WINDOW_HACK) - ::SetParent(__hack__glfwGetHWND(rack::global_ui->window.gWindow), NULL); // [bsp 04Jul2018] reparent hack (fix hang up when DAW editor is closed) -#endif // VST2_REPARENT_WINDOW_HACK -#endif - vst2_editor_destroy(); - _wrapper->b_editor_created = YAC_FALSE; - } - _wrapper->b_queued_destroy_editor = YAC_FALSE; - } - else if(NULL != _wrapper->queued_load_patch.addr) - { - _wrapper->handleSetQueuedProgramChunk(); - } - else - { - _wrapper->sleepMillisecs(100); - } - } - - printf("xxx vstrack_plugin: UI thread finished\n"); - _wrapper->b_thread_done = YAC_TRUE; - return 0; -} - -void VSTPluginWrapper::startUIThread(void) { - b_queued_open_editor = false; - b_queued_destroy_editor = false; - b_editor_open = false; - b_editor_created = false; - queued_load_patch.b_ret = false; - queued_load_patch.size = 0u; - queued_load_patch.addr = NULL; - - b_thread_created = YAC_FALSE; - b_thread_running = YAC_TRUE; - b_thread_done = YAC_FALSE; - -#ifdef YAC_LINUX - b_thread_created = (pthread_create( &pthread_id, NULL, vst2_ui_thread_entry, (void*) this ) == 0); - - if(b_thread_created) - { - /* wait for lwp_id field to become valid */ - while(!b_thread_started) - { - pthread_yield(); - } - } -#endif // YAC_POSIX - -#ifdef YAC_WIN32 - hThread = CreateThread( - NULL, // default security attributes - 0, // use default stack size - (LPTHREAD_START_ROUTINE)vst2_ui_thread_entry,// thread function - (LPVOID)this, // argument to thread function - 0, // use default creation flags - &dwThreadId); // returns the thread identifier - b_thread_created = (hThread != NULL); - - while(!b_thread_started) - sleepMillisecs(10); // (todo) use condition - -#endif -} - -void VSTPluginWrapper::stopUIThread(void) { - b_thread_running = YAC_FALSE; - - while(!b_thread_done) - { - sleepMillisecs(10); // (todo) use condition - } - -#ifdef YAC_LINUX - ///pthread_join( pthread_id, NULL); - pthread_detach( pthread_id ); - pthread_cancel( pthread_id ); - pthread_id = 0; -#endif - -#ifdef YAC_WIN32 - SuspendThread( hThread ); - TerminateThread( hThread, 10 ); // 10 = exit code - WaitForMultipleObjects(1, &hThread, TRUE, 5000 /*INFINITE*/); // wait max. 5sec - CloseHandle(hThread); - hThread = NULL; -#endif - -} - /******************************************* * Callbacks: Host -> Plugin @@ -1022,7 +760,6 @@ void VSTPluginProcessReplacingFloat32(VSTPlugin *vstPlugin, //printf("xxx vstrack_plugin: VSTPluginProcessReplacingFloat32: wrapper=%p\n", wrapper); sUI chIdx; - sUI i; // (note) Cubase (tested with 9.5.30) uses the same buffer(s) for both input&output // => back up the inputs before clearing the outputs @@ -1061,46 +798,6 @@ void VSTPluginProcessReplacingFloat32(VSTPlugin *vstPlugin, } -#if 0 -/** - * This is the callback that will be called to process the samples in the case of double precision. This is where the - * meat of the logic happens! - * - * @param vstPlugin the object returned by VSTPluginMain - * @param inputs an array of array of input samples. You read from it. First dimension is for inputs, second dimension is for samples: inputs[numInputs][sampleFrames] - * @param outputs an array of array of output samples. You write to it. First dimension is for outputs, second dimension is for samples: outputs[numOuputs][sampleFrames] - * @param sampleFrames the number of samples (second dimension in both arrays) - */ -void VSTPluginProcessReplacingFloat64(VSTPlugin *vstPlugin, - double **inputs, - double **outputs, - VstInt32 sampleFrames - ) { - // we can get a hold to our C++ class since we stored it in the `object` field (see constructor) - VSTPluginWrapper *wrapper = static_cast(vstPlugin->object); - - wrapper->lockAudio(); - - if(wrapper->b_processing) - { - // code speaks for itself: for each input (2 when stereo input), iterating over every sample and writing the - // result in the outputs array after multiplying by 0.5 (which result in a 3dB attenuation of the sound) - for(int i = 0; i < wrapper->getNumInputs(); i++) - { - auto inputSamples = inputs[i]; - auto outputSamples = outputs[i]; - - for(int j = 0; j < sampleFrames; j++) - { - outputSamples[j] = inputSamples[j] * 0.5; - } - } - } - - wrapper->unlockAudio(); -} -#endif // 0 - /** * This is the plugin called by the host to communicate with the plugin, mainly to request information (like the @@ -1297,14 +994,14 @@ VstIntPtr VSTPluginDispatcher(VSTPlugin *vstPlugin, // ptr: buffer address // r: buffer size printf("xxx effGetChunk index=%d ptr=%p\n", index, ptr); - // if(0 == index) - // { - // r = wrapper->getBankChunk((uint8_t**)ptr); - // } - // else - // { + // // if(0 == index) + // // { + // // r = wrapper->getBankChunk((uint8_t**)ptr); + // // } + // // else + // // { r = wrapper->getProgramChunk((uint8_t**)ptr); - // } + // // } break; case effSetChunk: @@ -1313,14 +1010,14 @@ VstIntPtr VSTPluginDispatcher(VSTPlugin *vstPlugin, // ptr: buffer address // r: 1 printf("xxx effSetChunk index=%d size=%lld ptr=%p\n", index, value, ptr); - // if(0 == index) - // { - // r = wrapper->setBankChunk(size_t(value), (uint8_t*)ptr) ? 1 : 0; - // } - // else - // { - r = wrapper->setProgramChunk_Async(size_t(value), (uint8_t*)ptr) ? 1 : 0; - // } + // // if(0 == index) + // // { + // // r = wrapper->setBankChunk(size_t(value), (uint8_t*)ptr) ? 1 : 0; + // // } + // // else + // // { + r = wrapper->setProgramChunk(size_t(value), (uint8_t*)ptr) ? 1 : 0; + // // } break; case effShellGetNextPlugin: @@ -1431,6 +1128,19 @@ VstIntPtr VSTPluginDispatcher(VSTPlugin *vstPlugin, #endif case effEditIdle: + wrapper->setGlobals(); + if(lglw_window_is_visible(rack::global_ui->window.lglw)) + { + vst2_set_shared_plugin_tls_globals(); + + // Save DAW GL context and bind our own + lglw_glcontext_push(rack::global_ui->window.lglw); + + rack::vst2_editor_redraw(); + + // Restore the DAW's GL context + lglw_glcontext_pop(rack::global_ui->window.lglw); + } break; case effEditGetRect: @@ -1439,16 +1149,6 @@ VstIntPtr VSTPluginDispatcher(VSTPlugin *vstPlugin, if(NULL != ptr) // yeah, this should never be NULL { // ... -#define EDITWIN_X 20 -#define EDITWIN_Y 20 -// #define EDITWIN_W 1200 -// #define EDITWIN_H 800 -#define EDITWIN_W 60 -#define EDITWIN_H 21 - wrapper->editor_rect.left = EDITWIN_X; - wrapper->editor_rect.top = EDITWIN_Y; - wrapper->editor_rect.right = EDITWIN_X + EDITWIN_W; - wrapper->editor_rect.bottom = EDITWIN_Y + EDITWIN_H; *(void**)ptr = (void*) &wrapper->editor_rect; r = 1; } @@ -1468,16 +1168,13 @@ VstIntPtr VSTPluginDispatcher(VSTPlugin *vstPlugin, case effEditOpen: // Show editor window // ptr: native window handle (hWnd on Windows) -#ifdef YAC_WIN32 - wrapper->openEditor((HWND)ptr); -#endif + wrapper->openEditor(ptr); r = 1; break; case effEditClose: - // Hide editor window - // // wrapper->closeEditor(); - wrapper->hideEditor(); + // Close editor window + wrapper->closeEditor(); r = 1; break; @@ -1563,7 +1260,7 @@ VSTPluginWrapper::VSTPluginWrapper(audioMasterCallback vstHostCallback, effFlagsIsSynth | #endif effFlagsCanReplacing | - (effFlagsCanDoubleReplacing & 0) | + // (effFlagsCanDoubleReplacing & 0) | effFlagsProgramChunks | effFlagsHasEditor ; @@ -1592,8 +1289,12 @@ VSTPluginWrapper::VSTPluginWrapper(audioMasterCallback vstHostCallback, last_program_chunk_str = NULL; b_open = false; + b_editor_open = false; - // script_context = NULL; + editor_rect.left = EDITWIN_X; + editor_rect.top = EDITWIN_Y; + editor_rect.right = EDITWIN_X + EDITWIN_W; + editor_rect.bottom = EDITWIN_Y + EDITWIN_H; } /** @@ -1615,9 +1316,9 @@ void vst2_unlock_midi_device() { rack::global->vst2.wrapper->mtx_mididev.unlock(); } -void vst2_handle_queued_set_program_chunk(void) { - (void)rack::global->vst2.wrapper->handleSetQueuedProgramChunk(); -} +// void vst2_handle_queued_set_program_chunk(void) { +// (void)rack::global->vst2.wrapper->handleSetQueuedProgramChunk(); +// } void vst2_handle_ui_param(int uniqueParamId, float normValue) { // Called by engineSetParam() @@ -1629,24 +1330,15 @@ void vst2_get_timing_info(int *_retPlaying, float *_retBPM, float *_retSongPosPP rack::global->vst2.wrapper->getTimingInfo(_retPlaying, _retBPM, _retSongPosPPQ); } -#ifdef VST2_REPARENT_WINDOW_HACK -#ifdef YAC_WIN32 -void vst2_maximize_reparented_window(void) { -#if 0 - HWND glfwHWND = __hack__glfwGetHWND(rack::global_ui->window.gWindow); - HWND parentHWND = (HWND)rack::global_ui->vst2.parent_hwnd; - printf("xxx vstrack_plugin:vst2_maximize_reparented_window: hwnd=%p\n", (void*)glfwHWND); - RECT rect; - (void)::GetClientRect(parentHWND, &rect); - ///(void)::AdjustWindowRect(..) - printf("xxx vstrack_plugin:vst2_maximize_reparented_window: new size=(%d; %d)\n", rect.right-rect.left, rect.bottom-rect.top); - ::MoveWindow(glfwHWND, 0, 0, rect.right-rect.left, rect.bottom-rect.top, TRUE/*bRepaint*/); - // ::ShowWindow(glfwHWND, SW_MAXIMIZE); - // // ::ShowWindow(glfwHWND, SW_SHOWMAXIMIZED); -#endif // 0 +void vst2_set_globals(void *_wrapper) { + VSTPluginWrapper *wrapper = (VSTPluginWrapper *)_wrapper; + wrapper->setGlobals(); } -#endif // YAC_WIN32 -#endif // VST2_REPARENT_WINDOW_HACK + +void vst2_window_size_set(int _width, int _height) { + rack::global->vst2.wrapper->setWindowSize(_width, _height); +} + /** * Implementation of the main entry point of the plugin diff --git a/src/window.cpp b/src/window.cpp index 00de5283..b11bb7f1 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2,6 +2,7 @@ #include "window.hpp" #include "app.hpp" #include "asset.hpp" +#include "settings.hpp" #include "gamepad.hpp" #include "keyboard.hpp" #include "util/color.hpp" @@ -34,280 +35,534 @@ #include "global.hpp" #include "global_ui.hpp" - -#ifdef USE_VST2 -extern void vst2_handle_queued_set_program_chunk (void); - -#if defined(VST2_REPARENT_WINDOW_HACK) -extern void vst2_maximize_reparented_window(void); -extern "C" extern int __glfw_hack__b_queued_maximize_window; -#endif // VST2_REPARENT_WINDOW_HACK -#endif // USE_VST2 +extern void vst2_set_globals (void *_wrapper); namespace rack { -void windowSizeCallback(GLFWwindow* window, int width, int height) { -} - -void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods) { -#ifdef ARCH_MAC - // Ctrl-left click --> right click - if (button == GLFW_MOUSE_BUTTON_LEFT) { - if (glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS) { - button = GLFW_MOUSE_BUTTON_RIGHT; - } - } -#endif +// void windowSizeCallback(GLFWwindow* window, int width, int height) { +// } + +// void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods) { +// #ifdef ARCH_MAC +// // Ctrl-left click --> right click +// if (button == GLFW_MOUSE_BUTTON_LEFT) { +// if (glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS) { +// button = GLFW_MOUSE_BUTTON_RIGHT; +// } +// } +// #endif + +// if (action == GLFW_PRESS) { +// global_ui->widgets.gTempWidget = NULL; +// // onMouseDown +// { +// EventMouseDown e; +// e.pos = global_ui->window.gMousePos; +// e.button = button; +// global_ui->ui.gScene->onMouseDown(e); +// global_ui->widgets.gTempWidget = e.target; +// } + +// if (button == GLFW_MOUSE_BUTTON_LEFT) { +// if (global_ui->widgets.gTempWidget) { +// // onDragStart +// EventDragStart e; +// global_ui->widgets.gTempWidget->onDragStart(e); +// } +// global_ui->widgets.gDraggedWidget = global_ui->widgets.gTempWidget; + +// if (global_ui->widgets.gTempWidget != global_ui->widgets.gFocusedWidget) { +// if (global_ui->widgets.gFocusedWidget) { +// // onDefocus +// EventDefocus e; +// global_ui->widgets.gFocusedWidget->onDefocus(e); +// } +// global_ui->widgets.gFocusedWidget = NULL; +// if (global_ui->widgets.gTempWidget) { +// // onFocus +// EventFocus e; +// global_ui->widgets.gTempWidget->onFocus(e); +// if (e.consumed) { +// global_ui->widgets.gFocusedWidget = global_ui->widgets.gTempWidget; +// } +// } +// } +// } +// global_ui->widgets.gTempWidget = NULL; +// } +// else if (action == GLFW_RELEASE) { +// // onMouseUp +// global_ui->widgets.gTempWidget = NULL; +// { +// EventMouseUp e; +// e.pos = global_ui->window.gMousePos; +// e.button = button; +// global_ui->ui.gScene->onMouseUp(e); +// global_ui->widgets.gTempWidget = e.target; +// } + +// if (button == GLFW_MOUSE_BUTTON_LEFT) { +// if (global_ui->widgets.gDraggedWidget) { +// // onDragDrop +// EventDragDrop e; +// e.origin = global_ui->widgets.gDraggedWidget; +// global_ui->widgets.gTempWidget->onDragDrop(e); +// } +// // gDraggedWidget might have been set to null in the last event, recheck here +// if (global_ui->widgets.gDraggedWidget) { +// // onDragEnd +// EventDragEnd e; +// global_ui->widgets.gDraggedWidget->onDragEnd(e); +// } +// global_ui->widgets.gDraggedWidget = NULL; +// global_ui->widgets.gDragHoveredWidget = NULL; +// } +// global_ui->widgets.gTempWidget = NULL; +// } +// } + +// struct MouseButtonArguments { +// GLFWwindow *window; +// int button; +// int action; +// int mods; +// }; + +// static std::queue mouseButtonQueue; +// void mouseButtonStickyPop() { +// if (!mouseButtonQueue.empty()) { +// MouseButtonArguments args = mouseButtonQueue.front(); +// mouseButtonQueue.pop(); +// mouseButtonCallback(args.window, args.button, args.action, args.mods); +// } +// } + +// void mouseButtonStickyCallback(GLFWwindow *window, int button, int action, int mods) { +// // Defer multiple clicks per frame to future frames +// MouseButtonArguments args = {window, button, action, mods}; +// mouseButtonQueue.push(args); +// } + +// void cursorPosCallback(GLFWwindow* window, double xpos, double ypos) { +// Vec mousePos = Vec(xpos, ypos).div(global_ui->window.gPixelRatio / global_ui->window.gWindowRatio).round(); +// Vec mouseRel = mousePos.minus(global_ui->window.gMousePos); + +// int cursorMode = glfwGetInputMode(global_ui->window.gWindow, GLFW_CURSOR); +// (void) cursorMode; + +// #ifdef ARCH_MAC +// // Workaround for Mac. We can't use GLFW_CURSOR_DISABLED because it's buggy, so implement it on our own. +// // This is not an ideal implementation. For example, if the user drags off the screen, the new mouse position will be clamped. +// if (cursorMode == GLFW_CURSOR_HIDDEN) { +// // CGSetLocalEventsSuppressionInterval(0.0); +// glfwSetCursorPos(global_ui->window.gWindow, global_ui->window.gMousePos.x, global_ui->window.gMousePos.y); +// CGAssociateMouseAndMouseCursorPosition(true); +// mousePos = global_ui->window.gMousePos; +// } +// // Because sometimes the cursor turns into an arrow when its position is on the boundary of the window +// glfwSetCursor(global_ui->window.gWindow, NULL); +// #endif + +// global_ui->window.gMousePos = mousePos; + +// global_ui->widgets.gTempWidget = NULL; +// // onMouseMove +// { +// EventMouseMove e; +// e.pos = mousePos; +// e.mouseRel = mouseRel; +// global_ui->ui.gScene->onMouseMove(e); +// global_ui->widgets.gTempWidget = e.target; +// } + +// if (global_ui->widgets.gDraggedWidget) { +// // onDragMove +// EventDragMove e; +// e.mouseRel = mouseRel; +// global_ui->widgets.gDraggedWidget->onDragMove(e); + +// if (global_ui->widgets.gTempWidget != global_ui->widgets.gDragHoveredWidget) { +// if (global_ui->widgets.gDragHoveredWidget) { +// EventDragEnter e; +// e.origin = global_ui->widgets.gDraggedWidget; +// global_ui->widgets.gDragHoveredWidget->onDragLeave(e); +// } +// global_ui->widgets.gDragHoveredWidget = global_ui->widgets.gTempWidget; +// if (global_ui->widgets.gDragHoveredWidget) { +// EventDragEnter e; +// e.origin = global_ui->widgets.gDraggedWidget; +// global_ui->widgets.gDragHoveredWidget->onDragEnter(e); +// } +// } +// } +// else { +// if (global_ui->widgets.gTempWidget != global_ui->widgets.gHoveredWidget) { +// if (global_ui->widgets.gHoveredWidget) { +// // onMouseLeave +// EventMouseLeave e; +// global_ui->widgets.gHoveredWidget->onMouseLeave(e); +// } +// global_ui->widgets.gHoveredWidget = global_ui->widgets.gTempWidget; +// if (global_ui->widgets.gHoveredWidget) { +// // onMouseEnter +// EventMouseEnter e; +// global_ui->widgets.gHoveredWidget->onMouseEnter(e); +// } +// } +// } +// global_ui->widgets.gTempWidget = NULL; +// if (glfwGetMouseButton(global_ui->window.gWindow, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS) { +// // TODO +// // Define a new global called gScrollWidget, which remembers the widget where middle-click was first pressed +// EventScroll e; +// e.pos = mousePos; +// e.scrollRel = mouseRel; +// global_ui->ui.gScene->onScroll(e); +// } +// } + +// void cursorEnterCallback(GLFWwindow* window, int entered) { +// if (!entered) { +// if (global_ui->widgets.gHoveredWidget) { +// // onMouseLeave +// EventMouseLeave e; +// global_ui->widgets.gHoveredWidget->onMouseLeave(e); +// } +// global_ui->widgets.gHoveredWidget = NULL; +// } +// } + +// void scrollCallback(GLFWwindow *window, double x, double y) { +// Vec scrollRel = Vec(x, y); +// #if ARCH_LIN || ARCH_WIN +// if (windowIsShiftPressed()) +// scrollRel = Vec(y, x); +// #endif +// // onScroll +// EventScroll e; +// e.pos = global_ui->window.gMousePos; +// e.scrollRel = scrollRel.mult(50.0); +// global_ui->ui.gScene->onScroll(e); +// } + +// // void charCallback(GLFWwindow *window, unsigned int codepoint) { +// // if (global_ui->widgets.gFocusedWidget) { +// // // onText +// // EventText e; +// // e.codepoint = codepoint; +// // global_ui->widgets.gFocusedWidget->onText(e); +// // } +// // } + +// void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { +// if (action == GLFW_PRESS || action == GLFW_REPEAT) { +// if (global_ui->widgets.gFocusedWidget) { +// // onKey +// EventKey e; +// e.key = key; +// global_ui->widgets.gFocusedWidget->onKey(e); +// if (e.consumed) +// return; +// } +// // onHoverKey +// EventHoverKey e; +// e.pos = global_ui->window.gMousePos; +// e.key = key; +// global_ui->ui.gScene->onHoverKey(e); +// } + +// // Keyboard MIDI driver +// if (!(mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT | GLFW_MOD_SUPER))) { +// if (action == GLFW_PRESS) { +// keyboardPress(key); +// } +// else if (action == GLFW_RELEASE) { +// keyboardRelease(key); +// } +// } +// } + +// // void dropCallback(GLFWwindow *window, int count, const char **paths) { +// // // onPathDrop +// // EventPathDrop e; +// // e.pos = global_ui->window.gMousePos; +// // for (int i = 0; i < count; i++) { +// // e.paths.push_back(paths[i]); +// // } +// // global_ui->ui.gScene->onPathDrop(e); +// // } + +// // void errorCallback(int error, const char *description) { +// // warn("GLFW error %d: %s", error, description); +// // } + +extern "C" { + +static void lglw_mouse_cbk(lglw_t _lglw, int32_t _x, int32_t _y, uint32_t _buttonState, uint32_t _changedButtonState) { + // printf("xxx lglw_mouse_cbk: lglw=%p p=(%d; %d) bt=0x%08x changedBt=0x%08x\n", _lglw, _x, _y, _buttonState, _changedButtonState); + vst2_set_globals(lglw_userdata_get(_lglw)); + + if(LGLW_MOUSE_WHEELUP == _buttonState) + { + // onScroll + EventScroll e; + e.pos = global_ui->window.gMousePos; + Vec scrollRel = Vec(0, 1); + e.scrollRel = scrollRel.mult(50.0); + global_ui->ui.gScene->onScroll(e); + } + else if(LGLW_MOUSE_WHEELDOWN == _buttonState) + { + // onScroll + EventScroll e; + e.pos = global_ui->window.gMousePos; + Vec scrollRel = Vec(0, -1); + e.scrollRel = scrollRel.mult(50.0); + global_ui->ui.gScene->onScroll(e); + } + else if(0u == _changedButtonState) + { + // onMouseMotion + Vec mousePos = Vec(_x, _y);//.div(global_ui->window.gPixelRatio / global_ui->window.gWindowRatio).round(); + Vec mouseRel = mousePos.minus(global_ui->window.gMousePos); + + // int cursorMode = glfwGetInputMode(global_ui->window.gWindow, GLFW_CURSOR); + // (void) cursorMode; + +// #ifdef ARCH_MAC +// // Workaround for Mac. We can't use GLFW_CURSOR_DISABLED because it's buggy, so implement it on our own. +// // This is not an ideal implementation. For example, if the user drags off the screen, the new mouse position will be clamped. +// if (cursorMode == GLFW_CURSOR_HIDDEN) { +// // CGSetLocalEventsSuppressionInterval(0.0); +// glfwSetCursorPos(global_ui->window.gWindow, global_ui->window.gMousePos.x, global_ui->window.gMousePos.y); +// CGAssociateMouseAndMouseCursorPosition(true); +// mousePos = global_ui->window.gMousePos; +// } +// // Because sometimes the cursor turns into an arrow when its position is on the boundary of the window +// glfwSetCursor(global_ui->window.gWindow, NULL); +// #endif + + global_ui->window.gMousePos = mousePos; + + global_ui->widgets.gTempWidget = NULL; + // onMouseMove + { + EventMouseMove e; + e.pos = mousePos; + e.mouseRel = mouseRel; + global_ui->ui.gScene->onMouseMove(e); + global_ui->widgets.gTempWidget = e.target; + } - if (action == GLFW_PRESS) { - global_ui->widgets.gTempWidget = NULL; - // onMouseDown - { - EventMouseDown e; - e.pos = global_ui->window.gMousePos; - e.button = button; - global_ui->ui.gScene->onMouseDown(e); - global_ui->widgets.gTempWidget = e.target; - } - - if (button == GLFW_MOUSE_BUTTON_LEFT) { - if (global_ui->widgets.gTempWidget) { - // onDragStart - EventDragStart e; - global_ui->widgets.gTempWidget->onDragStart(e); - } - global_ui->widgets.gDraggedWidget = global_ui->widgets.gTempWidget; - - if (global_ui->widgets.gTempWidget != global_ui->widgets.gFocusedWidget) { - if (global_ui->widgets.gFocusedWidget) { - // onDefocus - EventDefocus e; - global_ui->widgets.gFocusedWidget->onDefocus(e); - } - global_ui->widgets.gFocusedWidget = NULL; - if (global_ui->widgets.gTempWidget) { - // onFocus - EventFocus e; - global_ui->widgets.gTempWidget->onFocus(e); - if (e.consumed) { - global_ui->widgets.gFocusedWidget = global_ui->widgets.gTempWidget; - } - } - } - } - global_ui->widgets.gTempWidget = NULL; - } - else if (action == GLFW_RELEASE) { - // onMouseUp - global_ui->widgets.gTempWidget = NULL; - { - EventMouseUp e; - e.pos = global_ui->window.gMousePos; - e.button = button; - global_ui->ui.gScene->onMouseUp(e); - global_ui->widgets.gTempWidget = e.target; - } - - if (button == GLFW_MOUSE_BUTTON_LEFT) { - if (global_ui->widgets.gDraggedWidget) { - // onDragDrop - EventDragDrop e; - e.origin = global_ui->widgets.gDraggedWidget; - global_ui->widgets.gTempWidget->onDragDrop(e); - } - // gDraggedWidget might have been set to null in the last event, recheck here - if (global_ui->widgets.gDraggedWidget) { - // onDragEnd - EventDragEnd e; - global_ui->widgets.gDraggedWidget->onDragEnd(e); - } - global_ui->widgets.gDraggedWidget = NULL; - global_ui->widgets.gDragHoveredWidget = NULL; - } - global_ui->widgets.gTempWidget = NULL; - } -} + if (global_ui->widgets.gDraggedWidget) { + // onDragMove + EventDragMove e; + e.mouseRel = mouseRel; + global_ui->widgets.gDraggedWidget->onDragMove(e); + + if (global_ui->widgets.gTempWidget != global_ui->widgets.gDragHoveredWidget) { + if (global_ui->widgets.gDragHoveredWidget) { + EventDragEnter e; + e.origin = global_ui->widgets.gDraggedWidget; + global_ui->widgets.gDragHoveredWidget->onDragLeave(e); + } + global_ui->widgets.gDragHoveredWidget = global_ui->widgets.gTempWidget; + if (global_ui->widgets.gDragHoveredWidget) { + EventDragEnter e; + e.origin = global_ui->widgets.gDraggedWidget; + global_ui->widgets.gDragHoveredWidget->onDragEnter(e); + } + } + } + else { + if (global_ui->widgets.gTempWidget != global_ui->widgets.gHoveredWidget) { + if (global_ui->widgets.gHoveredWidget) { + // onMouseLeave + EventMouseLeave e; + global_ui->widgets.gHoveredWidget->onMouseLeave(e); + } + global_ui->widgets.gHoveredWidget = global_ui->widgets.gTempWidget; + if (global_ui->widgets.gHoveredWidget) { + // onMouseEnter + EventMouseEnter e; + global_ui->widgets.gHoveredWidget->onMouseEnter(e); + } + } + } + global_ui->widgets.gTempWidget = NULL; + // // if (glfwGetMouseButton(global_ui->window.gWindow, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS) { + if(0u != (_buttonState & LGLW_MOUSE_MBUTTON)) { + // TODO + // Define a new global called gScrollWidget, which remembers the widget where middle-click was first pressed + EventScroll e; + e.pos = mousePos; + e.scrollRel = mouseRel; + global_ui->ui.gScene->onScroll(e); + } + } + else + { + // Mouse button state changed + +// #ifdef ARCH_MAC +// // Ctrl-left click --> right click +// if (button == GLFW_MOUSE_BUTTON_LEFT) { +// if (glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS) { +// button = GLFW_MOUSE_BUTTON_RIGHT; +// } +// } +// #endif + int button = + (0u != (_changedButtonState & LGLW_MOUSE_LBUTTON)) ? 0 : + (0u != (_changedButtonState & LGLW_MOUSE_RBUTTON)) ? 1 : + (0u != (_changedButtonState & LGLW_MOUSE_MBUTTON)) ? 2 : + -1; + + bool bPressed = (0u != (_changedButtonState & _buttonState)); + + if (bPressed) { + global_ui->widgets.gTempWidget = NULL; + // onMouseDown + { + EventMouseDown e; + e.pos = global_ui->window.gMousePos; + e.button = button; + global_ui->ui.gScene->onMouseDown(e); + global_ui->widgets.gTempWidget = e.target; + } + + if (button == 0/*GLFW_MOUSE_BUTTON_LEFT*/) { + if (global_ui->widgets.gTempWidget) { + // onDragStart + EventDragStart e; + global_ui->widgets.gTempWidget->onDragStart(e); + } + global_ui->widgets.gDraggedWidget = global_ui->widgets.gTempWidget; + + if (global_ui->widgets.gTempWidget != global_ui->widgets.gFocusedWidget) { + if (global_ui->widgets.gFocusedWidget) { + // onDefocus + EventDefocus e; + global_ui->widgets.gFocusedWidget->onDefocus(e); + } + global_ui->widgets.gFocusedWidget = NULL; + if (global_ui->widgets.gTempWidget) { + // onFocus + EventFocus e; + global_ui->widgets.gTempWidget->onFocus(e); + if (e.consumed) { + global_ui->widgets.gFocusedWidget = global_ui->widgets.gTempWidget; + } + } + } + } + global_ui->widgets.gTempWidget = NULL; + } + else { ///if (action == GLFW_RELEASE) { + // onMouseUp + global_ui->widgets.gTempWidget = NULL; + { + EventMouseUp e; + e.pos = global_ui->window.gMousePos; + e.button = button; + global_ui->ui.gScene->onMouseUp(e); + global_ui->widgets.gTempWidget = e.target; + } + + if (button == 0/*GLFW_MOUSE_BUTTON_LEFT*/) { + if (global_ui->widgets.gDraggedWidget) { + // onDragDrop + EventDragDrop e; + e.origin = global_ui->widgets.gDraggedWidget; + global_ui->widgets.gTempWidget->onDragDrop(e); + } + // gDraggedWidget might have been set to null in the last event, recheck here + if (global_ui->widgets.gDraggedWidget) { + // onDragEnd + EventDragEnd e; + global_ui->widgets.gDraggedWidget->onDragEnd(e); + } + global_ui->widgets.gDraggedWidget = NULL; + global_ui->widgets.gDragHoveredWidget = NULL; + } + global_ui->widgets.gTempWidget = NULL; + } -struct MouseButtonArguments { - GLFWwindow *window; - int button; - int action; - int mods; -}; - -static std::queue mouseButtonQueue; -void mouseButtonStickyPop() { - if (!mouseButtonQueue.empty()) { - MouseButtonArguments args = mouseButtonQueue.front(); - mouseButtonQueue.pop(); - mouseButtonCallback(args.window, args.button, args.action, args.mods); - } -} + } -void mouseButtonStickyCallback(GLFWwindow *window, int button, int action, int mods) { - // Defer multiple clicks per frame to future frames - MouseButtonArguments args = {window, button, action, mods}; - mouseButtonQueue.push(args); } -void cursorPosCallback(GLFWwindow* window, double xpos, double ypos) { - Vec mousePos = Vec(xpos, ypos).div(global_ui->window.gPixelRatio / global_ui->window.gWindowRatio).round(); - Vec mouseRel = mousePos.minus(global_ui->window.gMousePos); - - int cursorMode = glfwGetInputMode(global_ui->window.gWindow, GLFW_CURSOR); - (void) cursorMode; - -#ifdef ARCH_MAC - // Workaround for Mac. We can't use GLFW_CURSOR_DISABLED because it's buggy, so implement it on our own. - // This is not an ideal implementation. For example, if the user drags off the screen, the new mouse position will be clamped. - if (cursorMode == GLFW_CURSOR_HIDDEN) { - // CGSetLocalEventsSuppressionInterval(0.0); - glfwSetCursorPos(global_ui->window.gWindow, global_ui->window.gMousePos.x, global_ui->window.gMousePos.y); - CGAssociateMouseAndMouseCursorPosition(true); - mousePos = global_ui->window.gMousePos; - } - // Because sometimes the cursor turns into an arrow when its position is on the boundary of the window - glfwSetCursor(global_ui->window.gWindow, NULL); -#endif +static void lglw_focus_cbk(lglw_t _lglw, uint32_t _focusState, uint32_t _changedFocusState) { + // printf("xxx lglw_focus_cbk: lglw=%p focusState=0x%08x changedFocusState=0x%08x\n", _lglw, _focusState, _changedFocusState); - global_ui->window.gMousePos = mousePos; + vst2_set_globals(lglw_userdata_get(_lglw)); - global_ui->widgets.gTempWidget = NULL; - // onMouseMove - { - EventMouseMove e; - e.pos = mousePos; - e.mouseRel = mouseRel; - global_ui->ui.gScene->onMouseMove(e); - global_ui->widgets.gTempWidget = e.target; - } - - if (global_ui->widgets.gDraggedWidget) { - // onDragMove - EventDragMove e; - e.mouseRel = mouseRel; - global_ui->widgets.gDraggedWidget->onDragMove(e); - - if (global_ui->widgets.gTempWidget != global_ui->widgets.gDragHoveredWidget) { - if (global_ui->widgets.gDragHoveredWidget) { - EventDragEnter e; - e.origin = global_ui->widgets.gDraggedWidget; - global_ui->widgets.gDragHoveredWidget->onDragLeave(e); - } - global_ui->widgets.gDragHoveredWidget = global_ui->widgets.gTempWidget; - if (global_ui->widgets.gDragHoveredWidget) { - EventDragEnter e; - e.origin = global_ui->widgets.gDraggedWidget; - global_ui->widgets.gDragHoveredWidget->onDragEnter(e); - } - } - } - else { - if (global_ui->widgets.gTempWidget != global_ui->widgets.gHoveredWidget) { - if (global_ui->widgets.gHoveredWidget) { - // onMouseLeave - EventMouseLeave e; - global_ui->widgets.gHoveredWidget->onMouseLeave(e); - } - global_ui->widgets.gHoveredWidget = global_ui->widgets.gTempWidget; - if (global_ui->widgets.gHoveredWidget) { - // onMouseEnter - EventMouseEnter e; - global_ui->widgets.gHoveredWidget->onMouseEnter(e); - } - } - } - global_ui->widgets.gTempWidget = NULL; - if (glfwGetMouseButton(global_ui->window.gWindow, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS) { - // TODO - // Define a new global called gScrollWidget, which remembers the widget where middle-click was first pressed - EventScroll e; - e.pos = mousePos; - e.scrollRel = mouseRel; - global_ui->ui.gScene->onScroll(e); - } -} - -void cursorEnterCallback(GLFWwindow* window, int entered) { - if (!entered) { - if (global_ui->widgets.gHoveredWidget) { - // onMouseLeave - EventMouseLeave e; - global_ui->widgets.gHoveredWidget->onMouseLeave(e); - } - global_ui->widgets.gHoveredWidget = NULL; - } + if(0u != (_changedFocusState & LGLW_FOCUS_MOUSE)) + { + if(0u != (_focusState & LGLW_FOCUS_MOUSE)) + { + // onMouseEnter + } + else + { + if (global_ui->widgets.gHoveredWidget) { + // onMouseLeave + EventMouseLeave e; + global_ui->widgets.gHoveredWidget->onMouseLeave(e); + } + global_ui->widgets.gHoveredWidget = NULL; + } + } } -void scrollCallback(GLFWwindow *window, double x, double y) { - Vec scrollRel = Vec(x, y); -#if ARCH_LIN || ARCH_WIN - if (windowIsShiftPressed()) - scrollRel = Vec(y, x); -#endif - // onScroll - EventScroll e; - e.pos = global_ui->window.gMousePos; - e.scrollRel = scrollRel.mult(50.0); - global_ui->ui.gScene->onScroll(e); -} +static void lglw_keyboard_cbk(lglw_t _lglw, uint32_t _vkey, uint32_t _kmod, lglw_bool_t _bPressed) { + printf("xxx lglw_keyboard_cbk: lglw=%p vkey=0x%08x (\'%c\') kmod=0x%08x bPressed=%d\n", _lglw, _vkey, (char)_vkey, _kmod, _bPressed); -void charCallback(GLFWwindow *window, unsigned int codepoint) { - if (global_ui->widgets.gFocusedWidget) { - // onText - EventText e; - e.codepoint = codepoint; - global_ui->widgets.gFocusedWidget->onText(e); - } -} + vst2_set_globals(lglw_userdata_get(_lglw)); -void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - if (action == GLFW_PRESS || action == GLFW_REPEAT) { - if (global_ui->widgets.gFocusedWidget) { - // onKey - EventKey e; - e.key = key; - global_ui->widgets.gFocusedWidget->onKey(e); - if (e.consumed) - return; - } - // onHoverKey - EventHoverKey e; - e.pos = global_ui->window.gMousePos; - e.key = key; - global_ui->ui.gScene->onHoverKey(e); - } + if( (0u == (_vkey & LGLW_VKEY_EXT)) && (0u == (_kmod & (LGLW_KMOD_LCTRL | LGLW_KMOD_RCTRL))) ) + { + // Unicode or ASCII character + if(_bPressed) + { + if (global_ui->widgets.gFocusedWidget) { + // onText + EventText e; + e.codepoint = _vkey; + global_ui->widgets.gFocusedWidget->onText(e); + if(e.consumed) + return; + } + } + } - // Keyboard MIDI driver - if (!(mods & (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT | GLFW_MOD_SUPER))) { - if (action == GLFW_PRESS) { - keyboardPress(key); - } - else if (action == GLFW_RELEASE) { - keyboardRelease(key); - } - } -} + if(_bPressed) + { + if (global_ui->widgets.gFocusedWidget) { + // onKey + EventKey e; + e.key = _vkey; + global_ui->widgets.gFocusedWidget->onKey(e); + if (e.consumed) + return; + } -void dropCallback(GLFWwindow *window, int count, const char **paths) { - // onPathDrop - EventPathDrop e; - e.pos = global_ui->window.gMousePos; - for (int i = 0; i < count; i++) { - e.paths.push_back(paths[i]); - } - global_ui->ui.gScene->onPathDrop(e); + // onHoverKey + EventHoverKey e; + e.pos = global_ui->window.gMousePos; + e.key = _vkey; + global_ui->ui.gScene->onHoverKey(e); + } } -void errorCallback(int error, const char *description) { - warn("GLFW error %d: %s", error, description); -} +} // extern C void renderGui() { int width, height; // printf("xxx renderGui: ENTER\n"); - glfwGetFramebufferSize(global_ui->window.gWindow, &width, &height); + // glfwGetFramebufferSize(global_ui->window.gWindow, &width, &height); + lglw_window_size_get(global_ui->window.lglw, &width, &height); // Update and render nvgBeginFrame(global_ui->window.gVg, width, height, global_ui->window.gPixelRatio); @@ -322,82 +577,72 @@ void renderGui() { glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); nvgEndFrame(global_ui->window.gVg); - glfwSwapBuffers(global_ui->window.gWindow); + // // glfwSwapBuffers(global_ui->window.gWindow); // printf("xxx renderGui: LEAVE\n"); } void windowInit() { int err; - bool bInitGLFW = true; -#ifdef USE_VST2 - // (note) GLFW uses global vars. hmmmmm. multiple init seems to work, though (and opening multiple windows) - // (note) just don't terminate until last instance is closed - // (note) (this will probably result in memleaks..?!) - bInitGLFW = (1 == global->vst2.last_seen_instance_count); -#endif // USE_VST2 + // (note) the hidden LGLW context window must have the same size as the real window created later on + settingsLoad(assetLocal("settings.json"), true/*bWindowSizeOnly*/); -#if 0 - if(bInitGLFW) - { - // Set up GLFW - glfwSetErrorCallback(errorCallback); - err = glfwInit(); - if (err != GLFW_TRUE) { - osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Could not initialize GLFW."); - exit(1); - } - } -#else - glfwSetErrorCallback(errorCallback); -#endif + global_ui->window.lglw = lglw_init(global_ui->window.windowWidth, global_ui->window.windowHeight); -#if defined NANOVG_GL2 - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); -#elif defined NANOVG_GL3 - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); -#endif - glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); - glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); + lglw_userdata_set(global_ui->window.lglw, global->vst2.wrapper); + +// #if defined NANOVG_GL2 +// glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); +// glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); +// #elif defined NANOVG_GL3 +// glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); +// glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); +// glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); +// glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); +// #endif + // glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); + // glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); global_ui->window.lastWindowTitle = ""; - global_ui->window.gWindow = glfwCreateWindow(640, 480, global_ui->window.lastWindowTitle.c_str(), NULL, NULL); - if (!global_ui->window.gWindow) { - osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Cannot open window with OpenGL 2.0 renderer. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed."); - exit(1); - } + // global_ui->window.gWindow = glfwCreateWindow(640, 480, global_ui->window.lastWindowTitle.c_str(), NULL, NULL); + // if (!global_ui->window.gWindow) { + // osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Cannot open window with OpenGL 2.0 renderer. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed."); + // exit(1); + // } - glfwMakeContextCurrent(global_ui->window.gWindow); + // // glfwMakeContextCurrent(global_ui->window.gWindow); + // // glfwSwapInterval(1); + lglw_glcontext_push(global_ui->window.lglw); + lglw_swap_interval(global_ui->window.lglw, 1); - glfwSwapInterval(1); + // // glfwSetInputMode(global_ui->window.gWindow, GLFW_LOCK_KEY_MODS, 1); - glfwSetInputMode(global_ui->window.gWindow, GLFW_LOCK_KEY_MODS, 1); + // // glfwSetWindowSizeCallback(global_ui->window.gWindow, windowSizeCallback); + // // glfwSetMouseButtonCallback(global_ui->window.gWindow, mouseButtonStickyCallback); + lglw_mouse_callback_set(global_ui->window.lglw, &lglw_mouse_cbk); + lglw_focus_callback_set(global_ui->window.lglw, &lglw_focus_cbk); + lglw_keyboard_callback_set(global_ui->window.lglw, &lglw_keyboard_cbk); - glfwSetWindowSizeCallback(global_ui->window.gWindow, windowSizeCallback); - glfwSetMouseButtonCallback(global_ui->window.gWindow, mouseButtonStickyCallback); // Call this ourselves, but on every frame instead of only when the mouse moves // glfwSetCursorPosCallback(gWindow, cursorPosCallback); - glfwSetCursorEnterCallback(global_ui->window.gWindow, cursorEnterCallback); - glfwSetScrollCallback(global_ui->window.gWindow, scrollCallback); - glfwSetCharCallback(global_ui->window.gWindow, charCallback); - glfwSetKeyCallback(global_ui->window.gWindow, keyCallback); - glfwSetDropCallback(global_ui->window.gWindow, dropCallback); + // glfwSetCursorEnterCallback(global_ui->window.gWindow, cursorEnterCallback); + // glfwSetScrollCallback(global_ui->window.gWindow, scrollCallback); + // glfwSetCharCallback(global_ui->window.gWindow, charCallback); + // glfwSetKeyCallback(global_ui->window.gWindow, keyCallback); + // glfwSetDropCallback(global_ui->window.gWindow, dropCallback); // Set up GLEW glewExperimental = GL_TRUE; err = glewInit(); if (err != GLEW_OK) { osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Could not initialize GLEW. Does your graphics card support OpenGL 2.0 or greater? If so, make sure you have the latest graphics drivers installed."); + lglw_glcontext_pop(global_ui->window.lglw); exit(1); } // GLEW generates GL error because it calls glGetString(GL_EXTENSIONS), we'll consume it here. glGetError(); - glfwSetWindowSizeLimits(global_ui->window.gWindow, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE); + // glfwSetWindowSizeLimits(global_ui->window.gWindow, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE); // Set up NanoVG int nvgFlags = NVG_ANTIALIAS; @@ -425,13 +670,13 @@ void windowInit() { windowSetTheme(nvgRGB(0x33, 0x33, 0x33), nvgRGB(0xf0, 0xf0, 0xf0)); -#ifdef USE_VST2 - // (note) the patch loader requires an initialized window system (widgets etc) - ::glfwHideWindow(global_ui->window.gWindow); -#endif // USE_VST2 + lglw_glcontext_pop(global_ui->window.lglw); } void windowDestroy() { + printf("xxx vstrack: windowDestroy()\n"); + lglw_glcontext_push(global_ui->window.lglw); + global_ui->window.gGuiFont.reset(); #if defined NANOVG_GL2 @@ -450,190 +695,205 @@ void windowDestroy() { nvgDeleteGLES2(global_ui->window.gFramebufferVg); #endif - glfwDestroyWindow(global_ui->window.gWindow); - global_ui->window.gWindow = 0; + lglw_glcontext_pop(global_ui->window.lglw); -#if 0 - bool bTerminateGLFW = true; -#ifdef USE_VST2 - bTerminateGLFW = (1 == global->vst2.last_seen_instance_count); -#endif // USE_VST2 - if(bTerminateGLFW) - glfwTerminate(); -#endif + lglw_exit(global_ui->window.lglw); + global_ui->window.lglw = NULL; } -void windowRun() { - printf("xxx vcvrack: windowRun() ENTER\n"); - assert(global_ui->window.gWindow); - global_ui->window.gGuiFrame = 0; - while(!glfwWindowShouldClose(global_ui->window.gWindow) -#ifdef USE_VST2 - && !global_ui->vst2.b_close_window -#endif // USE_VST2 - ) { - -#ifndef RACK_PLUGIN - vst2_handle_queued_set_program_chunk(); -#endif // RACK_PLUGIN - - double startTime = glfwGetTime(); - global_ui->window.gGuiFrame++; - // printf("xxx vcvrack: windowRun(): startTime=%g\n", startTime); - - // Poll events - glfwPollEvents(); - { - double xpos, ypos; - glfwGetCursorPos(global_ui->window.gWindow, &xpos, &ypos); - cursorPosCallback(global_ui->window.gWindow, xpos, ypos); - } - mouseButtonStickyPop(); - -#ifndef USE_VST2 - gamepadStep(); -#endif // !USE_VST2 - - // Set window title - std::string windowTitle; - windowTitle = global_ui->app.gApplicationName; - windowTitle += " "; - windowTitle += global_ui->app.gApplicationVersion; - if (!global_ui->app.gRackWidget->lastPath.empty()) { - windowTitle += " - "; - windowTitle += stringFilename(global_ui->app.gRackWidget->lastPath); - } - if (windowTitle != global_ui->window.lastWindowTitle) { - glfwSetWindowTitle(global_ui->window.gWindow, windowTitle.c_str()); - global_ui->window.lastWindowTitle = windowTitle; - } - - // Get desired scaling - float pixelRatio; - glfwGetWindowContentScale(global_ui->window.gWindow, &pixelRatio, NULL); - pixelRatio = roundf(pixelRatio); - if (pixelRatio != global_ui->window.gPixelRatio) { - EventZoom eZoom; - global_ui->ui.gScene->onZoom(eZoom); - global_ui->window.gPixelRatio = pixelRatio; - } - - // Get framebuffer/window ratio - int width, height; - glfwGetFramebufferSize(global_ui->window.gWindow, &width, &height); - int windowWidth, windowHeight; - glfwGetWindowSize(global_ui->window.gWindow, &windowWidth, &windowHeight); - global_ui->window.gWindowRatio = (float)width / windowWidth; - - global_ui->ui.gScene->box.size = Vec(width, height).div(global_ui->window.gPixelRatio); - - // Step scene - global_ui->ui.gScene->step(); - - // Render - bool visible = glfwGetWindowAttrib(global_ui->window.gWindow, GLFW_VISIBLE) && !glfwGetWindowAttrib(global_ui->window.gWindow, GLFW_ICONIFIED); - if (visible) { - renderGui(); - } - - // Limit framerate manually if vsync isn't working - double endTime = glfwGetTime(); - double frameTime = endTime - startTime; - double minTime = 1.0 / 90.0; - if (frameTime < minTime) { - std::this_thread::sleep_for(std::chrono::duration(minTime - frameTime)); - } - endTime = glfwGetTime(); - // info("%lf fps", 1.0 / (endTime - startTime)); - -#ifdef USE_VST2 - if(global_ui->vst2.b_hide_window) - { - global_ui->vst2.b_hide_window = 0; - break; - } -#if defined(YAC_WIN32) && defined(VST2_REPARENT_WINDOW_HACK) -#ifndef RACK_PLUGIN - else if(rack::global_ui->vst2.b_queued_maximize_window || __glfw_hack__b_queued_maximize_window) - { - rack::global_ui->vst2.b_queued_maximize_window = false; - __glfw_hack__b_queued_maximize_window = false; - vst2_maximize_reparented_window(); - } -#endif // VST2_REPARENT_WINDOW_HACK -#endif // RACK_PLUGIN -#endif // USE_VST2 - } +void vst2_editor_redraw(void) { + // (note) the GL context is set by the caller + + global_ui->window.gGuiFrame++; -#ifdef USE_VST2 - ::glfwSetWindowShouldClose(global_ui->window.gWindow, 0); - ::glfwHideWindow(global_ui->window.gWindow); +#if 0 + // Set window title + std::string windowTitle; + windowTitle = global_ui->app.gApplicationName; + windowTitle += " "; + windowTitle += global_ui->app.gApplicationVersion; + if (!global_ui->app.gRackWidget->lastPath.empty()) { + windowTitle += " - "; + windowTitle += stringFilename(global_ui->app.gRackWidget->lastPath); + } + if (windowTitle != global_ui->window.lastWindowTitle) { + // // glfwSetWindowTitle(global_ui->window.gWindow, windowTitle.c_str()); + global_ui->window.lastWindowTitle = windowTitle; + } #endif - printf("xxx vcvrack: windowRun() LEAVE\n"); + // Get framebuffer/window ratio + int width, height; + lglw_window_size_get(global_ui->window.lglw, &width, &height); + global_ui->window.gWindowRatio = 1.0f; + global_ui->ui.gScene->box.size = Vec(width, height); + + // Step scene + global_ui->ui.gScene->step(); + + // Render + renderGui(); + + // Present + glFlush(); + lglw_swap_buffers(global_ui->window.lglw); } +// #if 0 +// void windowRun() { +// printf("xxx vcvrack: windowRun() ENTER\n"); +// assert(global_ui->window.gWindow); +// global_ui->window.gGuiFrame = 0; +// while(!glfwWindowShouldClose(global_ui->window.gWindow) +// #ifdef USE_VST2 +// && !global_ui->vst2.b_close_window +// #endif // USE_VST2 +// ) { + +// double startTime = glfwGetTime(); +// global_ui->window.gGuiFrame++; +// // printf("xxx vcvrack: windowRun(): startTime=%g\n", startTime); + +// // Poll events +// glfwPollEvents(); +// { +// double xpos, ypos; +// glfwGetCursorPos(global_ui->window.gWindow, &xpos, &ypos); +// cursorPosCallback(global_ui->window.gWindow, xpos, ypos); +// } +// mouseButtonStickyPop(); + +// #ifndef USE_VST2 +// gamepadStep(); +// #endif // !USE_VST2 + +// // Set window title +// std::string windowTitle; +// windowTitle = global_ui->app.gApplicationName; +// windowTitle += " "; +// windowTitle += global_ui->app.gApplicationVersion; +// if (!global_ui->app.gRackWidget->lastPath.empty()) { +// windowTitle += " - "; +// windowTitle += stringFilename(global_ui->app.gRackWidget->lastPath); +// } +// if (windowTitle != global_ui->window.lastWindowTitle) { +// // // glfwSetWindowTitle(global_ui->window.gWindow, windowTitle.c_str()); +// global_ui->window.lastWindowTitle = windowTitle; +// } + +// // Get desired scaling +// // // float pixelRatio; +// // // glfwGetWindowContentScale(global_ui->window.gWindow, &pixelRatio, NULL); +// // // pixelRatio = roundf(pixelRatio); +// // // if (pixelRatio != global_ui->window.gPixelRatio) { +// // // EventZoom eZoom; +// // // global_ui->ui.gScene->onZoom(eZoom); +// // // global_ui->window.gPixelRatio = pixelRatio; +// // // } + +// // Get framebuffer/window ratio +// int width, height; +// glfwGetFramebufferSize(global_ui->window.gWindow, &width, &height); +// int windowWidth, windowHeight; +// glfwGetWindowSize(global_ui->window.gWindow, &windowWidth, &windowHeight); +// global_ui->window.gWindowRatio = (float)width / windowWidth; + +// global_ui->ui.gScene->box.size = Vec(width, height).div(global_ui->window.gPixelRatio); + +// // Step scene +// global_ui->ui.gScene->step(); + +// // Render +// bool visible = glfwGetWindowAttrib(global_ui->window.gWindow, GLFW_VISIBLE) && !glfwGetWindowAttrib(global_ui->window.gWindow, GLFW_ICONIFIED); +// if (visible) { +// renderGui(); +// } + +// // Limit framerate manually if vsync isn't working +// double endTime = glfwGetTime(); +// double frameTime = endTime - startTime; +// double minTime = 1.0 / 90.0; +// if (frameTime < minTime) { +// std::this_thread::sleep_for(std::chrono::duration(minTime - frameTime)); +// } +// endTime = glfwGetTime(); +// // info("%lf fps", 1.0 / (endTime - startTime)); +// } + +// printf("xxx vcvrack: windowRun() LEAVE\n"); +// } +// #endif + void windowClose() { - glfwSetWindowShouldClose(global_ui->window.gWindow, GLFW_TRUE); + // // glfwSetWindowShouldClose(global_ui->window.gWindow, GLFW_TRUE); } void windowCursorLock() { - if (global_ui->window.gAllowCursorLock) { -#ifdef ARCH_MAC - glfwSetInputMode(global_ui->window.gWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); -#else - glfwSetInputMode(global_ui->window.gWindow, GLFW_CURSOR, GLFW_CURSOR_DISABLED); -#endif - } + if (global_ui->window.gAllowCursorLock) { +// #ifdef ARCH_MAC +// glfwSetInputMode(global_ui->window.gWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); +// #else +// glfwSetInputMode(global_ui->window.gWindow, GLFW_CURSOR, GLFW_CURSOR_DISABLED); +// #endif + lglw_mouse_grab(global_ui->window.lglw, LGLW_MOUSE_GRAB_WARP); + } + } void windowCursorUnlock() { - if (global_ui->window.gAllowCursorLock) { - glfwSetInputMode(global_ui->window.gWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL); - } + if (global_ui->window.gAllowCursorLock) { + // glfwSetInputMode(global_ui->window.gWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL); + lglw_mouse_ungrab(global_ui->window.lglw); + } } bool windowIsModPressed() { -#ifdef ARCH_MAC - return glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS; -#else - return glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS; -#endif +// #ifdef ARCH_MAC +// return glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS; +// #else +// return glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS; +// #endif + return (0u != (lglw_keyboard_get_modifiers(global_ui->window.lglw) & (LGLW_KMOD_LCTRL | LGLW_KMOD_RCTRL))); } bool windowIsShiftPressed() { - return glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; + // return glfwGetKey(global_ui->window.gWindow, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(global_ui->window.gWindow, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; + return (0u != (lglw_keyboard_get_modifiers(global_ui->window.lglw) & (LGLW_KMOD_LSHIFT | LGLW_KMOD_RSHIFT))); } Vec windowGetWindowSize() { int width, height; - glfwGetWindowSize(global_ui->window.gWindow, &width, &height); + lglw_window_size_get(global_ui->window.lglw, &width, &height); + // glfwGetWindowSize(global_ui->window.gWindow, &width, &height); return Vec(width, height); } void windowSetWindowSize(Vec size) { int width = size.x; int height = size.y; - glfwSetWindowSize(global_ui->window.gWindow, width, height); + // glfwSetWindowSize(global_ui->window.gWindow, width, height); } Vec windowGetWindowPos() { int x, y; - glfwGetWindowPos(global_ui->window.gWindow, &x, &y); + // glfwGetWindowPos(global_ui->window.gWindow, &x, &y); + x = 0; + y = 0; return Vec(x, y); } void windowSetWindowPos(Vec pos) { int x = pos.x; int y = pos.y; - glfwSetWindowPos(global_ui->window.gWindow, x, y); + // glfwSetWindowPos(global_ui->window.gWindow, x, y); } bool windowIsMaximized() { - if(global_ui->window.gWindow) - return glfwGetWindowAttrib(global_ui->window.gWindow, GLFW_MAXIMIZED); - else - return false; + // if(global_ui->window.gWindow) + // return glfwGetWindowAttrib(global_ui->window.gWindow, GLFW_MAXIMIZED); + // else + // return false; + return true; } void windowSetTheme(NVGcolor bg, NVGcolor fg) { @@ -683,21 +943,22 @@ void windowSetTheme(NVGcolor bg, NVGcolor fg) { } void windowSetFullScreen(bool fullScreen) { - if (windowGetFullScreen()) { - glfwSetWindowMonitor(global_ui->window.gWindow, NULL, global_ui->window.windowX, global_ui->window.windowY, global_ui->window.windowWidth, global_ui->window.windowHeight, GLFW_DONT_CARE); - } - else { - glfwGetWindowPos(global_ui->window.gWindow, &global_ui->window.windowX, &global_ui->window.windowY); - glfwGetWindowSize(global_ui->window.gWindow, &global_ui->window.windowWidth, &global_ui->window.windowHeight); - GLFWmonitor *monitor = glfwGetPrimaryMonitor(); - const GLFWvidmode* mode = glfwGetVideoMode(monitor); - glfwSetWindowMonitor(global_ui->window.gWindow, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); - } + // if (windowGetFullScreen()) { + // glfwSetWindowMonitor(global_ui->window.gWindow, NULL, global_ui->window.windowX, global_ui->window.windowY, global_ui->window.windowWidth, global_ui->window.windowHeight, GLFW_DONT_CARE); + // } + // else { + // glfwGetWindowPos(global_ui->window.gWindow, &global_ui->window.windowX, &global_ui->window.windowY); + // glfwGetWindowSize(global_ui->window.gWindow, &global_ui->window.windowWidth, &global_ui->window.windowHeight); + // GLFWmonitor *monitor = glfwGetPrimaryMonitor(); + // const GLFWvidmode* mode = glfwGetVideoMode(monitor); + // glfwSetWindowMonitor(global_ui->window.gWindow, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); + // } } bool windowGetFullScreen() { - GLFWmonitor *monitor = glfwGetWindowMonitor(global_ui->window.gWindow); - return monitor != NULL; + // GLFWmonitor *monitor = glfwGetWindowMonitor(global_ui->window.gWindow); + // return monitor != NULL; + return false; } @@ -706,6 +967,7 @@ bool windowGetFullScreen() { //////////////////// Font::Font(const std::string &filename) { + printf("xxx vstrack: Font::Font\n"); handle = nvgCreateFont(global_ui->window.gVg, filename.c_str(), filename.c_str()); if (handle >= 0) { info("Loaded font %s", filename.c_str()); @@ -731,6 +993,7 @@ std::shared_ptr Font::load(const std::string &filename) { //////////////////// Image::Image(const std::string &filename) { + printf("xxx vstrack: Image::Image\n"); handle = nvgCreateImage(global_ui->window.gVg, filename.c_str(), NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); if (handle > 0) { info("Loaded image %s", filename.c_str()); @@ -757,6 +1020,7 @@ std::shared_ptr Image::load(const std::string &filename) { //////////////////// SVG::SVG(const std::string &filename) { + printf("xxx vstrack: SVG::SVG\n"); // printf("xxx SVG::SVG: ENTER\n"); handle = nsvgParseFromFile(filename.c_str(), "px", SVG_DPI); // printf("xxx SVG::SVG: handle=%p\n"); diff --git a/vst2_bin/CHANGELOG_VST.txt b/vst2_bin/CHANGELOG_VST.txt index d997fa12..91496d73 100644 --- a/vst2_bin/CHANGELOG_VST.txt +++ b/vst2_bin/CHANGELOG_VST.txt @@ -1,3 +1,11 @@ +** August 5th, 2018 +- replace GLFW window / input event handling by LGLW library + => no more "dummy" windows + => automation should now work in all DAWs + => effect and instrument plugins may now be used in the same DAW project +- window size can now be configured via settings.json "windowSize" property + + ** July 26th, 2018 - fix effect processing in Cubase 9.5.30 diff --git a/vst2_bin/README_vst2.txt b/vst2_bin/README_vst2.txt index bffd35a6..cfad53be 100644 --- a/vst2_bin/README_vst2.txt +++ b/vst2_bin/README_vst2.txt @@ -1,5 +1,5 @@ -VeeSeeVST Rack VST 2.4 Plugin -- July 26th, 2018 -================================================ +VeeSeeVST Rack VST 2.4 Plugin -- August 5th, 2018 +================================================= !!!------------------------------------------------------------------------------ !!! ***** THIS IS NOT AN OFFICIAL VCV RACK RELEASE ***** !!! @@ -16,8 +16,6 @@ This is a quick'n'dirty adaption of VCV Rack 0.6.1 for the VST2 format. + supports VST program chunks (=> patches are saved with the DAW's project file or as .fxp files) + supports VST host timing (audioMasterGetTime / kVstTempoValid / kVstTransportPlaying, see Core.MIDI-1 module) + supports VST parameters (send / recv) -- does not support plugin DLLs due to VCV Rack's architecture which prevents this when it is run as a plugin itself - - future releases will contain additional (open source) add-ons modules Here's a demo video of it: https://vimeo.com/277703414 @@ -25,6 +23,8 @@ Tested in - Eureka (my own work-in-progress VST host) - Cockos Reaper - Propellerhead Reason 10 + - Steinberg Cubase Pro 9.5.30 + - LMMS 1.2.0-rc6 The VST2 plugin includes the following add-on modules: - Alikins.IdleSwitch diff --git a/vst2_bin/log.txt b/vst2_bin/log.txt index 4e1e2d1e..8627ec3c 100644 --- a/vst2_bin/log.txt +++ b/vst2_bin/log.txt @@ -1,6 +1,6 @@ -[0.000 info src/main.cpp:63] VeeSeeVST Rack 0.6.1 -[0.000 info src/main.cpp:66] Global directory: f:\git\VeeSeeVSTRack\vst2_bin\/ -[0.000 info src/main.cpp:67] Local directory: f:\git\VeeSeeVSTRack\vst2_bin\/ +[0.000 info src/main.cpp:59] VeeSeeVST Rack 0.6.1 +[0.000 info src/main.cpp:62] Global directory: F:\git\VeeSeeVSTRack\vst2_bin\/ +[0.000 info src/main.cpp:63] Local directory: F:\git\VeeSeeVSTRack\vst2_bin\/ [0.000 info src/plugin.cpp:673] vcvrack: Loaded static plugin Alikins 0.6.1 [0.000 info src/plugin.cpp:673] vcvrack: Loaded static plugin AS 0.6.1 [0.000 info src/plugin.cpp:673] vcvrack: Loaded static plugin AudibleInstruments 0.6.1 @@ -22,12 +22,12 @@ [0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin Koralfx-Modules 0.6.1 [0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin LindenbergResearch 0.6.1 [0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin LOGinstruments 0.6.1 -[0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin ML_modules 0.6.1 -[0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin moDllz 0.6.1 -[0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin modular80 0.6.1 -[0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin mscHack 0.6.1 -[0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin mtsch-plugins 0.6.1 -[0.001 info src/plugin.cpp:673] vcvrack: Loaded static plugin NauModular 0.6.1 +[0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin ML_modules 0.6.1 +[0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin moDllz 0.6.1 +[0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin modular80 0.6.1 +[0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin mscHack 0.6.1 +[0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin mtsch-plugins 0.6.1 +[0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin NauModular 0.6.1 [0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin Ohmer 0.6.1 [0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin Qwelk 0.6.1 [0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin RJModules 0.6.1 @@ -40,74 +40,58 @@ [0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin trowaSoft 0.6.1 [0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin unless_modules 0.6.1 [0.002 info src/plugin.cpp:673] vcvrack: Loaded static plugin Valley 0.6.1 -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Alikins/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/AS/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/AudibleInstruments/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/BaconMusic/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Befaco/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Bidoo/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Bogaudio/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/BOKONTEPByteBeatMachine/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/cf/plugin.dll does not exist -[0.002 info src/plugin.cpp:155] Loaded plugin dBiz 0.6.1 from f:\git\VeeSeeVSTRack\vst2_bin\/plugins/dBiz/plugin.dll -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/DHE-Modules/plugin.dll does not exist -[0.002 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/DrumKit/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/ErraticInstruments/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/ESeries/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/FrozenWasteland/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Fundamental/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Gratrix/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/HetrickCV/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/huaba/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/JW-Modules/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Koralfx-Modules/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/LindenbergResearch/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/LOGinstruments/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/ML_modules/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/moDllz/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/modular80/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/mscHack/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/mtsch-plugins/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/NauModular/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Ohmer/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Qwelk/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/RJModules/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/SerialRacker/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/SonusModular/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Southpole-parasites/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/squinkylabs-plug1/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/SubmarineFree/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Template/plugin.dll does not exist -[0.003 info src/plugin.cpp:155] Loaded plugin Template_shared 0.6.1 from f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Template_shared/plugin.dll -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/trowaSoft/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/unless_modules/plugin.dll does not exist -[0.003 warn src/plugin.cpp:86] Plugin file f:\git\VeeSeeVSTRack\vst2_bin\/plugins/Valley/plugin.dll does not exist -[0.003 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_146097_cc.svg -[0.003 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_31859_cc.svg -[0.004 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1343816_cc.svg -[0.004 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1343811_cc.svg -[0.004 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1084369_cc.svg -[0.004 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1745061_cc.svg -[0.004 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1240789_cc.svg -[0.004 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_305536_cc.svg -[0.004 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_468341_cc.svg -[0.186 info src/window.cpp:711] Loaded font f:\git\VeeSeeVSTRack\vst2_bin\/res/fonts/DejaVuSans.ttf -[0.187 info src/settings.cpp:185] Loading settings f:\git\VeeSeeVSTRack\vst2_bin\/settings.json -[0.191 info src/app/RackWidget.cpp:158] Saving patch to string -[0.288 info src/app/RackWidget.cpp:196] Loading patch from string -[0.290 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/Core/MIDIToCVInterface.svg -[0.290 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/ComponentLibrary/ScrewSilver.svg -[0.290 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/ComponentLibrary/PJ301M.svg -[0.290 info src/window.cpp:711] Loaded font f:\git\VeeSeeVSTRack\vst2_bin\/res/fonts/ShareTechMono-Regular.ttf -[0.291 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\plugins/Fundamental/res/ADSR.svg -[0.291 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/ComponentLibrary/RoundLargeBlackKnob.svg -[0.292 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\plugins/Fundamental/res/VCO-1.svg -[0.292 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/ComponentLibrary/CKSS_0.svg -[0.292 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/ComponentLibrary/CKSS_1.svg -[0.292 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/ComponentLibrary/RoundHugeBlackKnob.svg -[0.293 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\plugins/Fundamental/res/VCA.svg -[0.294 info src/window.cpp:764] Loaded SVG f:\git\VeeSeeVSTRack\vst2_bin\/res/Core/AudioInterface.svg -[61.404 info src/app/RackWidget.cpp:158] Saving patch to string -[62.652 info src/app/RackWidget.cpp:158] Saving patch to string -[65.283 info src/app/RackWidget.cpp:158] Saving patch to string -[72.333 info src/app/RackWidget.cpp:158] Saving patch to string +[0.002 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Alikins/plugin.dll does not exist +[0.002 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/AS/plugin.dll does not exist +[0.002 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/AudibleInstruments/plugin.dll does not exist +[0.002 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/BaconMusic/plugin.dll does not exist +[0.002 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Befaco/plugin.dll does not exist +[0.002 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Bidoo/plugin.dll does not exist +[0.002 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Bogaudio/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/BOKONTEPByteBeatMachine/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/cf/plugin.dll does not exist +[0.003 info src/plugin.cpp:155] Loaded plugin dBiz 0.6.1 from F:\git\VeeSeeVSTRack\vst2_bin\/plugins/dBiz/plugin.dll +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/DHE-Modules/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/DrumKit/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/ErraticInstruments/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/ESeries/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/FrozenWasteland/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Fundamental/plugin.dll does not exist +[0.003 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Gratrix/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/HetrickCV/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/huaba/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/JW-Modules/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Koralfx-Modules/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/LindenbergResearch/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/LOGinstruments/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/ML_modules/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/moDllz/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/modular80/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/mscHack/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/mtsch-plugins/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/NauModular/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Ohmer/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Qwelk/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/RJModules/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/SerialRacker/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/SonusModular/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Southpole-parasites/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/squinkylabs-plug1/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/SubmarineFree/plugin.dll does not exist +[0.004 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Template/plugin.dll does not exist +[0.005 info src/plugin.cpp:155] Loaded plugin Template_shared 0.6.1 from F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Template_shared/plugin.dll +[0.005 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/trowaSoft/plugin.dll does not exist +[0.005 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/unless_modules/plugin.dll does not exist +[0.005 warn src/plugin.cpp:86] Plugin file F:\git\VeeSeeVSTRack\vst2_bin\/plugins/Valley/plugin.dll does not exist +[0.005 info src/settings.cpp:194] Loading settings F:\git\VeeSeeVSTRack\vst2_bin\/settings.json +[0.030 info src/window.cpp:973] Loaded font F:\git\VeeSeeVSTRack\vst2_bin\/res/fonts/DejaVuSans.ttf +[0.030 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_146097_cc.svg +[0.030 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_31859_cc.svg +[0.031 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1343816_cc.svg +[0.031 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1343811_cc.svg +[0.031 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1084369_cc.svg +[0.031 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1745061_cc.svg +[0.031 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_1240789_cc.svg +[0.031 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_305536_cc.svg +[0.031 info src/window.cpp:1028] Loaded SVG F:\git\VeeSeeVSTRack\vst2_bin\/res/icons/noun_468341_cc.svg +[0.031 info src/settings.cpp:194] Loading settings F:\git\VeeSeeVSTRack\vst2_bin\/settings.json +[0.032 info src/app/RackWidget.cpp:158] Saving patch to string diff --git a/vst2_bin/plugins/Template_shared/plugin.dll b/vst2_bin/plugins/Template_shared/plugin.dll index 696aff87..9973762c 100644 Binary files a/vst2_bin/plugins/Template_shared/plugin.dll and b/vst2_bin/plugins/Template_shared/plugin.dll differ diff --git a/vst2_bin/plugins/dBiz/plugin.dll b/vst2_bin/plugins/dBiz/plugin.dll index b6bf9ed4..57408b1b 100644 Binary files a/vst2_bin/plugins/dBiz/plugin.dll and b/vst2_bin/plugins/dBiz/plugin.dll differ diff --git a/vst2_bin/settings.json b/vst2_bin/settings.json index d194953f..b23026d0 100644 --- a/vst2_bin/settings.json +++ b/vst2_bin/settings.json @@ -2,14 +2,14 @@ "token": "", "windowSize": [ 1240.0, - 810.0 + 820.0 ], "windowPos": [ 60.0, 83.0 ], "wireOpacity": 50.0, - "wireTension": 1.0, + "wireTension": 0.97, "zoom": 1.0, "allowCursorLock": true, "sampleRate": 44100.0, diff --git a/vst2_bin/veeseevstrack_instr.dll__ b/vst2_bin/veeseevstrack_instr.dll__ deleted file mode 100644 index af5f7f9a..00000000 Binary files a/vst2_bin/veeseevstrack_instr.dll__ and /dev/null differ diff --git a/vst2_common.mk b/vst2_common.mk index 4d603ae4..a09c54f3 100644 --- a/vst2_common.mk +++ b/vst2_common.mk @@ -3,7 +3,7 @@ # # -EXTRAFLAGS+= -DVERSION=0.6.1 -D_USE_MATH_DEFINES -Iinclude/ -Idep/include -DUSE_VST2 +EXTRAFLAGS+= -DVERSION=0.6.1 -D_USE_MATH_DEFINES -Iinclude/ -Idep/include -Idep/ -DUSE_VST2 include vst2_common_msvc_pre.mk diff --git a/vst2_common_msvc_pre.mk b/vst2_common_msvc_pre.mk index 783a31d9..1d401c70 100644 --- a/vst2_common_msvc_pre.mk +++ b/vst2_common_msvc_pre.mk @@ -10,6 +10,7 @@ else EXTRALIBS+= -LIBPATH:dep/lib/msvc/x86 endif -EXTRALIBS+= libspeexdsp.lib glew.lib glfw.lib opengl32.lib gdi32.lib user32.lib kernel32.lib Comdlg32.lib Shell32.lib ws2_32.lib winmm.lib +EXTRALIBS+= libspeexdsp.lib glew.lib opengl32.lib gdi32.lib user32.lib kernel32.lib Comdlg32.lib Shell32.lib ws2_32.lib winmm.lib +#glfw.lib plugin_lib = $(PLUGIN_DIR)/$(1)/$(1).lib