Porting JUCE programs to DISTRHO/juce for LV2 support
Moderators: MattKingUSA, khz
-
- Established Member
- Posts: 1516
- Joined: Sun Jan 27, 2019 2:25 pm
- Location: Italy
- Has thanked: 385 times
- Been thanked: 299 times
Porting JUCE programs to DISTRHO/juce for LV2 support
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
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
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]
Please donate time (even bug reports) or money to libre software
Jam on openSUSE + GeekosDAW!
Please donate time (even bug reports) or money to libre software
Jam on openSUSE + GeekosDAW!
-
- Established Member
- Posts: 821
- Joined: Thu Mar 21, 2013 12:55 am
- Location: Vladivostok
- Has thanked: 65 times
- Been thanked: 124 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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 :
that's all (IIRC), go to Builds/LinuxMakefile and do make
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]
-
- Established Member
- Posts: 821
- Joined: Thu Mar 21, 2013 12:55 am
- Location: Vladivostok
- Has thanked: 65 times
- Been thanked: 124 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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.
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
Hi,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.
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;
};
-
- Established Member
- Posts: 1516
- Joined: Sun Jan 27, 2019 2:25 pm
- Location: Italy
- Has thanked: 385 times
- Been thanked: 299 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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.jpo wrote:Hi,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.
You should try to replace the SharedMessageThread class in juce_LV2_Wrapper.cpp by this one:
It should not deadlock anymore.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; };
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.
Last edited by Basslint on Tue Dec 17, 2019 1:11 pm, edited 1 time in total.
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]
Please donate time (even bug reports) or money to libre software
Jam on openSUSE + GeekosDAW!
Please donate time (even bug reports) or money to libre software
Jam on openSUSE + GeekosDAW!
-
- Established Member
- Posts: 821
- Joined: Thu Mar 21, 2013 12:55 am
- Location: Vladivostok
- Has thanked: 65 times
- Been thanked: 124 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Gotcha!
jpo, this is very big step for humanity
jpo, this is very big step for humanity
- Attachments
-
- Screenshot_20191217_142605.jpg (89.5 KiB) Viewed 13898 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
It is basically the SharedMessageThread from the juce VST2 wrapper, so yes, it is gplv3Basslint 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.
-
- Established Member
- Posts: 821
- Joined: Thu Mar 21, 2013 12:55 am
- Location: Vladivostok
- Has thanked: 65 times
- Been thanked: 124 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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:
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 ()
-
- Established Member
- Posts: 821
- Joined: Thu Mar 21, 2013 12:55 am
- Location: Vladivostok
- Has thanked: 65 times
- Been thanked: 124 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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
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
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)
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
-
- Established Member
- Posts: 821
- Joined: Thu Mar 21, 2013 12:55 am
- Location: Vladivostok
- Has thanked: 65 times
- Been thanked: 124 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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.
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
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
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.
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
-
- Established Member
- Posts: 1516
- Joined: Sun Jan 27, 2019 2:25 pm
- Location: Italy
- Has thanked: 385 times
- Been thanked: 299 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
Paging @KottREIS0 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 compilationI'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.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
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]
Please donate time (even bug reports) or money to libre software
Jam on openSUSE + GeekosDAW!
Please donate time (even bug reports) or money to libre software
Jam on openSUSE + GeekosDAW!
-
- Established Member
- Posts: 821
- Joined: Thu Mar 21, 2013 12:55 am
- Location: Vladivostok
- Has thanked: 65 times
- Been thanked: 124 times
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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
Just change in LV2.mak:
JUCE_CFLAGS_VST into JUCE_CFLAGS_VST3
Re: Porting JUCE programs to DISTRHO/juce for LV2 support
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