| @@ -70,6 +70,7 @@ namespace rack { \ | |||
| plugin = p; \ | |||
| global = plugin->global; \ | |||
| global_ui = plugin->global_ui; \ | |||
| /*printf("xxx plugin:loc_set_tls_globals: &global=%p global=%p\n", &global, plugin->global);*/ \ | |||
| hashtable_seed = p->json.hashtable_seed; \ | |||
| seed_initialized = p->json.seed_initialized; \ | |||
| } \ | |||
| @@ -235,7 +236,7 @@ struct Model { | |||
| }; | |||
| void pluginInit(bool devMode); | |||
| void pluginInit(bool devMode, bool _bFX); | |||
| void pluginDestroy(); | |||
| void pluginLogIn(std::string email, std::string password); | |||
| void pluginLogOut(); | |||
| @@ -5,7 +5,8 @@ include ../../../build_shared_plugin_pre.mk | |||
| include make.objects | |||
| define BIN_POST_FXN | |||
| cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll | |||
| cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll.fx | |||
| cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll.instr | |||
| endef | |||
| include ../../../build_shared_plugin_post.mk | |||
| @@ -5,7 +5,8 @@ include ../../../build_shared_plugin_pre.mk | |||
| include make.objects | |||
| define BIN_POST_FXN | |||
| cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll | |||
| cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll.fx | |||
| cp -f $(SLUG).dll ../../../../vst2_bin/plugins/$(SLUG)/plugin.dll.instr | |||
| endef | |||
| include ../../../build_shared_plugin_post.mk | |||
| @@ -313,17 +313,6 @@ void engineSetParam(Module *module, int paramId, float value) { | |||
| } | |||
| } | |||
| } | |||
| // else | |||
| // { | |||
| // // Should not be reachable | |||
| // // (note) [bsp] this scale+bias hack should work for most parameters, though | |||
| // // (note) [bsp] => automation curves will look a bit strange, though | |||
| // // (note) [bsp] => this may potentially crash modules which cannot deal with params outside the expected range | |||
| // float normValue = value / 2.0f; | |||
| // normValue += 0.5f; | |||
| // // Call host audioMasterAutomate | |||
| // vst2_handle_ui_param(uniqueParamId, normValue); | |||
| // } | |||
| } | |||
| } | |||
| #endif // USE_VST2 | |||
| @@ -29,7 +29,7 @@ YAC_TLS rack::GlobalUI *rack::global_ui; | |||
| #ifdef USE_VST2 | |||
| int vst2_init(int argc, char* argv[]) { | |||
| int vst2_init(int argc, char* argv[], bool _bFX) { | |||
| bool devMode = false; | |||
| std::string patchFile; | |||
| @@ -63,7 +63,7 @@ int vst2_init(int argc, char* argv[]) { | |||
| info("Local directory: %s", assetLocal("").c_str()); | |||
| // Initialize app | |||
| pluginInit(devMode); | |||
| pluginInit(devMode, _bFX); | |||
| engineInit(); | |||
| #ifndef USE_VST2 | |||
| rtmidiInit(); | |||
| @@ -70,13 +70,13 @@ void Plugin::addModel(Model *model) { | |||
| // private API | |||
| //////////////////// | |||
| static bool loadPlugin(std::string path) { | |||
| static bool loadPlugin(std::string path, bool _bFX) { | |||
| #ifdef RACK_HOST | |||
| std::string libraryFilename; | |||
| #if ARCH_LIN | |||
| libraryFilename = path + "/" + "plugin.so"; | |||
| #elif ARCH_WIN | |||
| libraryFilename = path + "/" + "plugin.dll"; | |||
| libraryFilename = path + "/" + "plugin.dll" + (_bFX ? ".fx" : ".instr"); | |||
| #elif ARCH_MAC | |||
| libraryFilename = path + "/" + "plugin.dylib"; | |||
| #endif | |||
| @@ -138,6 +138,7 @@ static bool loadPlugin(std::string path) { | |||
| plugin->vst2_queue_param_sync_fxn = &vst2_queue_param_sync; | |||
| plugin->global = global; | |||
| plugin->global_ui = global_ui; | |||
| printf("xxx vstrack_plugin: loadPlugin: global=%p plugin->global=%p\n", global, plugin->global); | |||
| #endif // RACK_HOST | |||
| #endif // USE_VST2 | |||
| initCallback(plugin); | |||
| @@ -252,13 +253,13 @@ static bool syncPlugin(std::string slug, json_t *manifestJ, bool dryRun) { | |||
| #endif // USE_VST2 | |||
| } | |||
| static void loadPlugins(std::string path) { | |||
| static void loadPlugins(std::string path, bool _bFX) { | |||
| #ifdef RACK_HOST | |||
| std::string message; | |||
| for (std::string pluginPath : systemListEntries(path)) { | |||
| if (!systemIsDirectory(pluginPath)) | |||
| continue; | |||
| if (!loadPlugin(pluginPath)) { | |||
| if (!loadPlugin(pluginPath, _bFX)) { | |||
| #ifndef USE_VST2 | |||
| // (note) skip message (some plugins are linked statically in VST2 build) | |||
| message += stringf("Could not load plugin %s\n", pluginPath.c_str()); | |||
| @@ -376,7 +377,7 @@ static void extractPackages(std::string path) { | |||
| // public API | |||
| //////////////////// | |||
| void pluginInit(bool devMode) { | |||
| void pluginInit(bool devMode, bool _bFX) { | |||
| tagsInit(); | |||
| #ifdef RACK_HOST | |||
| @@ -411,7 +412,7 @@ void pluginInit(bool devMode) { | |||
| #endif // USE_VST2 | |||
| // Load/init dynamically loaded plugins | |||
| loadPlugins(localPlugins); | |||
| loadPlugins(localPlugins, _bFX); | |||
| #endif // RACK_HOST | |||
| } | |||
| @@ -775,11 +776,16 @@ void vst2_set_shared_plugin_tls_globals(void) { | |||
| // Called in audio thread (see vst2_main.cpp:VSTPluginProcessReplacingFloat32()) | |||
| for(Plugin *p : global->plugin.gPlugins) { | |||
| if(NULL != p->set_tls_globals_fxn) { | |||
| // printf("xxx vcvrack: calling p->set_tls_globals_fxn() global=%p\n", p->global); | |||
| if(0) | |||
| { | |||
| static int xxx = 0; | |||
| if(0 == (++xxx & 255)) | |||
| printf("xxx vstrack_plugin: calling p->set_tls_globals_fxn() global=%p p->global=%p\n", global, p->global); | |||
| } | |||
| p->json.hashtable_seed = hashtable_seed; | |||
| p->json.seed_initialized = seed_initialized; | |||
| p->set_tls_globals_fxn(p); | |||
| // printf("xxx vcvrack: calling p->set_tls_globals_fxn() OK\n"); | |||
| // printf("xxx vstrack_plugin: calling p->set_tls_globals_fxn() OK\n"); | |||
| } | |||
| } | |||
| } | |||
| @@ -18,7 +18,7 @@ | |||
| /// created: 25Jun2018 | |||
| /// changed: 26Jun2018, 27Jun2018, 29Jun2018, 01Jul2018, 02Jul2018, 06Jul2018, 13Jul2018 | |||
| /// 26Jul2018, 04Aug2018, 05Aug2018, 06Aug2018, 07Aug2018, 09Aug2018, 11Aug2018 | |||
| /// 18Aug2018, 19Aug2018, 05Sep2018 | |||
| /// 18Aug2018, 19Aug2018, 05Sep2018, 06Sep2018 | |||
| /// | |||
| /// | |||
| @@ -69,7 +69,7 @@ typedef union mem_u { | |||
| sF32 f32; | |||
| } mem_t; | |||
| extern int vst2_init (int argc, char* argv[]); | |||
| extern int vst2_init (int argc, char* argv[], bool _bFX); | |||
| extern void vst2_exit (void); | |||
| namespace rack { | |||
| extern void vst2_editor_redraw (void); | |||
| @@ -81,7 +81,7 @@ extern void vst2_queue_param (int uniqueParamId, float value, bool bNormalized); | |||
| extern void vst2_handle_queued_params (void); | |||
| 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); | |||
| extern void vst2_set_shared_plugin_tls_globals (void); // see plugin.cpp | |||
| extern "C" extern int vst2_handle_effeditkeydown (unsigned int _vkey); | |||
| namespace rack { | |||
| @@ -540,7 +540,13 @@ public: | |||
| //argv[0] = (char*)cwd.chars; | |||
| argv[0] = (char*)dllnameraw; | |||
| Dprintf("xxx vstrack_plugin::openEffect: dllname=\"%s\"\n", argv[0]); | |||
| (void)vst2_init(argc, argv); | |||
| (void)vst2_init(argc, argv, | |||
| #ifdef VST2_EFFECT | |||
| true/*bFX*/ | |||
| #else | |||
| false/*bFX*/ | |||
| #endif // VST2_EFFECT | |||
| ); | |||
| Dprintf("xxx vstrack_plugin::openEffect: vst2_init() done\n"); | |||
| vst2_set_shared_plugin_tls_globals(); | |||
| @@ -1869,10 +1875,12 @@ void VSTPluginSetParameter(VSTPlugin *vstPlugin, | |||
| // we can get a hold to our C++ class since we stored it in the `object` field (see constructor) | |||
| VSTPluginWrapper *wrapper = static_cast<VSTPluginWrapper *>(vstPlugin->object); | |||
| wrapper->lockAudio(); | |||
| // // wrapper->lockAudio(); | |||
| wrapper->setGlobals(); | |||
| rack::global_ui->app.mtx_param.lock(); | |||
| vst2_queue_param(index, parameter, true/*bNormalized*/); | |||
| wrapper->unlockAudio(); | |||
| rack::global_ui->app.mtx_param.unlock(); | |||
| // // wrapper->unlockAudio(); | |||
| } | |||
| void vst2_queue_param_sync(int _uniqueParamId, float _value, bool _bNormalized) { | |||
| @@ -1880,9 +1888,11 @@ void vst2_queue_param_sync(int _uniqueParamId, float _value, bool _bNormalized) | |||
| printf("xxx vst2_queue_param_sync ENTER: uniqueParamId=%d value=%f bNormalized=%d\n", _uniqueParamId, _value, _bNormalized); | |||
| VSTPluginWrapper *wrapper = rack::global->vst2.wrapper; | |||
| wrapper->lockAudio(); | |||
| // // wrapper->lockAudio(); | |||
| rack::global_ui->app.mtx_param.lock(); | |||
| vst2_queue_param(_uniqueParamId, _value, _bNormalized); | |||
| wrapper->unlockAudio(); | |||
| rack::global_ui->app.mtx_param.unlock(); | |||
| // // wrapper->unlockAudio(); | |||
| printf("xxx vst2_queue_param_sync LEAVE\n"); | |||
| } | |||
| @@ -2019,6 +2029,7 @@ void vst2_unlock_midi_device() { | |||
| void vst2_handle_ui_param(int uniqueParamId, float normValue) { | |||
| // Called by engineSetParam() | |||
| // printf("xxx vst2_handle_ui_param: uniqueParamId=%d &global=%p global=%p wrapper=%p\n", uniqueParamId, &rack::global, rack::global, rack::global->vst2.wrapper); | |||
| rack::global->vst2.wrapper->handleUIParam(uniqueParamId, normValue); | |||
| } | |||
| @@ -2030,6 +2041,7 @@ void vst2_get_timing_info(int *_retPlaying, float *_retBPM, float *_retSongPosPP | |||
| void vst2_set_globals(void *_wrapper) { | |||
| VSTPluginWrapper *wrapper = (VSTPluginWrapper *)_wrapper; | |||
| wrapper->setGlobals(); | |||
| vst2_set_shared_plugin_tls_globals(); | |||
| } | |||
| void vst2_window_size_set(int _width, int _height) { | |||
| @@ -2135,7 +2147,7 @@ VST_EXPORT VSTPlugin *VSTPluginMain(VSTHostCallback vstHostCallback) { | |||
| CCONST('g', 'v', 'g', 'y'), | |||
| #else | |||
| CCONST('v', '5', 'k', 'v'), | |||
| #endif | |||
| #endif // VST2_EFFECT | |||
| PLUGIN_VERSION, // version | |||
| VST2_MAX_UNIQUE_PARAM_IDS, // num params | |||
| 1, // one program | |||
| @@ -54,8 +54,9 @@ namespace rack { | |||
| 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); | |||
| // printf("xxx lglw_mouse_cbk: lglw=%p wrapper=%p p=(%d; %d) bt=0x%08x changedBt=0x%08x\n", _lglw, lglw_userdata_get(_lglw), _x, _y, _buttonState, _changedButtonState); | |||
| vst2_set_globals(lglw_userdata_get(_lglw)); | |||
| // printf("xxx lglw_mouse_cbk: &global=%p global=%p\n", &rack::global, rack::global); | |||
| // (note) assumes that GL context is never touched during regular mouse move | |||
| // (note) mouse clicks may cause new SVGs to be loaded, which in turn may cause new GL textures to be created | |||
| @@ -249,6 +250,8 @@ static void lglw_mouse_cbk(lglw_t _lglw, int32_t _x, int32_t _y, uint32_t _butto | |||
| // if(0u != _changedButtonState) | |||
| lglw_glcontext_pop(global_ui->window.lglw); | |||
| // printf("xxx lglw_mouse_cbk: LEAVE global=%p\n", rack::global); | |||
| } | |||
| static void lglw_focus_cbk(lglw_t _lglw, uint32_t _focusState, uint32_t _changedFocusState) { | |||