bsp2 / VeeSeeVSTRack

Open-source virtual modular synthesizer
http://vcvrack.com/
BSD 3-Clause "New" or "Revised" License
259 stars 29 forks source link

question about an error building on Linux #3

Open davephillips opened 6 years ago

davephillips commented 6 years ago

Greetings ! I mentioned on KVR that I'd try building your plugin for Linux, here's where the make fails:

g++ -Wsuggest-override -std=c++11 -Iinclude -Idep/include -Idep/lib/libzip/include -DVERSION=0.6.1 -MMD -MP -g -O3 -march=nocona -ffast-math -fno-finite-math-only -Wall -Wextra -Wno-unused-parameter -DARCH_LIN -c -o build/src/plugin.cpp.o src/plugin.cpp src/plugin.cpp: In function ‘void rack::pluginInit(bool)’: src/plugin.cpp:356:29: error: ‘init_plugin_Core’ was not declared in this scope init_plugin_Core(corePlugin); ^ compile.mk:64: recipe for target 'build/src/plugin.cpp.o' failed make: *** [build/src/plugin.cpp.o] Error 1

Alas, I have little practical knowledge of C++, so any suggestions are appreciated.

bsp2 commented 6 years ago

Hi Dave,

the plugin cannot be recompiled for Linux without porting it first.

The build system for the plugin does not use automake/configure, i.e. you have to write some makefiles.

Please take a look at how the Windows version is compiled (makefile.msvc, vst2commonmsvc.mk, plugins/community/repos/plugin/makefile.msvc, ..).

Be prepared to fix some things along the way. Maybe some additional code needs to be written or some things need to be debugged.

It shouldn't be too hard but a firm knowledge of C++ and GNU make is needed when you create the makefiles / run into build errors (and you will).

Cheers, bsp

davephillips commented 6 years ago

Thanks, I'll look into those files further and see how far I get. I don't have much time to attempt the port, but I'll give it some effort before giving up. :)

cameronleger commented 6 years ago

Hi @bsp2, I hope you don't mind if we continue conversations here. I can open another issue to talk through this, but I figured Dave would be interested as well.

I appreciate the steps you've taken so far. I was wrong on some of the things and you have quick fixes for them. I'll look through your changes and apply them to my branch. I had made a bunch of similar changes as well for the Makefiles, but I had taken a different route and tweaked them to my liking. One major overhaul of this was bringing the dependencies in as submodules, while keeping this project's Makefiles external to them. I really didn't like that any changes I made in that area was untracked.

I hadn't put this on GitHub yet, but I will soon since I have one more Linux fix to apply that you did not. Basically, the working-directory code in vst2_main is Windows-specific, so I similarly wrapped that with ifdef and made equivalent operations using unistd.h functions. I'll put that in its own branch and send it this way.

I will skip linking issues for now as I've started focusing on lglw. I was going with Xlib replacements, although I may look at some of the higher-level stuff you mentioned. I've done one minor project in C with Xlib so it's not totally foreign. I did try thin archives although moving them around is painful as the paths are relative, and I still had the same issue! I'm starting to think I'm misguided on the issues at hand there and it can be solved with other methods once the port is

bsp2 commented 6 years ago

Hi Cameron,

first of all, thanks for "volunteering" for the Linux port ;)

Your observations were correct. Some of the preprocessor "magic" was non-standard and had to be replaced for the GCC build.

Today I've

What's puzzling me a bit is that the resulting binaries seem to be a bit small, even though the linker definitely pulls in all the object files / archives:

g++ -Wall  -DARCH_X86 -I/usr/include  -DHAVE_HYPOTF -fPIC -I"dep/yac" -DVST2_EFFECT -DVERSION=0.6.1 -D_USE_MATH_DEFINES -Iinclude/ -Idep/include -Idep/ -DUSE_VST2 -DARCH_LIN -I../../dev/vstsdk2.4/pluginterfaces/vst2.x/ -Wall -I"dep/yac" -I/usr/include   -O3 -march=haswell  -c src/vst2_main.cpp -o src/vst2_main.o 
g++ -shared -o "veeseevstrack_effect.so" -Wl,-soname,veeseevstrack_effect.so src/vst2_main.o src/main.o   dep/lib/linux_gcc/x86/libspeexdsp.a dep/lib/linux_gcc/x86/glew.a -lGL plugins/community/repos//21kHz/21kHz.a plugins/community/repos//AmalgamatedHarmonics/AmalgamatedHarmonics.a plugins/community/repos//Alikins/Alikins.a plugins/community/repos//alto777_LFSR/alto777_LFSR.a plugins/community/repos//AS/AS.a plugins/community/repos//AudibleInstruments/AudibleInstruments.a plugins/community/repos//Autodafe/Autodafe.a plugins/community/repos//BaconMusic/BaconMusic.a plugins/community/repos//Befaco/Befaco.a plugins/community/repos//Bidoo/Bidoo.a plugins/community/repos//Bogaudio/Bogaudio.a plugins/community/repos//CastleRocktronics/CastleRocktronics.a plugins/community/repos//cf/cf.a plugins/community/repos//com-soundchasing-stochasm/com-soundchasing-stochasm.a plugins/community/repos//computerscare/computerscare.a plugins/community/repos//DHE-Modules/DHE-Modules.a plugins/community/repos//DrumKit/DrumKit.a plugins/community/repos//ErraticInstruments/ErraticInstruments.a plugins/community/repos//ESeries/ESeries.a plugins/community/repos//FrankBussFormula/FrankBussFormula.a plugins/community/repos//FrozenWasteland/FrozenWasteland.a plugins/community/repos//Fundamental/Fundamental.a plugins/community/repos//Geodesics/Geodesics.a plugins/community/repos//Gratrix/Gratrix.a plugins/community/repos//HetrickCV/HetrickCV.a plugins/community/repos//huaba/huaba.a plugins/community/repos//ImpromptuModular/ImpromptuModular.a plugins/community/repos//JE/JE.a plugins/community/repos//JW-Modules/JW-Modules.a plugins/community/repos//Koralfx-Modules/Koralfx-Modules.a plugins/community/repos//LindenbergResearch/LindenbergResearch.a plugins/community/repos//LOGinstruments/LOGinstruments.a plugins/community/repos//mental/mental.a plugins/community/repos//ML_modules/ML_modules.a plugins/community/repos//moDllz/moDllz.a plugins/community/repos//modular80/modular80.a plugins/community/repos//mscHack/mscHack.a plugins/community/repos//mtsch-plugins/mtsch-plugins.a plugins/community/repos//NauModular/NauModular.a plugins/community/repos//Nohmad/Nohmad.a plugins/community/repos//Ohmer/Ohmer.a plugins/community/repos//PG-Instruments/PG-Instruments.a plugins/community/repos//PvC/PvC.a plugins/community/repos//Qwelk/Qwelk.a plugins/community/repos//RJModules/RJModules.a plugins/community/repos//SerialRacker/SerialRacker.a plugins/community/repos//SonusModular/SonusModular.a plugins/community/repos//Southpole/Southpole.a plugins/community/repos//Southpole-parasites/Southpole-parasites.a plugins/community/repos//squinkylabs-plug1/squinkylabs-plug1.a plugins/community/repos//SubmarineFree/SubmarineFree.a plugins/community/repos//SynthKit/SynthKit.a plugins/community/repos//Template/Template.a plugins/community/repos//TheXOR/TheXOR.a plugins/community/repos//trowaSoft/trowaSoft.a plugins/community/repos//unless_modules/unless_modules.a plugins/community/repos//Valley/Valley.a Rack.a -L/usr/lib -lm 
strip "veeseevstrack_effect.so"
Build finished at 17:52.
make[1]: Leaving directory '/mnt/git/VeeSeeVSTRack'
mv veeseevstrack_instr.so vst2_bin/
mv veeseevstrack_effect.so vst2_bin/
-rwxrwxrwx 1 root root 1539704 Oct 11 17:52 vst2_bin/veeseevstrack_instr.so
-rwxrwxrwx 1 root root 1539704 Oct 11 17:52 vst2_bin/veeseevstrack_effect.so

(the Valley and Drumkit modules contain some rather large waveform sets, ~8mb each)

Good luck with the LGLW port !

I hope we won't need these awful keyboard hook hacks on Linux (I am not even sure they are technically possible).

You also have to know that Rack needs to create a GL context before the VST editor is opened. This wasn't an issue on Windows, I hope the same is true for the Linux OpenGL drivers (it should work since GL contexts are created independently of the window(s) they will later be attached to).

Cheers, Bastian

cameronleger commented 6 years ago

Appreciate the input! Do you mind if I turn those dependencies into git submodules? I found no issues with compiling, of course after running their autoreconfig/configure statements. I noticed one of them had a version bump, but again nothing complained during compilation. I had moved your Makefiles into the dep folder but altered their paths so that they compiled in the right directories. I also included plugin and dep targets in the main Makefile which simply ran the others, so that everything could be accomplished from the main Makefile. I still have to check/migrate my Makefile updates into yours, as I'd prefer to keep whatever format you want in the end.

davephillips commented 6 years ago

Greetings, and thanks for including me in the loop. :) I built from the latest git pull last night and got much further this time. Any suggestions for proceeding ? Btw, I'm on Fedora 23, GCC 5.3.1.

make[1]: Entering directory '/home/dlphilp/src/VeeSeeVSTRack'
g++ -Wall  -DARCH_X86 -I/usr/include  -DHAVE_HYPOTF -fPIC -I"dep/yac" -DVERSION=0.6.1 -D_USE_MATH_DEFINES -Iinclude/ -Idep/include -Idep/ -DUSE_VST2 -fPIC -DARCH_LIN -std=c++11 -I/home/dlphilp/SDKs/vstsdk2.4/pluginterfaces/vst2.x/ -Wall -I"dep/yac" -I/usr/include   -O3 -march=haswell  -c src/vst2_main.cpp -o src/vst2_main.o 
g++ -shared -o "veeseevstrack_instr.so" -Wl,-soname,veeseevstrack_instr.so src/vst2_main.o src/main.o   dep/lib/linux_gcc/x86/libspeexdsp.a dep/lib/linux_gcc/x86/glew.a -lGL plugins/community/repos//AmalgamatedHarmonics/AmalgamatedHarmonics.a plugins/community/repos//Alikins/Alikins.a plugins/community/repos//alto777_LFSR/alto777_LFSR.a plugins/community/repos//AS/AS.a plugins/community/repos//AudibleInstruments/AudibleInstruments.a plugins/community/repos//Autodafe/Autodafe.a plugins/community/repos//Befaco/Befaco.a plugins/community/repos//Bidoo/Bidoo.a plugins/community/repos//Bogaudio/Bogaudio.a plugins/community/repos//cf/cf.a plugins/community/repos//DHE-Modules/DHE-Modules.a plugins/community/repos//DrumKit/DrumKit.a plugins/community/repos//ESeries/ESeries.a plugins/community/repos//FrozenWasteland/FrozenWasteland.a plugins/community/repos//Fundamental/Fundamental.a plugins/community/repos//Geodesics/Geodesics.a plugins/community/repos//Gratrix/Gratrix.a plugins/community/repos//HetrickCV/HetrickCV.a plugins/community/repos//ImpromptuModular/ImpromptuModular.a plugins/community/repos//JE/JE.a plugins/community/repos//JW-Modules/JW-Modules.a plugins/community/repos//Koralfx-Modules/Koralfx-Modules.a plugins/community/repos//LindenbergResearch/LindenbergResearch.a plugins/community/repos//LOGinstruments/LOGinstruments.a plugins/community/repos//ML_modules/ML_modules.a plugins/community/repos//modular80/modular80.a plugins/community/repos//mscHack/mscHack.a plugins/community/repos//mtsch-plugins/mtsch-plugins.a plugins/community/repos//NauModular/NauModular.a plugins/community/repos//Nohmad/Nohmad.a plugins/community/repos//Ohmer/Ohmer.a plugins/community/repos//PG-Instruments/PG-Instruments.a plugins/community/repos//Qwelk/Qwelk.a plugins/community/repos//RJModules/RJModules.a plugins/community/repos//SonusModular/SonusModular.a plugins/community/repos//Southpole/Southpole.a plugins/community/repos//Southpole-parasites/Southpole-parasites.a plugins/community/repos//squinkylabs-plug1/squinkylabs-plug1.a plugins/community/repos//SubmarineFree/SubmarineFree.a plugins/community/repos//SynthKit/SynthKit.a plugins/community/repos//Template/Template.a plugins/community/repos//TheXOR/TheXOR.a plugins/community/repos//trowaSoft/trowaSoft.a plugins/community/repos//unless_modules/unless_modules.a plugins/community/repos//Valley/Valley.a Rack.a -L/usr/lib -lm 
Rack.a(window.o): In function `vst2_set_globals(void*)':
window.cpp:(.text+0x10350): multiple definition of `vst2_set_globals(void*)'
src/vst2_main.o:vst2_main.cpp:(.text+0x8110): first defined here
Rack.a(window.o): In function `vst2_window_size_set(int, int)':
window.cpp:(.text+0x10810): multiple definition of `vst2_window_size_set(int, int)'
src/vst2_main.o:vst2_main.cpp:(.text+0x8150): first defined here
Rack.a(window.o): In function `vst2_refresh_rate_set(float)':
window.cpp:(.text+0x10820): multiple definition of `vst2_refresh_rate_set(float)'
src/vst2_main.o:vst2_main.cpp:(.text+0x81c0): first defined here
/usr/bin/ld: skipping incompatible /usr/lib/libm.so when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
collect2: error: ld returned 1 exit status
dep/yac/sharedlib_linux.mk:31: recipe for target 'bin' failed
make[1]: *** [bin] Error 1
make[1]: Leaving directory '/home/dlphilp/src/VeeSeeVSTRack'
makefile.linux:22: recipe for target 'vst' failed
make: *** [vst] Error 2

[dlphilp@The6300 VeeSeeVSTRack]$ grep --recursive vst2_set_globals *.* .
Binary file Rack.a matches
Binary file Rack_shared.a matches
Binary file ./vst2_bin/plugins/Template_shared/plugin.so.instr matches
Binary file ./vst2_bin/plugins/Template_shared/plugin.so.fx matches
Binary file ./vst2_bin/plugins/bsp/plugin.so.instr matches
Binary file ./vst2_bin/plugins/bsp/plugin.so.fx matches
Binary file ./vst2_bin/plugins/dBiz/plugin.so.instr matches
Binary file ./vst2_bin/plugins/dBiz/plugin.so.fx matches
Binary file ./Rack.a matches
./src/vst2_main.cpp:void vst2_set_globals(void *_wrapper) {
Binary file ./src/window.o matches
./src/window.cpp:extern void vst2_set_globals (void *_wrapper);
./src/window.cpp:void vst2_set_globals(void *) { }
./src/window.cpp:   vst2_set_globals(lglw_userdata_get(_lglw));
./src/window.cpp:   vst2_set_globals(lglw_userdata_get(_lglw));
./src/window.cpp:   vst2_set_globals(lglw_userdata_get(_lglw));
./src/window.cpp:   vst2_set_globals(lglw_userdata_get(_lglw));
Binary file ./src/vst2_main.o matches
Binary file ./plugins/community/repos/Template_shared/Template_shared.so matches
Binary file ./Rack_shared.a matches
bsp2 commented 6 years ago

@cameronleger: I'd prefer to keep the dependencies bundled with the rest of the repo.

One reason for that is that in the MSVC build environment, there is no automake/configure so people need the pre-configured files. Another reason is that some of the sources had to be modified. When you replace them with the original versions (via a submodule), things might still build but they definitely won't work properly.

@davephillips: welcome back :) The build works fine on my machine (Debian 9, GCC 6.3.x) (I just re-tested it). It looks as if the build is using the wrong Rack.a library (Rack_shared.a contains stubs for functions like vst2_window_size_set), or maybe you forgot to clean before building Rack.a (lib) ? (well, I didn't mention this in the readme, which I just updated)

Make sure to follow these build instructions:

$ alias m="make -f makefile.linux"
$ cd dep
$ m clean
$ m bin
$ cd ..
$ m clean
$ m shared_lib
$ cd plugins
$ m clean
$ m bin
$ cd ..
$ m clean
$ m lib
$ m bin

I've just added an all target to the main makefile which performs these steps (following @cameronleger`s suggestion).

p.s.: you can (and should ;)) use markdown when you post build logs and the like (just enclose the text block in three backticks (```)).

cameronleger commented 6 years ago

That's unfortunate about MSVC. Since they were not nested roots or submodules, I couldn't easily tell that they were modified ;) I won't have much time this weekend, but I'll get back to the LGLW port soon.

bsp2 commented 6 years ago

Sorry, I hope you did not invest much time in the submodule change (even I cannot remember which files I changed. jansson I am sure of but I think there were also some (minor) changes to nanovg/blendish.)

In retrospective, I also should have added this preliminary Linux support (i.e. the makefiles) much earlier.

I hope at least the new add-on module Linux makefiles will save you some time now.

cameronleger commented 6 years ago

No worries :)

I thought of a diff between a checkout and your stuff, but I had no idea which commits they came from or if the configure results would be different anyways.

You have saved a lot of time with the Linux makefiles. I had basically done what you did, although with different names. Except that yours have a handful of changes I had no idea I'd need to make, so who knows what problems that would've caused.

davephillips commented 6 years ago

@bsp2 Thanks for the build chart, that did the trick for me. I successfully built veeseevstrack_effects.so and veeseevstrack_instr.so. Alas, neither is recognized by Bitwig 2.3.4 or Ardour. I'll keep working at it.

cameronleger commented 6 years ago

@davephillips there's still quite a bit to be done here before it should work at all, but I'm surprised that you built the end-results. Currently, the LGLW dependency has a generic header which is why everything compiles, but the Linux implementation is only stubs so nothing will happen graphically. I have started to implement this library on Linux, taking notes from the Windows example, but I have no timeframe on that completion.

I am basically unable to compile the end-results. For reference, I had to at least do the following:

  1. Add make -C dep -f makefile.linux install as the third line of the all target, as the dependencies were not being moved to the dep/lib folders thus later steps were failing.
  2. Adjust paths in vst2_common_linux_pre.mk for the location of the VST SDK.
  3. Adjust paths in staticlib_linux.mk for the correct yac folder.
  4. Comment all lines in vst2_common_staticlibs.mk as to not build the extra modules, which are unnecessary at this point.
  5. Comment all module-related lines in makefile.common as to not build the extra modules.

I hit the following error during make all. Is there any reason I can't just convert all usages of static libraries to shared libraries?

g++ -shared -o "veeseevstrack_instr.so" -Wl,-soname,veeseevstrack_instr.so src/vst2_main.o src/main.o   dep/lib/linux_gcc/x64/libspeexdsp.a dep/lib/linux_gcc/x64/glew.a -lGL Rack.a -L/usr/lib -lm 
/usr/bin/ld: Rack.a(RackScene.o): relocation R_X86_64_PC32 against symbol `_ZTVNSt6thread11_State_implINS_8_InvokerISt5tupleIJPFvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEPKcEEEEEE' can not be used when making a shared object; recompile with -fPIC

I tried -fPIC when generating static libs, and it does compile after that. I'm unsure if that's a viable option, though. Even though it compiled, I couldn't even get BWS to try to load the file. nm, ld, and ldd inspections only show one thing that's different from another instrument that loads properly: ld lists a ton of undefined reference to symbols mostly related to jansson and glew.

While so far my LGWL implementations are compiling, it will be hard to test until we can figure out this build process.

bsp2 commented 6 years ago

I've added the missing install make call to the main makefile(s).

There's also a new setenv_linux.sh script which sets the repo basedir (VSVR_BASE_DIR) and VST2 SDK (VST2_SDK_DIR) variables. You need to edit the file and point the VST2_SDK_DIR variable to the right directory. The script then needs to be run once (in the top level dir) before building the repo:

<yourpath>/VeeSeeVSTRack$ . setenv_linux.sh

This should be the only required change (yac is now found via $(VSVR_BASE_DIR)).

You should be able to build the entire repo via

make -f makefile.linux all

You may want to comment out the make invocations for shared_lib and plugins in makefile.linux. Since -DSKIP_STATIC_MODULES is enabled for now (and the include vst2_common_staticlibs.mk is commented out in vst2_common_linux.mk), the module .a files are not actually used.

I've also added a very simple VST debug host which can be used to test whether the plugin can be loaded (and initialized). The debug host also renders some samples (since the patch/rack is empty, these will all be zero).

After fixing some link-order related issues, I ran into a brick wall here:

VeeSeeVSTRack/other/vst2_debug_host$ ./vst2_debug_host
Failed to load library ../../vst2_bin/veeseevstrack_effect.so: ../../vst2_bin/veeseevstrack_effect.so: cannot allocate memory in static TLS block

It turned out that was a huge 128k TLS buffer in yac_host.cpp which fortunately is not actually necessary here so I removed this.

Next was a missing jansson symbol error which could be resolved by changing the build config and adding -DHAVE_ATOMIC_BUILTINS -DHAVE_SCHED_YIELD.

The next missing symbols were related to GTK+ so I added pkg-config gtk+-2.0 --libs.

Now the effect plugin finally loads in the debug host. However, it crashes in openEffect() (last printf was cwd change done).

At this point I noticed that the Linux code to detect the VST plugin directory does not work (it reports the pathname of the host instead). I replaced it with a hard-coded path (for testing purposes).

Next up was a crash in the info() function. I worked around that by setting devmode = true which causes the logger to write to stderr instead of a file (this needs to be fixed later on).

Finally, the plugin now loads and initializes and I get an Could not initialize GLEW error which is probably b/c the VM is not configured for GL 2.0+ (I guess).

The console output up to this point is:

xxx calling mainProc
vstrack_plugin: called VSTPluginMain... 
xxx mainProc returned effect=0xb5e44444
xxx calling effect->dispatcher<effOpen>
vstrack_plugin<dispatcher>: effOpen
xxx vstrack_plugin::openEffect
xxx vstrack_plugin::openEffect: instance_id=1
xxx vstrack_plugin::openEffect: cd to "/mnt/git/VeeSeeVSTRack/vst2_bin/"
xxx vstrack_plugin::openEffect: cwd change done
xxx argv[0]=0xbf93ccd0
xxx vstrack_plugin::openEffect: dllname="/mnt/git/VeeSeeVSTRack/vst2_bin/"
xxx vst2_init: 1
xxx vst2_init: 2
xxx vst2_init: 3
xxx vst2_init: 4 global_ui=0xb55441b0
[0.000 info src/main.cpp:67] VeeSeeVST Rack 0.6.1VeeSeeVST Rack 0.6.1

[0.000 info src/main.cpp:69] Development modeDevelopment mode

[0.000 info src/main.cpp:70] Global directory: ./Global directory: ./

[0.000 info src/main.cpp:71] Local directory: ./Local directory: ./

xxx vst2_init: 5
[0.001 warn src/plugin.cpp:86] Plugin file ./plugins/21kHz/plugin.so does not existPlugin file ./plugins/21kHz/plugin.so does not exist

[0.002 warn src/plugin.cpp:86] Plugin file ./plugins/Alikins/plugin.so does not existPlugin file ./plugins/Alikins/plugin.so does not exist

[0.002 warn src/plugin.cpp:86] Plugin file ./plugins/alto777_LFSR/plugin.so does not existPlugin file ./plugins/alto777_LFSR/plugin.so does not exist

[0.002 warn src/plugin.cpp:86] Plugin file ./plugins/AmalgamatedHarmonics/plugin.so does not existPlugin file ./plugins/AmalgamatedHarmonics/plugin.so does not exist

[0.003 warn src/plugin.cpp:86] Plugin file ./plugins/AS/plugin.so does not existPlugin file ./plugins/AS/plugin.so does not exist

[0.003 warn src/plugin.cpp:86] Plugin file ./plugins/AudibleInstruments/plugin.so does not existPlugin file ./plugins/AudibleInstruments/plugin.so does not exist

[0.003 warn src/plugin.cpp:86] Plugin file ./plugins/Autodafe/plugin.so does not existPlugin file ./plugins/Autodafe/plugin.so does not exist

[0.004 warn src/plugin.cpp:86] Plugin file ./plugins/BaconMusic/plugin.so does not existPlugin file ./plugins/BaconMusic/plugin.so does not exist

[0.004 warn src/plugin.cpp:86] Plugin file ./plugins/Befaco/plugin.so does not existPlugin file ./plugins/Befaco/plugin.so does not exist

[0.004 warn src/plugin.cpp:86] Plugin file ./plugins/Bidoo/plugin.so does not existPlugin file ./plugins/Bidoo/plugin.so does not exist

[0.004 warn src/plugin.cpp:86] Plugin file ./plugins/Bogaudio/plugin.so does not existPlugin file ./plugins/Bogaudio/plugin.so does not exist

[0.005 warn src/plugin.cpp:86] Plugin file ./plugins/BOKONTEPByteBeatMachine/plugin.so does not existPlugin file ./plugins/BOKONTEPByteBeatMachine/plugin.so does not exist

[0.005 warn src/plugin.cpp:86] Plugin file ./plugins/bsp/plugin.so does not existPlugin file ./plugins/bsp/plugin.so does not exist

[0.005 warn src/plugin.cpp:86] Plugin file ./plugins/CastleRocktronics/plugin.so does not existPlugin file ./plugins/CastleRocktronics/plugin.so does not exist

[0.006 warn src/plugin.cpp:86] Plugin file ./plugins/cf/plugin.so does not existPlugin file ./plugins/cf/plugin.so does not exist

[0.006 warn src/plugin.cpp:86] Plugin file ./plugins/com-soundchasing-stochasm/plugin.so does not existPlugin file ./plugins/com-soundchasing-stochasm/plugin.so does not exist

[0.006 warn src/plugin.cpp:86] Plugin file ./plugins/computerscare/plugin.so does not existPlugin file ./plugins/computerscare/plugin.so does not exist

[0.008 warn src/plugin.cpp:86] Plugin file ./plugins/dBiz/plugin.so does not existPlugin file ./plugins/dBiz/plugin.so does not exist

[0.009 warn src/plugin.cpp:86] Plugin file ./plugins/DHE-Modules/plugin.so does not existPlugin file ./plugins/DHE-Modules/plugin.so does not exist

[0.009 warn src/plugin.cpp:86] Plugin file ./plugins/DrumKit/plugin.so does not existPlugin file ./plugins/DrumKit/plugin.so does not exist

[0.010 warn src/plugin.cpp:86] Plugin file ./plugins/ErraticInstruments/plugin.so does not existPlugin file ./plugins/ErraticInstruments/plugin.so does not exist

[0.010 warn src/plugin.cpp:86] Plugin file ./plugins/ESeries/plugin.so does not existPlugin file ./plugins/ESeries/plugin.so does not exist

[0.010 warn src/plugin.cpp:86] Plugin file ./plugins/FrankBussFormula/plugin.so does not existPlugin file ./plugins/FrankBussFormula/plugin.so does not exist

[0.011 warn src/plugin.cpp:86] Plugin file ./plugins/FrozenWasteland/plugin.so does not existPlugin file ./plugins/FrozenWasteland/plugin.so does not exist

[0.011 warn src/plugin.cpp:86] Plugin file ./plugins/Fundamental/plugin.so does not existPlugin file ./plugins/Fundamental/plugin.so does not exist

[0.012 warn src/plugin.cpp:86] Plugin file ./plugins/Geodesics/plugin.so does not existPlugin file ./plugins/Geodesics/plugin.so does not exist

[0.012 warn src/plugin.cpp:86] Plugin file ./plugins/Gratrix/plugin.so does not existPlugin file ./plugins/Gratrix/plugin.so does not exist

[0.013 warn src/plugin.cpp:86] Plugin file ./plugins/HetrickCV/plugin.so does not existPlugin file ./plugins/HetrickCV/plugin.so does not exist

[0.013 warn src/plugin.cpp:86] Plugin file ./plugins/huaba/plugin.so does not existPlugin file ./plugins/huaba/plugin.so does not exist

[0.013 warn src/plugin.cpp:86] Plugin file ./plugins/ImpromptuModular/plugin.so does not existPlugin file ./plugins/ImpromptuModular/plugin.so does not exist

[0.014 warn src/plugin.cpp:86] Plugin file ./plugins/JE/plugin.so does not existPlugin file ./plugins/JE/plugin.so does not exist

[0.014 warn src/plugin.cpp:86] Plugin file ./plugins/JW-Modules/plugin.so does not existPlugin file ./plugins/JW-Modules/plugin.so does not exist

[0.015 warn src/plugin.cpp:86] Plugin file ./plugins/Koralfx-Modules/plugin.so does not existPlugin file ./plugins/Koralfx-Modules/plugin.so does not exist

[0.015 warn src/plugin.cpp:86] Plugin file ./plugins/LindenbergResearch/plugin.so does not existPlugin file ./plugins/LindenbergResearch/plugin.so does not exist

[0.016 warn src/plugin.cpp:86] Plugin file ./plugins/LOGinstruments/plugin.so does not existPlugin file ./plugins/LOGinstruments/plugin.so does not exist

[0.016 warn src/plugin.cpp:86] Plugin file ./plugins/mental/plugin.so does not existPlugin file ./plugins/mental/plugin.so does not exist

[0.017 warn src/plugin.cpp:86] Plugin file ./plugins/ML_modules/plugin.so does not existPlugin file ./plugins/ML_modules/plugin.so does not exist

[0.017 warn src/plugin.cpp:86] Plugin file ./plugins/moDllz/plugin.so does not existPlugin file ./plugins/moDllz/plugin.so does not exist

[0.017 warn src/plugin.cpp:86] Plugin file ./plugins/modular80/plugin.so does not existPlugin file ./plugins/modular80/plugin.so does not exist

[0.018 warn src/plugin.cpp:86] Plugin file ./plugins/mscHack/plugin.so does not existPlugin file ./plugins/mscHack/plugin.so does not exist

[0.018 warn src/plugin.cpp:86] Plugin file ./plugins/mtsch-plugins/plugin.so does not existPlugin file ./plugins/mtsch-plugins/plugin.so does not exist

[0.019 warn src/plugin.cpp:86] Plugin file ./plugins/NauModular/plugin.so does not existPlugin file ./plugins/NauModular/plugin.so does not exist

[0.019 warn src/plugin.cpp:86] Plugin file ./plugins/Nohmad/plugin.so does not existPlugin file ./plugins/Nohmad/plugin.so does not exist

[0.020 warn src/plugin.cpp:86] Plugin file ./plugins/Ohmer/plugin.so does not existPlugin file ./plugins/Ohmer/plugin.so does not exist

[0.020 warn src/plugin.cpp:86] Plugin file ./plugins/PG-Instruments/plugin.so does not existPlugin file ./plugins/PG-Instruments/plugin.so does not exist

[0.020 warn src/plugin.cpp:86] Plugin file ./plugins/PvC/plugin.so does not existPlugin file ./plugins/PvC/plugin.so does not exist

[0.021 warn src/plugin.cpp:86] Plugin file ./plugins/Qwelk/plugin.so does not existPlugin file ./plugins/Qwelk/plugin.so does not exist

[0.021 warn src/plugin.cpp:86] Plugin file ./plugins/RJModules/plugin.so does not existPlugin file ./plugins/RJModules/plugin.so does not exist

[0.022 warn src/plugin.cpp:86] Plugin file ./plugins/SerialRacker/plugin.so does not existPlugin file ./plugins/SerialRacker/plugin.so does not exist

[0.022 warn src/plugin.cpp:86] Plugin file ./plugins/SonusModular/plugin.so does not existPlugin file ./plugins/SonusModular/plugin.so does not exist

[0.023 warn src/plugin.cpp:86] Plugin file ./plugins/Southpole/plugin.so does not existPlugin file ./plugins/Southpole/plugin.so does not exist

[0.023 warn src/plugin.cpp:86] Plugin file ./plugins/Southpole-parasites/plugin.so does not existPlugin file ./plugins/Southpole-parasites/plugin.so does not exist

[0.023 warn src/plugin.cpp:86] Plugin file ./plugins/squinkylabs-plug1/plugin.so does not existPlugin file ./plugins/squinkylabs-plug1/plugin.so does not exist

[0.024 warn src/plugin.cpp:86] Plugin file ./plugins/SubmarineFree/plugin.so does not existPlugin file ./plugins/SubmarineFree/plugin.so does not exist

[0.024 warn src/plugin.cpp:86] Plugin file ./plugins/SynthKit/plugin.so does not existPlugin file ./plugins/SynthKit/plugin.so does not exist

[0.025 warn src/plugin.cpp:86] Plugin file ./plugins/Template/plugin.so does not existPlugin file ./plugins/Template/plugin.so does not exist

[0.025 warn src/plugin.cpp:86] Plugin file ./plugins/Template_shared/plugin.so does not existPlugin file ./plugins/Template_shared/plugin.so does not exist

[0.025 warn src/plugin.cpp:86] Plugin file ./plugins/TheXOR/plugin.so does not existPlugin file ./plugins/TheXOR/plugin.so does not exist

[0.026 warn src/plugin.cpp:86] Plugin file ./plugins/trowaSoft/plugin.so does not existPlugin file ./plugins/trowaSoft/plugin.so does not exist

[0.026 warn src/plugin.cpp:86] Plugin file ./plugins/unless_modules/plugin.so does not existPlugin file ./plugins/unless_modules/plugin.so does not exist

[0.027 warn src/plugin.cpp:86] Plugin file ./plugins/Valley/plugin.so does not existPlugin file ./plugins/Valley/plugin.so does not exist

xxx vst2_init: 6
xxx vst2_init: 7
xxx vst2_init: 8
[0.027 info src/settings.cpp:436] Loading settings ./settings.jsonLoading settings ./settings.json
bsp2 commented 6 years ago

It is now possible to load+init all static and shared add-on modules:

$ ./vst2_debug_host
xxx calling mainProc
vstrack_plugin: called VSTPluginMain... 
xxx mainProc returned effect=0xb2fee444
xxx calling effect->dispatcher<effOpen>
vstrack_plugin<dispatcher>: effOpen
xxx vstrack_plugin::openEffect
xxx vstrack_plugin::openEffect: instance_id=1
xxx vstrack_plugin::openEffect: cd to "/mnt/git/VeeSeeVSTRack/vst2_bin/"
xxx vstrack_plugin::openEffect: cwd change done
xxx argv[0]=0xbfce44d0
xxx vstrack_plugin::openEffect: dllname="/mnt/git/VeeSeeVSTRack/vst2_bin/"
xxx vst2_init: 1
xxx vst2_init: 2
xxx vst2_init: 3
xxx vst2_init: 4 global_ui=0xb26ee1b0
[0.000 info src/main.cpp:67] VeeSeeVST Rack 0.6.1VeeSeeVST Rack 0.6.1

[0.000 info src/main.cpp:69] Development modeDevelopment mode

[0.000 info src/main.cpp:70] Global directory: /mnt/git/VeeSeeVSTRack/vst2_bin//Global directory: /mnt/git/VeeSeeVSTRack/vst2_bin//

[0.000 info src/main.cpp:71] Local directory: /mnt/git/VeeSeeVSTRack/vst2_bin//Local directory: /mnt/git/VeeSeeVSTRack/vst2_bin//

xxx vst2_init: 5
[dbg] vst2_load_static_rack_plugins: ENTER
[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin 21kHz 0.6.1vcvrack: Loaded static plugin 21kHz 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AmalgamatedHarmonics 0.6.1vcvrack: Loaded static plugin AmalgamatedHarmonics 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Alikins 0.6.1vcvrack: Loaded static plugin Alikins 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin alto777_LFSR 0.6.1vcvrack: Loaded static plugin alto777_LFSR 0.6.1

[0.003 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AS 0.6.9vcvrack: Loaded static plugin AS 0.6.9

[0.004 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AudibleInstruments 0.6.1vcvrack: Loaded static plugin AudibleInstruments 0.6.1

[0.004 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Autodafe 0.6.1vcvrack: Loaded static plugin Autodafe 0.6.1

[0.004 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin BaconMusic 0.6.1vcvrack: Loaded static plugin BaconMusic 0.6.1

xxx springReverbInit: irFilename="/mnt/git/VeeSeeVSTRack/vst2_bin/plugins/Befaco/res/SpringReverbIR.pcm"
[0.010 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Befaco 0.6.1vcvrack: Loaded static plugin Befaco 0.6.1

[0.011 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Bidoo 0.6.1vcvrack: Loaded static plugin Bidoo 0.6.1

[0.012 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Bogaudio 0.6.7vcvrack: Loaded static plugin Bogaudio 0.6.7

[0.012 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin CastleRocktronics 0.6.1vcvrack: Loaded static plugin CastleRocktronics 0.6.1

[0.013 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin cf 0.6.1vcvrack: Loaded static plugin cf 0.6.1

[0.013 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin com-soundchasing-stochasm 0.6.1vcvrack: Loaded static plugin com-soundchasing-stochasm 0.6.1

[0.013 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin computerscare 0.6.1vcvrack: Loaded static plugin computerscare 0.6.1

[0.013 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin DHE-Modules 0.6.1vcvrack: Loaded static plugin DHE-Modules 0.6.1

[0.013 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin DrumKit 0.6.1vcvrack: Loaded static plugin DrumKit 0.6.1

[0.013 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin ErraticInstruments 0.6.1vcvrack: Loaded static plugin ErraticInstruments 0.6.1

[0.014 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin ESeries 0.6.1vcvrack: Loaded static plugin ESeries 0.6.1

[0.014 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin FrankBussFormula 0.6.1vcvrack: Loaded static plugin FrankBussFormula 0.6.1

[0.014 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin FrozenWasteland 0.6.1vcvrack: Loaded static plugin FrozenWasteland 0.6.1

[0.015 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Fundamental 0.6.1vcvrack: Loaded static plugin Fundamental 0.6.1

[0.015 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Geodesics 0.6.1vcvrack: Loaded static plugin Geodesics 0.6.1

[0.016 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Gratrix 0.6.1vcvrack: Loaded static plugin Gratrix 0.6.1

[0.016 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin HetrickCV 0.6.1vcvrack: Loaded static plugin HetrickCV 0.6.1

[0.016 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin huaba 0.6.1vcvrack: Loaded static plugin huaba 0.6.1

[0.017 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin ImpromptuModular 0.6.11vcvrack: Loaded static plugin ImpromptuModular 0.6.11

[0.017 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin JE 0.6.1vcvrack: Loaded static plugin JE 0.6.1

[0.017 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin JW-Modules 0.6.1vcvrack: Loaded static plugin JW-Modules 0.6.1

[0.017 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Koralfx-Modules 0.6.1vcvrack: Loaded static plugin Koralfx-Modules 0.6.1

[0.018 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin LindenbergResearch 0.6.2bvcvrack: Loaded static plugin LindenbergResearch 0.6.2b

[0.018 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin LOGinstruments 0.6.1vcvrack: Loaded static plugin LOGinstruments 0.6.1

[0.019 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin mental 0.6.1vcvrack: Loaded static plugin mental 0.6.1

[0.019 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin ML_modules 0.6.1vcvrack: Loaded static plugin ML_modules 0.6.1

[0.019 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin moDllz 0.6.1vcvrack: Loaded static plugin moDllz 0.6.1

[0.020 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin modular80 0.6.1vcvrack: Loaded static plugin modular80 0.6.1

[0.020 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin mscHack 0.6.1vcvrack: Loaded static plugin mscHack 0.6.1

[0.020 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin mtsch-plugins 0.6.1vcvrack: Loaded static plugin mtsch-plugins 0.6.1

[0.020 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin NauModular 0.6.1vcvrack: Loaded static plugin NauModular 0.6.1

[0.020 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Nohmad 0.6.1vcvrack: Loaded static plugin Nohmad 0.6.1

[0.021 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Ohmer 0.6.1vcvrack: Loaded static plugin Ohmer 0.6.1

[0.021 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin PG-Instruments 0.6.1vcvrack: Loaded static plugin PG-Instruments 0.6.1

[0.021 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin PvC 0.6.1vcvrack: Loaded static plugin PvC 0.6.1

[0.022 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Qwelk 0.6.1vcvrack: Loaded static plugin Qwelk 0.6.1

[0.022 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin RJModules 0.6.1vcvrack: Loaded static plugin RJModules 0.6.1

[0.022 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin SerialRacker 0.6.1vcvrack: Loaded static plugin SerialRacker 0.6.1

[0.023 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin SonusModular 0.6.1vcvrack: Loaded static plugin SonusModular 0.6.1

[0.024 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Southpole 0.6.1vcvrack: Loaded static plugin Southpole 0.6.1

[0.024 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Southpole-parasites 0.6.1vcvrack: Loaded static plugin Southpole-parasites 0.6.1

[0.024 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin squinkylabs-plug1 0.6.1vcvrack: Loaded static plugin squinkylabs-plug1 0.6.1

[0.025 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin SubmarineFree 0.6.1vcvrack: Loaded static plugin SubmarineFree 0.6.1

[0.025 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin SynthKit 0.6.1vcvrack: Loaded static plugin SynthKit 0.6.1

[0.025 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Template 0.6.1vcvrack: Loaded static plugin Template 0.6.1

[0.025 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin TheXOR 0.6.1vcvrack: Loaded static plugin TheXOR 0.6.1

[0.025 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin trowaSoft 0.6.1vcvrack: Loaded static plugin trowaSoft 0.6.1

[0.026 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin unless_modules 0.6.1vcvrack: Loaded static plugin unless_modules 0.6.1

[0.026 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Valley 0.6.1vcvrack: Loaded static plugin Valley 0.6.1

[dbg] vst2_load_static_rack_plugins: LEAVE
[0.036 info src/plugin.cpp:90] trying to load shared plugin file /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/bsp/plugin.so.fxtrying to load shared plugin file /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/bsp/plugin.so.fx

xxx vstrack_plugin: loadPlugin: global=0xb26ee008 plugin->global=0xb26ee008
[0.051 info src/plugin.cpp:160] Loaded plugin bsp 0.6.1 from /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/bsp/plugin.so.fxLoaded plugin bsp 0.6.1 from /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/bsp/plugin.so.fx

[0.055 info src/plugin.cpp:90] trying to load shared plugin file /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/dBiz/plugin.so.fxtrying to load shared plugin file /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/dBiz/plugin.so.fx

xxx vstrack_plugin: loadPlugin: global=0xb26ee008 plugin->global=0xb26ee008
[0.078 info src/plugin.cpp:160] Loaded plugin dBiz 0.6.1 from /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/dBiz/plugin.so.fxLoaded plugin dBiz 0.6.1 from /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/dBiz/plugin.so.fx

[0.103 info src/plugin.cpp:90] trying to load shared plugin file /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/Template_shared/plugin.so.fxtrying to load shared plugin file /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/Template_shared/plugin.so.fx

xxx vstrack_plugin: loadPlugin: global=0xb26ee008 plugin->global=0xb26ee008
hello from Template_shared plugin!
[0.116 info src/plugin.cpp:160] Loaded plugin Template_shared 0.6.1 from /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/Template_shared/plugin.so.fxLoaded plugin Template_shared 0.6.1 from /mnt/git/VeeSeeVSTRack/vst2_bin//plugins/Template_shared/plugin.so.fx

xxx vst2_init: 6
xxx vst2_init: 7
xxx vst2_init: 8
[0.118 info src/settings.cpp:436] Loading settings /mnt/git/VeeSeeVSTRack/vst2_bin//settings.jsonLoading settings /mnt/git/VeeSeeVSTRack/vst2_bin//settings.json

Things left to do:

cameronleger commented 6 years ago

Wow, that's a lot of good work! I appreciate the debugging help as that's probably much quicker for you than us.

The plugin folder mis-detection was my fault, as I was doing some fairly one-to-one replacements there but probably didn't understand one of the arguments or calls properly.

The LGLW, I'm still just approaching it with the basic X11 libraries in mind, and I have compiling code for the hidden/visible window creation/destruction and resizing. I'm hoping to test that it actually does that stuff soon, otherwise it's just hopeful code. I didn't notice anything that might be a problem later in the files. I am unsure of the what the userdata does so I haven't touched it yet.

bsp2 commented 6 years ago

userdata is used to retrieve the VSTPluginWrapper instance handle in the UI event callbacks (see window.cpp (lglw_userdata_*)).

I just updated vst2_main.cpp and added support for absolute library paths (dladdr may return absolute or relative paths, depending on how the plugin is loaded).

Now the Linux version of Renoise for example can see (and load) the (native) VST plugin (it exits after the VM related GLEW error message).

davephillips commented 6 years ago

@bsp2 Thanks again ! I got things built, but when I run vst2_debug_host I get this error:

[dlphilp@The6300 vst2_bin]$ cd ../other/vst2_debug_host/
[dlphilp@The6300 vst2_debug_host]$ ./vst2_debug_host 
xxx calling mainProc
vstrack_plugin: called VSTPluginMain... 
xxx mainProc returned effect=0x7fd3f735b668
xxx calling effect->dispatcher<effOpen>
vstrack_plugin<dispatcher>: effOpen
xxx vstrack_plugin::openEffect
xxx vstrack_plugin::openEffect: instance_id=1
xxx vstrack_plugin::openEffect: dllnamerawp="/home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vstrack_plugin::openEffect: cd to "/home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/"
xxx vstrack_plugin::openEffect: cwd change done
xxx argv[0]=0x7ffd81b14ed0
xxx vstrack_plugin::openEffect: dllname="/home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vst2_init: 1
Illegal instruction (core dumped)

Any clues ?

davephillips commented 6 years ago

Just updated to the latest pull, same problem. Also still no load in Bitwig 2.3.4. :(

cameronleger commented 6 years ago

@davephillips you should find some helpful information in main.cpp around line 57. Your build is failing somewhere inside of the randomInit call. I think if you set RELEASE and DEBUG properly in install_linux.mk from YAC, the coredumps will contain more helpful information as well.

I get farther than that (still not as far as @bsp2), but I have to add -fPIC in some steps so that the linking succeeds. Sadly, mine crashes when it should simply be logging more information. For reference, here's what I'm getting after that:

xxx calling mainProc
vstrack_plugin: called VSTPluginMain... 
xxx mainProc returned effect=0x7f2482b46668
xxx calling effect->dispatcher<effOpen>
vstrack_plugin<dispatcher>: effOpen
xxx vstrack_plugin::openEffect
xxx vstrack_plugin::openEffect: instance_id=1
xxx vstrack_plugin::openEffect: dllnamerawp="/home/cameron/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vstrack_plugin::openEffect: cd to "/home/cameron/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/"
xxx vstrack_plugin::openEffect: cwd change done
xxx argv[0]=0x7fff4cdd2e20
xxx vstrack_plugin::openEffect: dllname="/home/cameron/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vst2_init: 1
xxx vst2_init: 2
xxx vst2_init: 3
xxx vst2_init: 4 global_ui=0x7f2482246298
zsh: segmentation fault (core dumped)  ./vst2_debug_host

EDIT: My issue is definitely to do with the logging issues. It crashes the same way with/without dev mode (for logging to either STDOUT or STDERR). Printing the same information before the Rack logging commands works just fine.

(gdb) run
Starting program: /home/cameron/src/VeeSeeVSTRack/other/vst2_debug_host/vst2_debug_host 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
xxx calling mainProc
vstrack_plugin: called VSTPluginMain... 
xxx mainProc returned effect=0x7fffefafa668
xxx calling effect->dispatcher<effOpen>
vstrack_plugin<dispatcher>: effOpen
xxx vstrack_plugin::openEffect
xxx vstrack_plugin::openEffect: instance_id=1
xxx vstrack_plugin::openEffect: dllnamerawp="/home/cameron/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vstrack_plugin::openEffect: cd to "/home/cameron/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/"
xxx vstrack_plugin::openEffect: cwd change done
xxx argv[0]=0x7fffffffdc10
xxx vstrack_plugin::openEffect: dllname="/home/cameron/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vst2_init: DEV
xxx vst2_init: 1
xxx vst2_init: 2
xxx vst2_init: 3
xxx vst2_init: 4 global_ui=0x7fffef1fa298
xxx vst2_init: 4.1 gApplicationName=VeeSeeVST Rack
xxx vst2_init: 4.2 gApplicationVersion=0.6.1

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd8635 in __strlen_avx2 () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7bd8635 in __strlen_avx2 () at /usr/lib/libc.so.6
#1  0x00007ffff7acb887 in vfprintf () at /usr/lib/libc.so.6
#2  0x00007ffff5d807da in rack::loggerLogVa(rack::LoggerLevel, const char *, int, const char *, typedef __va_list_tag __va_list_tag *)
    (level=rack::INFO_LEVEL, file=0x7ffff5e54cc1 "src/main.cpp", line=72, format=0x7ffff5e54cbb "%s %s", args=0x7fffffffd630) at src/util/logger.cpp:59
#3  0x00007ffff5d80912 in rack::loggerLog(rack::LoggerLevel, char const*, int, char const*, ...)
    (level=rack::INFO_LEVEL, file=0x7ffff5e54cc1 "src/main.cpp", line=72, format=0x7ffff5e54cbb "%s %s") at src/util/logger.cpp:70
#4  0x00007ffff5462e26 in vst2_init(int, char**, bool) (argc=1, argv=0x7fffffffd808, _bFX=true) at src/main.cpp:72
#5  0x00007ffff545f365 in VSTPluginWrapper::openEffect() (this=0x7fffef1fa010) at src/vst2_main.cpp:581
#6  0x00007ffff545d48c in VSTPluginDispatcher(AEffect*, int, int, long, void*, float)
    (vstPlugin=0x7fffefafa668, opCode=0, index=0, value=0, ptr=0x0, opt=0) at src/vst2_main.cpp:1481
#7  0x00005555555552b8 in open_and_close() ()
#8  0x00005555555550bd in main ()
(gdb) 

EDIT2: Commenting line 59 in logger.cpp where it was crashing has it loading all the plugins and ending put at the could not initialize GLEW error. At least I can replicate the latest build.

davephillips commented 6 years ago

@cameronleger I think I'm now at exactly the same point as you:

$ ./vst2_debug_host 
xxx calling mainProc
vstrack_plugin: called VSTPluginMain... 
xxx mainProc returned effect=0x7fcbeb10b668
xxx calling effect->dispatcher<effOpen>
vstrack_plugin<dispatcher>: effOpen
xxx vstrack_plugin::openEffect
xxx vstrack_plugin::openEffect: instance_id=1
xxx vstrack_plugin::openEffect: dllnamerawp="/home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vstrack_plugin::openEffect: cd to "/home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/"
xxx vstrack_plugin::openEffect: cwd change done
xxx argv[0]=0x7ffcf7430b10
xxx vstrack_plugin::openEffect: dllname="/home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/veeseevstrack_effect.so"
xxx vst2_init: 1
xxx vst2_init: 2
xxx vst2_init: 3
xxx vst2_init: 4 global_ui=0x7fcbea80b298
[0.000 info src/main.cpp:67] VeeSeeVST Rack 0.6.1

[0.000 info src/main.cpp:69] Development mode

[0.000 info src/main.cpp:70] Global directory: /home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin//

[0.000 info src/main.cpp:71] Local directory: /home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin//

xxx vst2_init: 5
[dbg] vst2_load_static_rack_plugins: ENTER
[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AmalgamatedHarmonics 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Alikins 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin alto777_LFSR 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AS 0.6.9

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AudibleInstruments 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Autodafe 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Befaco 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Bidoo 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Bogaudio 0.6.7

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin cf 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin DHE-Modules 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin DrumKit 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin ESeries 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin FrozenWasteland 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Fundamental 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Geodesics 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Gratrix 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin HetrickCV 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin ImpromptuModular 0.6.11

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin JE 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin JW-Modules 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Koralfx-Modules 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin LindenbergResearch 0.6.2b

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin LOGinstruments 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin ML_modules 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin modular80 0.6.1

[0.001 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin mscHack 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin mtsch-plugins 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin NauModular 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Nohmad 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Ohmer 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin PG-Instruments 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Qwelk 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin RJModules 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin SonusModular 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Southpole 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Southpole-parasites 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin squinkylabs-plug1 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin SubmarineFree 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin SynthKit 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Template 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin TheXOR 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin trowaSoft 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin unless_modules 0.6.1

[0.002 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Valley 0.6.1

[dbg] vst2_load_static_rack_plugins: LEAVE
[0.002 info src/plugin.cpp:90] trying to load shared plugin file /home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin//plugins/Template_shared/plugin.so.fx

xxx vstrack_plugin: loadPlugin: global=0x7fcbea80b010 plugin->global=0x7fcbea80b010
hello from Template_shared plugin!
[0.016 info src/plugin.cpp:160] Loaded plugin Template_shared 0.6.1 from /home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin//plugins/Template_shared/plugin.so.fx

xxx vst2_init: 6
xxx vst2_init: 7
xxx vst2_init: 8
[0.016 info src/settings.cpp:436] Loading settings /home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin//settings.json

Illegal instruction (core dumped)
cameronleger commented 6 years ago

The glewInit() is returning 1 for GLEW_ERROR_NO_GL_VERSION and not 0 for GLEW_OK. This should mean that a GL Context was not created before the initialization, so it cannot determine anything about GL. Below are the other GLEW error codes, perhaps it's best to check them and return appropriate errors, as this one is slightly misleading. I don't think it's too important though.

I think this means we're at a point where I can really test my LGLW efforts. I'm creating X windows at this point, but I had not created GL Contexts as well which is why this is happening. I think when I get that part done we'll bypass this GLEW error.

/* error codes */
#define GLEW_OK 0
#define GLEW_NO_ERROR 0
#define GLEW_ERROR_NO_GL_VERSION 1  /* missing GL version */
#define GLEW_ERROR_GL_VERSION_10_ONLY 2  /* Need at least OpenGL 1.1 */
#define GLEW_ERROR_GLX_VERSION_11_ONLY 3  /* Need at least GLX 1.2 */
#define GLEW_ERROR_NO_GLX_DISPLAY 4  /* Need GLX display for GLX support */
bsp2 commented 6 years ago

Ok, if I understood correctly, you both can reproduce the build so we are on the same page now.

The logger issue needs to be looked at, of course, but for now let's just comment the vprintf line which is apparently not working everywhere (works here for some reason).

And yes, the crash in windowInit() (after xxx vst2_init: 8) is in window.cpp:402:glewInit() and it's most certainly because the LGLW stub did not actually create a GL context.

I've just added a simple VST2 test plugin to the repo which I used to test LGLW / OpenGL.

It's just a single file (plugin.cpp) and you'll need to write a Linux makefile for it (the .7z contains only the source and a VisualStudio project).

The plugin simply displays a flashing GL window and prints some debug messages (e.g. to test keyboard / mouse input).

Might be easier to test LGLW with this plugin instead of VSVR since it's much simpler.

EDIT: keep in mind that you cannot use the vst2_debug_host to load the test plugin. You have to use a host that creates the parent window (its window handle is passed to the plugin when the VST editor window is opened in vst2_main.cpp:VSTPluginWrapper::openEditor()).

Alternatively, you can just hack the plugin.cpp file and make it a standalone executable, then move on to the VST2 version when that works.

cameronleger commented 6 years ago

That is correct. I just setup an OpenGL GLX context as the windows are created/destroyed and the debug host seems to work fine. I will definitely switch to your test plugin instead, as it was opening/closing windows like mad and I think that's by design :P

bsp2 commented 6 years ago

Sounds good! You could also modify the debug host and make it create the parent window (via LGLW).

One thing I was wondering about is what the argument to effEditGetRect (in vst2_main.cpp:1807) looks like on Linux. On Windows, it's a pointer to a RECT structure. Maybe we'll need to define the same struct on Linux ? (probably, if you take a look here)

cameronleger commented 6 years ago

Related to resizing and knowing the window size? I started here: https://tronche.com/gui/x/xlib/window-information/XGetGeometry.html

It's not really structured, just a few integers for X, Y, width, and height.

bsp2 commented 6 years ago

The VST host queries effEditGetRect via the plugin's dispatcher function (VSTPluginDispatcher() in vst2_main.cpp) before it opens the editor window. The parameter has to match the host and I think it's supposed to be a Windows-like RECT struct pointer.

And well, VSTs usually don't support resizing so this is kind of a hack in VSVR.

When a new window size is selected via the toolbar menu (see Toolbar.cpp), the plugin calls lglw_window_resize() which not only resizes the editor (sub-)window but also checks if the window has a parent, and in that case also resizes the parent.

cameronleger commented 6 years ago

I've developed the resizing in LGWL with something that should work, but it's untested still. The structure was very similar to the Windows implementation. I haven't done the lglw_window_size_get one, but I assume both of those handle the neccessary changes for sizing.

I just came across something that made me rethink how this will work. I think I understand your hidden window concept: you need a GL drawable before the plugin's window is opened, so you keep one around the whole time but show a different child window when the plugin asks for the window.

I was translating this one-to-one to X11, until I was checking up on 'mapping' a Window which is not the same as creating it, it merely lets the X11 server show/manage the window. Mapped windows will only appear if their ancestors are already mapped, and this wouldn't be the case for the hidden window. So, the main window will either not be a child of the hidden window, or perhaps the hidden window isn't necessary and a lone window can exist and be mapped/unmapped as necessary.

bsp2 commented 6 years ago

IIRC, the main reason for the hidden window is EDIT: that you need a DC (or Drawable on Linux) in order to bind the GL context.

Re: the window mapping: Yes, creating and mapping/showing the window are two separate things.

The hidden window will never be mapped (become visible).

The main window is either a desktop window (when the _parentHWNDOrNull argument to lglw_window_open() is NULL), or a child window of another window (which the VST host created). It will never be a child window of the hidden window.

Implementing lglw_window_size_get will be very easy, just take a look at the Windows version of it.

cameronleger commented 6 years ago

I understand. I had blindly copied the wrong Window as the parent, so when I read the code over against the docs I was thinking of that instead of the original.

Just a quick status update: I have the GL code mostly done; I can load the test plugin and see the colors flashing. There's a few quirks about this that I don't fully understand, though. I modified the test host, and I'm able to test on:

I added file-logging code to lglw_linux to get around no output from Bitwig. My problem here is that I was getting some very hard crashes where the Audio Engine would terminate, and I cannot log in that case. I have faint ideas about the errors, all X11 server errors, but they would normally print messages and immediately exit the program; I cannot see the messages.

While I was easily running in the test host and Ardour, I had issues with the Windows in BWS. First, the Window would not actually appear until I ran glXMakeCurrent when the Window was created and not simply during the push/pop calls. This was not necessary for the others.

Then, the most troublesome issue was a hard crash when the Window was closed and opened again later on. Again, only an issue in BWS. The second time around, it crashes at the required early glXMakeCurrent call. Presumably, these crashes are BadWindow or GLXBadDrawable errors, as I saw them in the other systems while trying things to fix this.

My simple workaround came about during testing. For this call, I XSetErrorHandler to a basic function that stores the error for later inspection, run the call, then set it back to the default handler. I can see in the logs that the first time it works, every creation after that has an error, but it looks like it just works. I tried to run this call only the first time, but then later glXMakeCurrent calls will crash. I don't know why, but I have to transparently eat this error after the Window is destroyed/created for Bitwig Studio.

Next up is handling the inputs. The WndProc concept in Windows is notably easier here. X requires checking an event queue on your own, but is infamously bad at threading. I see that a few other VSTs using X11 prefer to check/process the queue during the effEditIdle which was my first guess as well.

It looks like the Windows version uses this time to redraw the window. Would you kindly describe how you've managed the (re)drawing of the window? I'd like to know more about this part before changing things about it.

bsp2 commented 6 years ago

I found the following information which could be helpful:

Ardour VST UI handling on Linux: https://github.com/Ardour/ardour/blob/master/gtk2_ardour/linux_vst_gui_support.cc

64bit XEventProc in Renoise: https://www.kvraudio.com/forum/viewtopic.php?t=387924 @neotec writes that the Renoise devs sent him this code snippet that can be used to set the callback function in a 64bit plugin:

void setEventProc(Display* display, Window window)
{
    size_t data = (size_t)eventProc;
    long temp[2];

    // Split the 64 bit pointer into a little-endian long array
    temp[0] = (long)(data & 0xffffffffUL);
    temp[1] = (long)(data >> 32L);

    Atom atom = XInternAtom(display, "_XEventProc", false);
    XChangeProperty(display, window, atom, atom, 32, 
        PropModeReplace, (unsigned char*)temp, 2);
}

Event handling on Windows: The event handling on Windows works in a similar way. Each VST plugin window is associated with a window class, which stores a WndProc event handler function pointer. The main event loop is in the VST host (just like Ardour on Linux). Events not consumed by the host are delegated to the VST (sub-)window WndProc callback. I think this callback is called by Windows when the host does not handle an event and instead leaves the handling to the DefWindowProc.

On both platforms, the plugin creates a sub-window and associates an event callback with it. The sub-window is reparented to the window that the host created. The handle to this host (parent) window is passed to effEditOpen.

On Windows, the parent window can be passed to the CreateWindow call. I am not sure how this works on Linux, i.e. which X11 call will cause the ReparentNotify message to be sent to the host (maybe it will be sent if a window specifies its parent during creation, just like on Windows).

The mapping/unmapping (ShowWindow on Windows) is controlled by the host (on both platforms). Most hosts don't close/destroy the window (and call effEditClose) until the plugin is unloaded. Instead, they usually just show and hide the window when necessary.

And yes, debugging all of this can be quite tricky, especially on Windows where you usually don't have the source for the host application ;)

Looking at the Ardour host code and its comments, it seems that implementing the vst2_debug_host with UI support in a portable way (i.e. only with LGLW) might not be so easy. Maybe you can create a Linux-specific version of the debug host and borrow some code from Ardour ?

Anyway, good to hear that you're making progress with the LGLW port and are already seeing some graphics output !

EDIT: so far I've used LGLW only for the VSVR plugin but it could also be useful for standalone apps. All that's missing is a function to pump the event queue, i.e.

void lglw_events (lglw_t _lglw);
cameronleger commented 6 years ago

Good research! I'll definitely look into the _XEventProc information.

Re: window parenting, you always have to specify a parent Window in X11. If you don't need one you still have to find the Root Window and use that instead. So, the _parentHWNDOrNull is set to the Root Window when null, and it's passed into the Window's creation function very similar to the Windows version. I've seen some hosts that run XReparentWindow afterwards anyways, probably just to be sure it's in control.

Re: the host mapping/unmapping, are you saying that BWS, Ardour, the debugging host, etc. will perform that step (although, I don't think the debug host is doing that)? I noticed the LWGL Show/Hide functions were not used anywhere in this repo, although they were defined and did this step. It might explain the weirdness I had with BWS: regardless of mapping the Window myself, it only appeared after glXMakeCurrent presumably because otherwise the Window had nothing drawing/updating it.

Re: vst2_debug_host, I've already made some modifications although they only run #ifndef YAC_WIN32. I set it to run a few times instead of forever, and with a handful of sleep() calls to see what's going on. It starts by creating a basic/blank X Window, and passing that to effEditOpen. It runs a few effEditIdle calls before effEditOpen/effEditClose a few more times. I'll look more into what Ardour is doing to see if I can make this more like that.

bsp2 commented 6 years ago

Re: the host mapping/unmapping, are you saying that BWS, Ardour, the debugging host, etc. will perform that step (although, I don't think the debug host is doing that)? I noticed the LWGL Show/Hide functions were not used anywhere in this repo, although they were defined and did this step

when I designed the LGLW API I was replacing the GLFW calls in VCV Rack. It's true that in the end, the show/hide calls are not used by the plugin (yes, the host takes care of that) but it would be cool if you would implement them anyway because it would make the library a bit more versatile (i.e. also suitable for standalone apps, or maybe even for plugins that want to open additional windows).

In case you're wondering: the reason why I did not use GLFW or SDL was that I needed a library that can be instantiated multiple times, i.e. where a library instance handle is passed to all API functions (besides, all libraries should be built this way in the first place!).

GFLW and SDL use static variables which made it impossible to use both the effect and instrument versions of the plugin in the same host. With SDL, I also couldn't load any version of the plugin in hosts that already used SDL (e.g. my work-in-progress "Eureka" host, which is most likely going to be open source at some point. LGLW could be used there to create the parent windows for the VST UIs in a portable way).

cameronleger commented 6 years ago

OK. I do have them implemented and manually tested. I will have to revisit the mapping of the window during effEditOpen/lglw_window_open to see if that was the source of some of my problems.

cameronleger commented 6 years ago

I'm happy to say that I've cleaned up and solved the initial quirks. I set an error handler for X to simply send the errors through my log since they didn't seem to cause issues if ignored. Each error was for a BadWindow, and it was always in certain places and not specifically the calls that were made.

A simple XSync call after creating/deleting the Windows fixes the issues. The documentation states that clients will rarely need this, but apparently I do as there's some weird race conditions in this setup. I've seen other VSTs that wait for Window-related calls to finish before returning, so this isn't out of the ordinary.

It turns out that I do have to map the Window myself during creation since some hosts do not XMapSubwindows, only XMapWindow. I also do not have to call glXMakeCurrent when the window is created as the XSync fixed that portion.

As you said, most hosts will call effEditOpen/effEditClose when the VST is added/removed. The actual toggling of the Window is managed by them instead. Bitwig is an outlier here. With that in mind, could a simpler setup be achieved for Linux where only one Window is required? It would serve as both the hidden and actual window, and exist for the entirety of the plugin. For most hosts it might not be any different, whereas it would work in Bitwig and similar hosts like the rest of them do. I don't think this is unnecessarily complex right now; I'm just wondering.

bsp2 commented 6 years ago

Interesting that it's possible to show/hide ("map") sub-windows in X11. The manpage for XMapSubwindows states that the top-level window won't become visible until all child windows are mapped.

Re: your question:

Removing the second (hidden) window would imply that the remaining window could never be closed/destroyed (via lglw_window_close()) until the library instance is freed via lglw_exit().

After giving it some thought, I don't think that this should be an issue. The hidden window is not exposed to the library user, anyway, and it shouldn't matter if it's not actually there.

LGLW is not meant as a one-size-fits-it-all shared library but rather a simple single-file static lib that you copy to your project, then modify it as necessary. If it turns out that for some specific application the hidden window is needed after all, it shouldn't be hard to re-add that window with some copy'n'paste.

I just wouldn't want to change the LGLW API (e.g. remove the lglw_window_close() function) because on some platforms it's perfectly possible to create surfaceless GL(ES) contexts but it may not be possible to resize a window for example (e.g. if the window is actually a hardware layer).

In other words, on such a platform, lglw_init() would not create a window but just a GL(ES) context, and the actual window would be created in lglw_window_open().

So, if you think this will make the Linux port easier, do it.

cameronleger commented 6 years ago

I won't do it for now; I'd rather mimic the Windows side when possible until it's complete as to make the debugging and knowledge sharing easier. I might refactor it in the end, but it also might be wasted optimizations.

cameronleger commented 6 years ago

I did a lot of research on _XEventProc and tried some things out, but my results aren't working yet. I won't have that much time to work on this for a bit but I'm open for discussion. First, Google will turn up few results, and I was able to search GitHub for all usages of it. The vast majority of the 49 pages were simply copied files from JUCE. I've saved the unique hits and I'll catalog them here. It seems that X11 and VSTs on Linux are ripe for heated debates. I'll explain my results first.

Nothing happens in Bitwig regardless of what I've tried. Ardour definitely uses it and the code is available, so that's my primary testing platform right now. I've made a very simple function for them to call which should print or log the call. Note that I've tried Event * and void *, but Ardour seems to expect to send a void *.

void loc_eventProc(void *xevent) {
   printf("XEventProc\n");
}

Ardour's Usage of the Callback https://github.com/Ardour/ardour/blob/master/gtk2_ardour/linux_vst_gui_support.cc This looks promising, although I'm concerned that JUCE might handle it differently. I've stripped the 64-bit version of getXWindowProperty into vst2_debug_host, and then I use that to grab the pointer and perform the same steps around 258. This allows me to log whether it was found, and try calling it from an environment that's much easier to debug in. I did not have success using gdb with Ardour, so this was important.

JUCE's Implementation of the Callback https://github.com/COx2/DistortionFilter/blob/c6a34fb56b503a6e95bf0975e00f438bbf4ff52a/juce/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp Here is just one example of this copy&pasted file. Perhaps this will cause problems, but you'll see that the function pointer they're accessing uses XEvent * instead of void * as Ardour does.

Renoise 64-bit Callback Creation https://www.kvraudio.com/forum/viewtopic.php?t=387924 You linked this post previously. It's interesting, but for me a little unhelpful. I assume that in this case eventProc is the function they're trying to bind, so I swapped that for loc_eventProc. It's not in the example, so it could be anything. I'm not skilled enough to infer this one, but simply using the name of my function does nothing, as in the debug host gets a result of 0 and skips it.

OvertoneDSP's Take on This https://discourse.ardour.org/t/overtonedsp-plugins/90115/22 There's a lot of debate here and nothing much for substance, other than general complaining about this. They've come up with their own solution instead which might inspire us here if all else fails.

amsynth's implementation https://github.com/amsynth/amsynth/blob/4a87798e650c6d71d70274a961c9b8d98fc6da7e/src/amsynth_vst.cpp This one stands out to me as the 64-bit magic goes way over my head and is nothing like anything else I've found. I'm simply subbed XEventProc, their function, for mine at loc_eventProc. Interestingly, this crashes when the callback is made, and it definitely happens when an XEvent I'm listening for happens. The debug host also crashes after printing that it found a result to use. gdb is unhelpful here:

#0  0xfffffffff7fc87db in ?? ()
#1  0x0000555555555615 in open_and_close () at vst2_debug_host.cpp:161
#2  0x00005555555558ff in main () at vst2_debug_host.cpp:219

eXT2's implementation https://github.com/rsenn/eXT2/blob/7f00a09561ded8175ffed2f4912dad74e466a1c7/vstplugins/vstgui/vstgui.cpp This is a nice example as they are attaching their instance through this method as well, which is probably the way to implement the user_data to know the correct instance of LGLW. However, I think it's 32-bit only. As it is, it causes the same crash as the previous example. I set it up with void* data = (void*)&loc_eventProc;

In summary, I'm slightly onto something, but it's not working at all. In some cases, the host cannot access what I've provided so nothing happens. When it can access it, it crashes immediately. Any information on debugging this is helpful. Honestly, the amount of casting and pointers here is a little overwhelming for my knowledge.

bsp2 commented 6 years ago

Qtractor Qtractor also supports native VSTs, see qtractorVstPlugin.cpp. The _XEventProc handling is at line 128 (getXEventProc()).

This looks like the counterpart of what Renoise 64bit is expecting a plugin to be doing (according to the code snippet).

Re: JUCE/Ardour: The void* is typecasted to XEvent* when the callback is invoked:

static void dispatch_x_events (XEvent* event, VSTState* vstfx) {
  /*...*/
  vstfx->eventProc((void*)event);
}

Re: amsynth: What they are doing there is generating a trampoline that lives in a memory region accessible by a 32bit pointer. According to the comments, it's just a compatibility thing that's probably not needed with modern hosts (i.e. only with older hosts that don't set a 64bit _XEventProc property).

Re: eXT2 and the user_data attribute: I'm not sure what line you are referring to but since the user_data field is LGLW internal, it should not be a problem because according to this, you can attach arbitrary, user defined properties to X11 windows.

Can you commit your current changes / additions (LGLW, debug host, GL test plugin) to GitHub ? Then I could take a look myself.

cameronleger commented 6 years ago

Re: eXT2, sorry, it's right above the _XEventProc around 1780. My point here was just that there's a readily available example of basically the same thing being done.

Although we've mostly sorted out the consistent builds, I have a few other modifications in order for everything to compile correctly for me. Perhaps these are only necessary in more specific places instead of what I've done, but without this I will get linking errors.

Add -fPIC to:

Anyways, I opened a PR https://github.com/bsp2/VeeSeeVSTRack/pull/13, I'm not sure about merging it yet as it's very WIP and will eventually be cleaned up. I was also thinking it would be merged into the LGLW repo and copied here. In any case you have at least my branch to look at.

vst2_debug_host.cpp has my conditional code for Linux (really non-Windows) to open an XWindow and run the callback.

Although I unpacked the vst2_lglw_debug_plugin, I'm pretty sure the only modification I've made is to add the makefile. I might have adjusted includes.

For LGLW, I've split it into two commits to make it easier to understand. The first is all the initial basically working code. The second is simply the XEventProc idea testing. Here's what I've done so far:

The second commit contains many WIP comments about what I encountered with each test.

davephillips commented 6 years ago

Greetings ! I've built the latest pull but it still fails in Bitwig. However, BW is giving me some better and hopefully more helpful information:

com.bitwig.flt.library.metadata.reader.exception.CouldNotReadMetadataException: could not read metadata: Could not read VST plug-in metadata
64 bit plugin host reported errors: Pluginhost returned non zero exit code 134
Error messages:

BitwigPluginHost64: src/SpringReverb.cpp:18: void springReverbInit(): Assertion `f' failed.

Other messages:

vstrack_plugin: called VSTPluginMain... 
vstrack_plugin:dispatcher: unhandled opCode 58 [ignored] 
vstrack_plugin<dispatcher>: effOpen
xxx vstrack_plugin::openEffect
xxx vstrack_plugin::openEffect: instance_id=1
xxx vstrack_plugin::openEffect: dllnamerawp="/home/dlphilp/vst/veeseevstrack/veeseevstrack_effect.so"
xxx vstrack_plugin::openEffect: cd to "/home/dlphilp/vst/veeseevstrack/"
xxx vstrack_plugin::openEffect: cwd change done
xxx argv[0]=0x11b8310
xxx vstrack_plugin::openEffect: dllname="/home/dlphilp/vst/veeseevstrack/veeseevstrack_effect.so"
xxx vst2_init: 1
xxx vst2_init: 2
xxx vst2_init: 3
xxx vst2_init: 4 global_ui=0x7ff6ebe0b298
[0.000 info src/main.cpp:67] VeeSeeVST Rack 0.6.1

[0.000 info src/main.cpp:69] Development mode

[0.000 info src/main.cpp:70] Global directory: /home/dlphilp/vst/veeseevstrack//

[0.000 info src/main.cpp:71] Local directory: /home/dlphilp/vst/veeseevstrack//

xxx vst2_init: 5
[dbg] vst2_load_static_rack_plugins: ENTER
[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AmalgamatedHarmonics 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Alikins 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin alto777_LFSR 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AS 0.6.9

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin AudibleInstruments 0.6.1

[0.000 info src/plugin_static.cpp:141] vcvrack: Loaded static plugin Autodafe 0.6.1

32 bit plugin host reported errors: Pluginhost returned non zero exit code 255
davephillips commented 6 years ago

So it looks to me like my crash occurs when it tries to load the Befaco Spring Reverb module.

bsp2 commented 6 years ago

@cameronleger: I merged your pull request and rebuild the VSVR plugins, the debug host, and the debug plugin.

Running the vst2_debug_host as-is resulted in

xxx calling mainProc
called VSTPluginMain... 
Segmentation fault

The crash occured in lglw_init(). Changing the hardcoded log path to /tmp/lglw_log.txt solved this issue.

Then I got:

xxx calling mainProc
called VSTPluginMain... 
xxx debug_plugin: calling lglw_init()
xxx debug_plugin: lglw_init() returned lglw=0x87c898
xxx mainProc returned effect=0x87c244
xxx calling effect->dispatcher<effOpen>
xxx effect->dispatcher<effOpen> returned
xxx XEventProc found... calling
XEventProc
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
OpenGL Warning: vboxCall failed with VBox status code VERR_BUFFER_OVERFLOW

xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditClose>
Segmentation fault

Apparently the OpenGL support in VirtualBox 5.2.20 (the latest version) is broken (glxgears gave me the same VERR_BUFFER_OVERFLOW error).

Commenting out the code in plugin.cpp:redrawWindow() "solved" this:

xxx calling mainProc
called VSTPluginMain... 
xxx debug_plugin: calling lglw_init()
xxx debug_plugin: lglw_init() returned lglw=0x131b490
xxx mainProc returned effect=0x131b244
xxx calling effect->dispatcher<effOpen>
xxx effect->dispatcher<effOpen> returned
xxx XEventProc found... calling
XEventProc
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effEditOpen> again
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx call processreplacing
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effClose>
xxx debug_host: closing library
xxx debug_host: library closed
xxx calling mainProc
called VSTPluginMain... 
xxx debug_plugin: calling lglw_init()
xxx debug_plugin: lglw_init() returned lglw=0x1318b20
xxx mainProc returned effect=0x1318a8c
xxx calling effect->dispatcher<effOpen>
xxx effect->dispatcher<effOpen> returned
xxx XEventProc found... calling
XEventProc
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effEditOpen> again
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx call processreplacing
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effClose>
xxx debug_host: closing library
xxx debug_host: library closed
xxx calling mainProc
called VSTPluginMain... 
xxx debug_plugin: calling lglw_init()
xxx debug_plugin: lglw_init() returned lglw=0x131bf50
xxx mainProc returned effect=0x131bebc
xxx calling effect->dispatcher<effOpen>
xxx effect->dispatcher<effOpen> returned
xxx XEventProc found... calling
XEventProc
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effEditOpen> again
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx call processreplacing
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effClose>
xxx debug_host: closing library
xxx debug_host: library closed
xxx calling mainProc
called VSTPluginMain... 
xxx debug_plugin: calling lglw_init()
xxx debug_plugin: lglw_init() returned lglw=0x131bf50
xxx mainProc returned effect=0x131bebc
xxx calling effect->dispatcher<effOpen>
xxx effect->dispatcher<effOpen> returned
xxx XEventProc found... calling
XEventProc
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effEditOpen> again
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx call processreplacing
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effClose>
xxx debug_host: closing library
xxx debug_host: library closed
xxx calling mainProc
called VSTPluginMain... 
xxx debug_plugin: calling lglw_init()
xxx debug_plugin: lglw_init() returned lglw=0x15e0680
xxx mainProc returned effect=0x15e0a3c
xxx calling effect->dispatcher<effOpen>
xxx effect->dispatcher<effOpen> returned
xxx XEventProc found... calling
XEventProc
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effEditOpen> again
xxx calling effect->dispatcher<effEditIdle>
xxx vstgltest: redraw window
xxx call processreplacing
xxx calling effect->dispatcher<effEditClose>
xxx calling effect->dispatcher<effClose>
xxx debug_host: closing library
xxx debug_host: library closed
xxx debug_host: exiting

i.e. it opens some windows and does not crash.

I made some minor changes:

Next I installed Qtractor, added /usr/local/lib/vst/ to the VST search path (View->Options->Plugins), created a track, and added the VST GL Test plugin. I was then able to 'Edit' the plugin which showed a window that was not being repainted (as expected since I had to comment out the redrawWindow() function).

Then I shut down the VM, turned off the 3d acceleration (can't remember this ever worked properly..), uncommented the redrawWindow code and ran the vst2_debug_host again. This time it didn't crash but the window only seemed to be repainted once (green).

Unfortunately, Qtractor now wasn't able to see the plugin anymore (even after commenting the redrawWindow code again).

Since Qtractor (at least my copy, installed via apt-get) also seemed very buggy (I couldn't save the session or create a second track since the "Ok" buttons were disabled for some reason), plus it did not output any of the VST plugin messages to the console, I now tried Renoise.

During startup, Renoise claims that it has found (1) VST plugin (there's no console log output for this) but once that startup is complete, the plugin lists are all empty, with no indication what happened to that VST plugin it found earlier. Hmm.

Next I tried Ardour (ardour5). It shows an "Audio/MIDI Setup" dialog (which defaults to ALSA) but clicking "Start" results in a dialog that says "Failed to open audio device" (and it prints "RESPONSE -1" to the console). I have no idea what this means. Renoise was able to open the ALSA device (after I removed+killed pulseaudio) just fine, and aplay on the console works, too.

Up next: energyXT (demo version). It starts up w/o issues and it sees the debug_lglw.so plugin. However, when trying to actually load it, it says "Failed to open debug_lglw". There's no further information about what went wrong. It does not seem to call the plugin`s VSTPluginMain function (which calls lglw_init() which in turn prints a log entry to /tmp/lglw_log.txt). The strace log entries look like this:

stat64("/usr/local/lib/vst/debug_lglw.so", {st_mode=S_IFREG|0755, st_size=31704, ...}) = 0
stat64("/usr/local/lib/vst/debug_lglw.so", {st_mode=S_IFREG|0755, st_size=31704, ...}) = 0
open("/usr/local/lib/vst/debug_lglw.so", O_RDONLY|O_CLOEXEC) = 4
read(4, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 \32\0\0004\0\0\0"..., 512) = 512
fstat64(4, {st_mode=S_IFREG|0755, st_size=31704, ...}) = 0
mmap2(NULL, 28948, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0xb408e000
mmap2(0xb4094000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 4, 0x5000) = 0xb4094000
close(4)                                = 0

i.e. it opens the plugin, reads a few header bytes, calls fstat/mmap2 (not sure what these are for), then immediately closes the plugin. Does it expect a windows DLL file ?

While searching for alternative hosts, I found this Linux Journal article, written by.. Dave Phillips (not a coincidence, I guess ;)).

Dave, do you have any suggestions ?

bsp2 commented 6 years ago

So it looks to me like my crash occurs when it tries to load the Befaco Spring Reverb module.

I've seen this happen when the plugin directory detection failed in earlier version of the plugin. The Befaco module tries to load an asset file and when that fails, it just crashes. I thought that with the new plugin detection code (i.e. the one that uses dladdr()), this issue had been resolved (you posted a log last week). Maybe you copied the .so file to somewhere outside of vst2_bin/ and that's why the asset files are not found ?

However, I think we should all concentrate on the simple debug plugin first before trying the actual, much more complex VSVR plugin.

The only hosts that managed to load the plugin so far (on my machine) were the debug host and Qtractor, and Qtractor stopped working after a short while (see my previous msg).

bsp2 commented 6 years ago

I just tried to load the VSVR instrument plugin in Renoise and it showed up in the plugin browser. I'll try to find out what's different about the debug plugin..

bsp2 commented 6 years ago
Renoise LOG> Audio Plugins: Searching for VST plugins in '/mnt/git/VeeSeeVSTRack/vst2_bin/'
Renoise LOG> VstPlugs: Trying to instantiate /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so
vstgltest: entering VSTPluginMain... 
vstgltest: dllname="/mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so"
vstgltest: calling lglw_init()
vstgltest: lglw_init() returned lglw=0xf0e65f0
Renoise LOG> VstPlugs: Analyzing VST plugin 'bsp: debug_lglw', Unique ID:1952805748, Version:0
vstgltest: effSetSampleRate(44100.000000)
vstgltest: effSetBlockSize(256)
vstgltest: effOpen
vstgltest: openEffect()
vstgltest: effSetSampleRate(44100.000000)
vstgltest: effSetBlockSize(256)
vstgltest: effMainsChanged(1)
Renoise LOG> VstPlugs: Instantiate OK
Renoise LOG> VstPlugs: Releasing /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so (finalizing the plugin)...
vstgltest: effMainsChanged(0)
vstgltest: effClose
Renoise LOG> VstPlugs: Releasing /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so (unloading the DLL)...
Renoise LOG> VstPlugs: /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so was successfully released
Renoise LOG> VstPlugs: Trying to instantiate /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so
vstgltest: entering VSTPluginMain... 
vstgltest: dllname="/mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so"
vstgltest: calling lglw_init()
vstgltest: lglw_init() returned lglw=0xe5f9298
Renoise LOG> VstPlugs: Analyzing VST plugin 'bsp: debug_lglw', Unique ID:1952805748, Version:0
vstgltest: effSetSampleRate(48000.000000)
vstgltest: effSetBlockSize(512)
vstgltest: effOpen
vstgltest: openEffect()
vstgltest: effSetSampleRate(48000.000000)
vstgltest: effSetBlockSize(512)
vstgltest: effMainsChanged(1)
Renoise LOG> VstPlugs: Instantiate OK
vstgltest: unhandled VSTPluginDispatcher opcode=32
vstgltest: unhandled VSTPluginDispatcher opcode=32
vstgltest: effMainsChanged(0)
vstgltest: effMainsChanged(1)
vstgltest: unhandled VSTPluginDispatcher opcode=32
vstgltest: unhandled VSTPluginDispatcher opcode=32
Renoise LOG> VstWindow: Creating a new X11Window...
Renoise LOG> VstWindow: Setting X11Window properties...
Renoise LOG> VstWindow: Give the plug access to the X11Window...
vstgltest: unhandled VSTPluginDispatcher opcode=61
Renoise LOG> VstWindow: Query the X11Window child...
Renoise LOG> VstWindow: Will forward events to the plugs _EventProc property...
Renoise LOG> VstWindow: Setting new Windowsize 640, 480
Renoise LOG> VstWindow: Mapping the window...
Renoise LOG> VstWindow: Setting new Windowsize 640, 480
vstgltest: unhandled VSTPluginDispatcher opcode=32
vstgltest: unhandled VSTPluginDispatcher opcode=32
vstgltest: redraw window
vstgltest: redraw window
vstgltest: redraw window
[repeats several hundred times]
[..]
Renoise LOG> VstWindow: Closing the Editor...
Renoise LOG> VstWindow: Editor was closed
Renoise LOG> Application: Exit...
vstgltest: unhandled VSTPluginDispatcher opcode=25
vstgltest: effMainsChanged(0)
vstgltest: effMainsChanged(1)
Renoise LOG> Shut down: Stopped the Player
Renoise LOG> MIDI: Shut down: Closing all acquired MIDI devices...
Renoise LOG> MIDI: Shutting down MIDI server...
Renoise LOG> MIDI-IO: Closing MIDI in device 'Renoise MIDI In Port A'...
Renoise LOG> MIDI-IO: Closing MIDI in device 'Renoise MIDI In Port B'...
Renoise LOG> MIDI-IO: Closing MIDI in device 'Renoise MIDI In Sync'...
Renoise LOG> MIDI-IO: Closing MIDI out device 'Renoise MIDI Out Sync'...
Renoise LOG> MIDI-IO: Shutting down the MIDI sequencers...
Renoise LOG> Shut down: Stopped and released all MIDI-Devices
Renoise LOG> ALSA: Stopping ALSA playback...
Renoise LOG> Shut down: Stopped and released the active Audio-Device
Renoise LOG> Shut down: Destroyed the Player
Renoise LOG> Shut down: Destroyed the Document
Renoise LOG> Shut down: Destroyed the GraphPort
Renoise LOG> Shut down: Saving the Preferences
Renoise LOG> Shut down: Destroyed the Preferences
Renoise LOG> Shut down: App is down
Renoise LOG> Application: Exit OK
Renoise LOG> VstPlugs: Releasing /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so (finalizing the plugin)...
vstgltest: effMainsChanged(0)
vstgltest: effClose
Renoise LOG> VstPlugs: Releasing /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so (unloading the DLL)...
Renoise LOG> VstPlugs: /mnt/git/VeeSeeVSTRack/vst2_bin/debug_lglw.so was successfully released
Renoise LOG> Application: Finalizing the API...
Renoise LOG> Closing log file...

This is looking much better (see latest commits).

The debug plugin now loads in Renoise, the editor window is visible, and everything shuts down properly without any crashes.

bsp2 commented 6 years ago

It also works in Qtractor. The trick is to set the track type to "Audio" when adding a new track. Then the debug plugin can be selected on the "Plugins" tab. Clicking "Edit" in the plugin's context menu will show the editor window.

davephillips commented 6 years ago

I've built the debug plugin but hit this error with the debug_host :

[dlphilp@The6300 vst2_debug_host]$ ./vst2_debug_host 
xxx calling mainProc
vstgltest: entering VSTPluginMain... 
vstgltest: dllname="/home/dlphilp/src/VeeSeeVSTRack/other/vst2_debug_host/../../vst2_bin/debug_lglw.so"
vstgltest: calling lglw_init()
vstgltest: lglw_init() returned lglw=0xabf660
xxx mainProc returned effect=0xabf590
xxx calling effect->dispatcher<effOpen>
vstgltest: effOpen
vstgltest: openEffect()
xxx effect->dispatcher<effOpen> returned
xxx XEventProc found... calling
Segmentation fault (core dumped)

The window opens for a few seconds then segfaults. Any suggestion what I may have missed ?

davephillips commented 6 years ago

Also tested in Bitwig 2.3.4. The window opens as a transparency. Screenshot attached. Am I at the same point as you guys ? debug_lglw

davephillips commented 6 years ago

Btw, the plugin loads and unloads in BW without problems and the test window opens and closes correctly. Nice work so far.

bsp2 commented 6 years ago

Can you please pull the latest commits ? I accidentally checked in the no-op redrawWindow function. That should fix the transparency issue.

EDIT: I also added a call to XInitThreads() in lglw_init(). Not really sure it's correct (see here).