@@ -70,6 +70,7 @@ namespace rack { \ | |||||
plugin = p; \ | plugin = p; \ | ||||
global = plugin->global; \ | global = plugin->global; \ | ||||
global_ui = plugin->global_ui; \ | 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; \ | hashtable_seed = p->json.hashtable_seed; \ | ||||
seed_initialized = p->json.seed_initialized; \ | 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 pluginDestroy(); | ||||
void pluginLogIn(std::string email, std::string password); | void pluginLogIn(std::string email, std::string password); | ||||
void pluginLogOut(); | void pluginLogOut(); | ||||
@@ -5,7 +5,8 @@ include ../../../build_shared_plugin_pre.mk | |||||
include make.objects | include make.objects | ||||
define BIN_POST_FXN | 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 | endef | ||||
include ../../../build_shared_plugin_post.mk | include ../../../build_shared_plugin_post.mk |
@@ -5,7 +5,8 @@ include ../../../build_shared_plugin_pre.mk | |||||
include make.objects | include make.objects | ||||
define BIN_POST_FXN | 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 | endef | ||||
include ../../../build_shared_plugin_post.mk | 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 | #endif // USE_VST2 | ||||
@@ -29,7 +29,7 @@ YAC_TLS rack::GlobalUI *rack::global_ui; | |||||
#ifdef USE_VST2 | #ifdef USE_VST2 | ||||
int vst2_init(int argc, char* argv[]) { | |||||
int vst2_init(int argc, char* argv[], bool _bFX) { | |||||
bool devMode = false; | bool devMode = false; | ||||
std::string patchFile; | std::string patchFile; | ||||
@@ -63,7 +63,7 @@ int vst2_init(int argc, char* argv[]) { | |||||
info("Local directory: %s", assetLocal("").c_str()); | info("Local directory: %s", assetLocal("").c_str()); | ||||
// Initialize app | // Initialize app | ||||
pluginInit(devMode); | |||||
pluginInit(devMode, _bFX); | |||||
engineInit(); | engineInit(); | ||||
#ifndef USE_VST2 | #ifndef USE_VST2 | ||||
rtmidiInit(); | rtmidiInit(); | ||||
@@ -70,13 +70,13 @@ void Plugin::addModel(Model *model) { | |||||
// private API | // private API | ||||
//////////////////// | //////////////////// | ||||
static bool loadPlugin(std::string path) { | |||||
static bool loadPlugin(std::string path, bool _bFX) { | |||||
#ifdef RACK_HOST | #ifdef RACK_HOST | ||||
std::string libraryFilename; | std::string libraryFilename; | ||||
#if ARCH_LIN | #if ARCH_LIN | ||||
libraryFilename = path + "/" + "plugin.so"; | libraryFilename = path + "/" + "plugin.so"; | ||||
#elif ARCH_WIN | #elif ARCH_WIN | ||||
libraryFilename = path + "/" + "plugin.dll"; | |||||
libraryFilename = path + "/" + "plugin.dll" + (_bFX ? ".fx" : ".instr"); | |||||
#elif ARCH_MAC | #elif ARCH_MAC | ||||
libraryFilename = path + "/" + "plugin.dylib"; | libraryFilename = path + "/" + "plugin.dylib"; | ||||
#endif | #endif | ||||
@@ -138,6 +138,7 @@ static bool loadPlugin(std::string path) { | |||||
plugin->vst2_queue_param_sync_fxn = &vst2_queue_param_sync; | plugin->vst2_queue_param_sync_fxn = &vst2_queue_param_sync; | ||||
plugin->global = global; | plugin->global = global; | ||||
plugin->global_ui = global_ui; | plugin->global_ui = global_ui; | ||||
printf("xxx vstrack_plugin: loadPlugin: global=%p plugin->global=%p\n", global, plugin->global); | |||||
#endif // RACK_HOST | #endif // RACK_HOST | ||||
#endif // USE_VST2 | #endif // USE_VST2 | ||||
initCallback(plugin); | initCallback(plugin); | ||||
@@ -252,13 +253,13 @@ static bool syncPlugin(std::string slug, json_t *manifestJ, bool dryRun) { | |||||
#endif // USE_VST2 | #endif // USE_VST2 | ||||
} | } | ||||
static void loadPlugins(std::string path) { | |||||
static void loadPlugins(std::string path, bool _bFX) { | |||||
#ifdef RACK_HOST | #ifdef RACK_HOST | ||||
std::string message; | std::string message; | ||||
for (std::string pluginPath : systemListEntries(path)) { | for (std::string pluginPath : systemListEntries(path)) { | ||||
if (!systemIsDirectory(pluginPath)) | if (!systemIsDirectory(pluginPath)) | ||||
continue; | continue; | ||||
if (!loadPlugin(pluginPath)) { | |||||
if (!loadPlugin(pluginPath, _bFX)) { | |||||
#ifndef USE_VST2 | #ifndef USE_VST2 | ||||
// (note) skip message (some plugins are linked statically in VST2 build) | // (note) skip message (some plugins are linked statically in VST2 build) | ||||
message += stringf("Could not load plugin %s\n", pluginPath.c_str()); | message += stringf("Could not load plugin %s\n", pluginPath.c_str()); | ||||
@@ -376,7 +377,7 @@ static void extractPackages(std::string path) { | |||||
// public API | // public API | ||||
//////////////////// | //////////////////// | ||||
void pluginInit(bool devMode) { | |||||
void pluginInit(bool devMode, bool _bFX) { | |||||
tagsInit(); | tagsInit(); | ||||
#ifdef RACK_HOST | #ifdef RACK_HOST | ||||
@@ -411,7 +412,7 @@ void pluginInit(bool devMode) { | |||||
#endif // USE_VST2 | #endif // USE_VST2 | ||||
// Load/init dynamically loaded plugins | // Load/init dynamically loaded plugins | ||||
loadPlugins(localPlugins); | |||||
loadPlugins(localPlugins, _bFX); | |||||
#endif // RACK_HOST | #endif // RACK_HOST | ||||
} | } | ||||
@@ -775,11 +776,16 @@ void vst2_set_shared_plugin_tls_globals(void) { | |||||
// Called in audio thread (see vst2_main.cpp:VSTPluginProcessReplacingFloat32()) | // Called in audio thread (see vst2_main.cpp:VSTPluginProcessReplacingFloat32()) | ||||
for(Plugin *p : global->plugin.gPlugins) { | for(Plugin *p : global->plugin.gPlugins) { | ||||
if(NULL != p->set_tls_globals_fxn) { | 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.hashtable_seed = hashtable_seed; | ||||
p->json.seed_initialized = seed_initialized; | p->json.seed_initialized = seed_initialized; | ||||
p->set_tls_globals_fxn(p); | 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 | /// created: 25Jun2018 | ||||
/// changed: 26Jun2018, 27Jun2018, 29Jun2018, 01Jul2018, 02Jul2018, 06Jul2018, 13Jul2018 | /// changed: 26Jun2018, 27Jun2018, 29Jun2018, 01Jul2018, 02Jul2018, 06Jul2018, 13Jul2018 | ||||
/// 26Jul2018, 04Aug2018, 05Aug2018, 06Aug2018, 07Aug2018, 09Aug2018, 11Aug2018 | /// 26Jul2018, 04Aug2018, 05Aug2018, 06Aug2018, 07Aug2018, 09Aug2018, 11Aug2018 | ||||
/// 18Aug2018, 19Aug2018, 05Sep2018 | |||||
/// 18Aug2018, 19Aug2018, 05Sep2018, 06Sep2018 | |||||
/// | /// | ||||
/// | /// | ||||
@@ -69,7 +69,7 @@ typedef union mem_u { | |||||
sF32 f32; | sF32 f32; | ||||
} mem_t; | } 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); | extern void vst2_exit (void); | ||||
namespace rack { | namespace rack { | ||||
extern void vst2_editor_redraw (void); | 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 void vst2_handle_queued_params (void); | ||||
extern float vst2_get_param (int uniqueParamId); | extern float vst2_get_param (int uniqueParamId); | ||||
extern void vst2_get_param_name (int uniqueParamId, char *s, int sMaxLen); | 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); | extern "C" extern int vst2_handle_effeditkeydown (unsigned int _vkey); | ||||
namespace rack { | namespace rack { | ||||
@@ -540,7 +540,13 @@ public: | |||||
//argv[0] = (char*)cwd.chars; | //argv[0] = (char*)cwd.chars; | ||||
argv[0] = (char*)dllnameraw; | argv[0] = (char*)dllnameraw; | ||||
Dprintf("xxx vstrack_plugin::openEffect: dllname=\"%s\"\n", argv[0]); | 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"); | Dprintf("xxx vstrack_plugin::openEffect: vst2_init() done\n"); | ||||
vst2_set_shared_plugin_tls_globals(); | 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) | // 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); | VSTPluginWrapper *wrapper = static_cast<VSTPluginWrapper *>(vstPlugin->object); | ||||
wrapper->lockAudio(); | |||||
// // wrapper->lockAudio(); | |||||
wrapper->setGlobals(); | wrapper->setGlobals(); | ||||
rack::global_ui->app.mtx_param.lock(); | |||||
vst2_queue_param(index, parameter, true/*bNormalized*/); | 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) { | 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); | printf("xxx vst2_queue_param_sync ENTER: uniqueParamId=%d value=%f bNormalized=%d\n", _uniqueParamId, _value, _bNormalized); | ||||
VSTPluginWrapper *wrapper = rack::global->vst2.wrapper; | VSTPluginWrapper *wrapper = rack::global->vst2.wrapper; | ||||
wrapper->lockAudio(); | |||||
// // wrapper->lockAudio(); | |||||
rack::global_ui->app.mtx_param.lock(); | |||||
vst2_queue_param(_uniqueParamId, _value, _bNormalized); | 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"); | 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) { | void vst2_handle_ui_param(int uniqueParamId, float normValue) { | ||||
// Called by engineSetParam() | // 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); | 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) { | void vst2_set_globals(void *_wrapper) { | ||||
VSTPluginWrapper *wrapper = (VSTPluginWrapper *)_wrapper; | VSTPluginWrapper *wrapper = (VSTPluginWrapper *)_wrapper; | ||||
wrapper->setGlobals(); | wrapper->setGlobals(); | ||||
vst2_set_shared_plugin_tls_globals(); | |||||
} | } | ||||
void vst2_window_size_set(int _width, int _height) { | void vst2_window_size_set(int _width, int _height) { | ||||
@@ -2135,7 +2147,7 @@ VST_EXPORT VSTPlugin *VSTPluginMain(VSTHostCallback vstHostCallback) { | |||||
CCONST('g', 'v', 'g', 'y'), | CCONST('g', 'v', 'g', 'y'), | ||||
#else | #else | ||||
CCONST('v', '5', 'k', 'v'), | CCONST('v', '5', 'k', 'v'), | ||||
#endif | |||||
#endif // VST2_EFFECT | |||||
PLUGIN_VERSION, // version | PLUGIN_VERSION, // version | ||||
VST2_MAX_UNIQUE_PARAM_IDS, // num params | VST2_MAX_UNIQUE_PARAM_IDS, // num params | ||||
1, // one program | 1, // one program | ||||
@@ -54,8 +54,9 @@ namespace rack { | |||||
extern "C" { | extern "C" { | ||||
static void lglw_mouse_cbk(lglw_t _lglw, int32_t _x, int32_t _y, uint32_t _buttonState, uint32_t _changedButtonState) { | 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)); | 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) 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 | // (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) | // if(0u != _changedButtonState) | ||||
lglw_glcontext_pop(global_ui->window.lglw); | 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) { | static void lglw_focus_cbk(lglw_t _lglw, uint32_t _focusState, uint32_t _changedFocusState) { | ||||