Page 1 of 2
Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Sun Oct 13, 2019 8:07 am
by Basslint
There are several libre JUCE plugins around that can't be easily run on GNU/Linux due to the fact that they use the official release of JUCE, so they only support VST2s (annoying because of the SDK, DMCAs, deprecated standard, etc.).
I'd like to port them to DISTRHO/juce so that they can be built as LV2 plugins. What steps do I have to follow in order to do that?
I am looking at an example like
https://github.com/jpcima/tunefish (which replaced the official JUCE on
https://github.com/paynebc/tunefish with DISTRHO/juce) but if someone who's more experienced than I am has some tips, I would be very grateful for them

Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Thu Oct 17, 2019 5:06 am
by Kott
I'll post it here.
Let's take
https://github.com/cognitone/sprike because it very same as Tunefish4 and uses "old" JUCE.
after git clone add DISTRHO-JUCE as submodule inside Sprike dir:
git submodule add https://github.com/DISTRHO/juce.git thirdparty/JUCE
build Projucer:
cd thirdparty/JUCE/extras/Projucer/Builds/LinuxMakefile/
make
now we have to run Projucer and make some additions to Sprike.jucer: change moudules path to ../thirdparty/JUCE/modules , turn on options that you want: enable standalone, jack etc
save, it will generate general Makefile
Then I took
LV2.mak and
generate-lv2-ttl.py from
https://github.com/jpcima/tunefish/tree ... /tunefish4
add LV2.mak to Makefile:
echo "include ../../LV2.mak" >>Builds/LinuxMakefile/Makefile
changed plugin name in LV2.mak
add LV options to JuceLibraryCode/AppConfig.h :
Code: Select all
// [BEGIN_USER_CODE_SECTION]
// (You can add your own code in this section, and the Projucer will not overwrite it)
#define JucePlugin_Build_LV2 1
#define JucePlugin_LV2URI "https://github.com/cognitone/sprike"
// [END_USER_CODE_SECTION]
that's all (IIRC), go to Builds/LinuxMakefile and do make
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Wed Oct 23, 2019 12:18 am
by Kott
As with "official" version 5.1.2 thinks go well. Recent version of JUCE with Debian patches
https://salsa.debian.org/multimedia-tea ... ter/debian run me to troubles.
I can compile most of plugins that requires JUCE >=5.4.4
But they hangs the host when loaded. According to strace there infinite loop (or lock) in some futex, as I can understand, cause I know nothing of multithread programming.
We would be very appreciate any help in this issue, just tell me where to look at first.
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Mon Dec 16, 2019 5:50 pm
by jpo
Kott wrote:
I can compile most of plugins that requires JUCE >=5.4.4
But they hangs the host when loaded. According to strace there infinite loop (or lock) in some futex, as I can understand, cause I know nothing of multithread programming.
Hi,
You should try to replace the SharedMessageThread class in juce_LV2_Wrapper.cpp by this one:
Code: Select all
struct SharedMessageThread : public Thread
{
SharedMessageThread() : Thread ("Lv2MessageThread")
{
startThread (7);
while (! initialised)
sleep (1);
}
~SharedMessageThread() override
{
signalThreadShouldExit();
JUCEApplicationBase::quit();
waitForThreadToExit (5000);
}
void run() override
{
ScopedJuceInitialiser_GUI juceInitialiser;
initialised = true;
MessageManager::getInstance()->setCurrentThreadAsMessageThread();
ScopedXDisplay xDisplay;
while ((! threadShouldExit()) && MessageManager::getInstance()->runDispatchLoopUntil (250))
{}
}
bool initialised = false;
};
It should not deadlock anymore.
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Mon Dec 16, 2019 9:02 pm
by Basslint
jpo wrote:Kott wrote:
I can compile most of plugins that requires JUCE >=5.4.4
But they hangs the host when loaded. According to strace there infinite loop (or lock) in some futex, as I can understand, cause I know nothing of multithread programming.
Hi,
You should try to replace the SharedMessageThread class in juce_LV2_Wrapper.cpp by this one:
Code: Select all
struct SharedMessageThread : public Thread
{
SharedMessageThread() : Thread ("Lv2MessageThread")
{
startThread (7);
while (! initialised)
sleep (1);
}
~SharedMessageThread() override
{
signalThreadShouldExit();
JUCEApplicationBase::quit();
waitForThreadToExit (5000);
}
void run() override
{
ScopedJuceInitialiser_GUI juceInitialiser;
initialised = true;
MessageManager::getInstance()->setCurrentThreadAsMessageThread();
ScopedXDisplay xDisplay;
while ((! threadShouldExit()) && MessageManager::getInstance()->runDispatchLoopUntil (250))
{}
}
bool initialised = false;
};
It should not deadlock anymore.
Thank you, could you please release this code under the GPLv3? A "yes" is enough, just so that it is clear, otherwise it can't be used easily in someone else's code.
Edit: correct me if I am wrong but if someone modifies GPLv3 code, any modifications based upon it are GPLv3 too, so the licensing should be cleared already, it's just to make things easier in case someone finds this thread and wants to use that code.
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Tue Dec 17, 2019 4:28 am
by Kott
Gotcha!
jpo, this is very big step for humanity

Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Tue Dec 17, 2019 4:34 pm
by jpo
Basslint wrote:Thank you, could you please release this code under the GPLv3? A "yes" is enough, just so that it is clear, otherwise it can't be used easily in someone else's code.
It is basically the SharedMessageThread from the juce VST2 wrapper, so yes, it is gplv3
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Tue Jan 14, 2020 6:52 am
by Kott
Fork with LV2 support can be obtained in
https://github.com/lv2-porting-project/JUCE branch lv2
Basically it works (tested with couple JUCE synths), but not for IEM-Plugins
https://github.com/lv2-porting-project/JUCE they crashes with:
Code: Select all
Thread 1 "jalv.gtk" received signal SIGFPE, Arithmetic exception.
0x00007ffff43a284c in RoomEncoderAudioProcessor::updateBuffers() () from /home/kv/.lv2/RoomEncoder.lv2/RoomEncoder.so
(gdb) bt
#0 0x00007ffff43a284c in RoomEncoderAudioProcessor::updateBuffers() () at /home/kv/.lv2/RoomEncoder.lv2/RoomEncoder.so
#1 0x00007ffff44550a4 in RoomEncoderAudioProcessor::prepareToPlay(double, int) () at /home/kv/.lv2/RoomEncoder.lv2/RoomEncoder.so
#2 0x00007ffff4708766 in juceLV2_Activate(void*) [clone .lto_priv.0] () at /home/kv/.lv2/RoomEncoder.lv2/RoomEncoder.so
#3 0x000055555555cdce in lilv_instance_activate ()
#4 0x0000555555561758 in jalv_open ()
#5 0x0000555555561b98 in main ()
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Wed Sep 23, 2020 6:05 am
by Kott
Some good news. As with version 6 the JUCE has added CMake build framework. I've made modification to cmake files, mostly blind copy-paste but it works.
https://github.com/lv2-porting-project/ ... 279ce03d9a
Now it's possible to build LV2 plugins using CMake. And it is more easy than "classic" method because you don't need to modify Makefiles during building.
If you want to try:
0. Get branch from
https://github.com/lv2-porting-project/ ... layground/
1. Add LV2 to plugin's CMakeLists.txt. Example for
https://github.com/jatinchowdhury18/ChowPhaser
Code: Select all
cmake_minimum_required(VERSION 3.15)
project(ChowPhaser VERSION 1.1.0)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(modules)
# juce_set_vst2_sdk_path(C:/SDKs/VST_SDK/VST2_SDK/)
juce_add_plugin(ChowPhaserMono
COMPANY_NAME chowdsp
PLUGIN_MANUFACTURER_CODE Chow
PLUGIN_CODE Cph1
FORMATS AU VST3 Standalone LV2
ProductName "ChowPhaser Mono")
juce_add_plugin(ChowPhaserStereo
COMPANY_NAME chowdsp
PLUGIN_MANUFACTURER_CODE Chow
PLUGIN_CODE Cph2
FORMATS AU VST3 Standalone LV2
ProductName "ChowPhaser Stereo")
juce_generate_juce_header(ChowPhaserMono)
juce_generate_juce_header(ChowPhaserStereo)
add_subdirectory(src)
add_subdirectory(res)
target_compile_definitions(ChowPhaserMono
PUBLIC
JUCE_DISPLAY_SPLASH_SCREEN=0
JUCE_REPORT_APP_USAGE=0
JucePlugin_LV2URI="https://github.com/jatinchowdhury18/ChowPhaserMono"
define JucePlugin_MaxNumInputChannels=2
define JucePlugin_MaxNumOutputChannels=2
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JUCE_JACK=1
JUCE_VST3_CAN_REPLACE_VST2=0
FOLEYS_SHOW_GUI_EDITOR_PALLETTE=0
FOLEYS_ENABLE_BINARY_DATA=1)
target_compile_definitions(ChowPhaserStereo
PUBLIC
JUCE_DISPLAY_SPLASH_SCREEN=0
JucePlugin_LV2URI="https://github.com/jatinchowdhury18/ChowPhaserStereo"
define JucePlugin_MaxNumInputChannels=2
define JucePlugin_MaxNumOutputChannels=2
JUCE_REPORT_APP_USAGE=0
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JUCE_JACK=1
JUCE_VST3_CAN_REPLACE_VST2=0
FOLEYS_SHOW_GUI_EDITOR_PALLETTE=0
FOLEYS_ENABLE_BINARY_DATA=1)
target_link_libraries(ChowPhaserMono PRIVATE
BinaryData
juce::juce_audio_utils
foleys_gui_magic)
target_link_libraries(ChowPhaserStereo PRIVATE
BinaryData
juce::juce_audio_utils
foleys_gui_magic)
see these lines:
FORMATS AU VST3 Standalone
LV2
JucePlugin_LV2URI="
https://github.com/jatinchowdhury18/ChowPhaserMono"
define JucePlugin_MaxNumInputChannels=2
define JucePlugin_MaxNumOutputChannels=2
1.1 Dumb stump for not yet adopted wrapper:
touch cmake-build/ChowCentaur/ChowCentaur_artefacts/JuceLibraryCode/AppConfig.h
2. get lv2_ttl_generator (
https://build.opensuse.org/package/show ... _generator)
git clone
https://github.com/lv2-porting-project/ ... -generator
cd lv2-ttl-generator
make -f GNUmakefile
copy to some /path/to/lv2_ttl_generator for example to /usr/local/bin
3. build
cmake -B cmake-build -DLV2_TTL_GENERATOR=/usr/local/bin/lv2_ttl_generator
cmake --build cmake-build -j8
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Wed Sep 23, 2020 6:11 am
by Kott
I work on cutting most of these steps:
Get rid of Num*Channels, AppConfig.h by modifying LV2 Wrapper.
Include lv2_ttl_generator in JUCE code (are there who can help with CMake?)
so it just will require LV2 target and URI at end.
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Wed Oct 07, 2020 1:04 pm
by REIS0
So just recycling this post.
Currently I'm trying to recompile some windows and mac exclusive plugins to linux and lv2, but after setting up I got this error with the lv2 compilation
Code: Select all
Compiling include_juce_audio_plugin_client_LV2.cpp
Linking _juce_target_ - LV2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [../../../juce/LV2.mak.in:25: build/_juce_target_.lv2/_juce_target_.so] Error 1
I'm not sure what exactly is causing it, tested building the vst3 version for linux and everything goes well. I'm using a
fork I've made from the 5.4.7 branch from the lv2-porting-project/JUCE.
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Thu Oct 08, 2020 6:45 am
by Basslint
REIS0 wrote: ↑Wed Oct 07, 2020 1:04 pm
So just recycling this post.
Currently I'm trying to recompile some windows and mac exclusive plugins to linux and lv2, but after setting up I got this error with the lv2 compilation
Code: Select all
Compiling include_juce_audio_plugin_client_LV2.cpp
Linking _juce_target_ - LV2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [../../../juce/LV2.mak.in:25: build/_juce_target_.lv2/_juce_target_.so] Error 1
I'm not sure what exactly is causing it, tested building the vst3 version for linux and everything goes well. I'm using a
fork I've made from the 5.4.7 branch from the lv2-porting-project/JUCE.
Paging
@Kott
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Thu Oct 08, 2020 7:12 am
by Kott
Linking flags inherited from VST2 flags. So, if you don't build VST2 version these flags will be lost.
Just change in LV2.mak:
JUCE_CFLAGS_VST into JUCE_CFLAGS_VST3
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Thu Oct 08, 2020 6:18 pm
by REIS0
Kott wrote: ↑Thu Oct 08, 2020 7:12 am
Linking flags inherited from VST2 flags. So, if you don't build VST2 version these flags will be lost.
Just change in LV2.mak:
JUCE_CFLAGS_VST into JUCE_CFLAGS_VST3
Unfortunately this doesn't worked

, tried changing JUCE_CFLAGS_VST, JUCE_CPPFLAGS_VST and JUCE_LDFLAGS_VST, tried different variations with setting only one flag, two and all flags. I'm checking for more flags in the file but so far no progress.
Here's the currently
LV2.mak file that I'm using
EDIT: Apparently I was a little dumb and now I've figured out that the problem is this version of juce doesn't have a vst3 support for linux makefiles, currently I'm testing building a vst2 version with fst
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Posted: Fri Oct 09, 2020 12:03 am
by Kott
Can you tell what project you're working on?