gen~, JUCE

alexmstahl's icon

hi

I appreciate the effort that went into https://github.com/Cycling74/gen-plugin-export a few years ago....an example of exporting gen~ code into JUCE, and then buiding audio plugins. I tried it with macOS 10.12.5, Max 7.3.4, XCode 8.3.3, JUCE 5.0.2, and I get a few compile errors, pasted below.

Any suggs, or advice to abandon this path and find some other route? I have an urgent need to share some DSP algorithms with film sound designers and unfortunately they don't all use Live (yet :-).

The following build commands failed:

    CompileC build/C74GenPlugin.build/Debug/C74GenPlugin.build/Objects-normal/x86_64/PluginProcessor.o /Users/alex/JUCE/gen-plugin-export-master/Source-Plugin/PluginProcessor.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler

    CompileC build/C74GenPlugin.build/Debug/C74GenPlugin.build/Objects-normal/x86_64/PluginEditor.o /Users/alex/Dropbox/SubPac/JUCE/gen-plugin-export-master/Source-Plugin/PluginEditor.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler

    CompileC build/C74GenPlugin.build/Debug/C74GenPlugin.build/Objects-normal/x86_64/juce_AAX_Wrapper-30033AC6146DE144.o /Users/alex/JUCE/gen-plugin-export-master/JUCE/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler

Timothy Place's icon

Hi Alex,

I'm taking a look at this now and should have something for you shortly.

Cheers!

alexmstahl's icon

Hi Timothy,

Thanks so much! Let me know if any additional info would be helpful. The errors vary depending on what plugin format I choose, and building for iOS seems to work. I've tried the older JUCE framework in the Git project as well as the latest.

Thanks again for taking a look into this, much obliged.

cheers

Timothy Place's icon

Starting from the beginning... I'm on OS 10.12.4 with Xcode 8.3.3. I clone from https://github.com/Cycling74/gen-plugin-export and then open gen-example.maxpat in Max 7.3.4. I click the green message box that says "exportcode". And the Max window outputs a ton of stuff. 7 lines from the end it says:

** BUILD SUCCEEDED **

I'm gathering that you do not experience this?

If I open the Xcode project at VST-Builds/MacOSX/build/Debug/C74GenPlugin.xcodeproj and build then it also build successfully, albeit with 71 warnings.

On second look though, I cannot tell what plug-in type are you targeting. I was assuming VST, but may this isn't true? The tip-off that it may not be true is the reference to "AAX" in your compiler errors.

My next steps will be to upgrade my OS to 10.12.5 (and test) and then upgrade the version of JUCE to 5 (and test again).

Thanks for any additional info you have.

alexmstahl's icon

Yes, I was trying different plugin types. So I just did a regression test with a fresh clone, and still got:

...[tons of output, lots of warnings about multiple group membership, malformed project, etc.]...

** BUILD FAILED **
The following build commands failed:
CompileC build/C74GenPlugin.build/Debug/C74GenPlugin.build/Objects-normal/x86_64/juce_VST_Wrapper-2E77B871A9FAD96A.o /Users/al
ex/Downloads/gen-plugin-export-master/JUCE/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp normal x86_64 c++ com.appl
e.compilers.llvm.clang.1_0.compiler
(1 failure)

If I try building in Xcode, I get 128 linker errors that mostly mention AUMidiBase, AUEffectBase, etc. ?

I remembered I was still using Max 7.3.3 so I tried again with 7.3.4. Same result.

------

If I change the exportscriptargs type to iOS, I get:


** BUILD FAILED **
The following build commands failed:
CompileC build/C74GenPlugin.build/Debug/C74GenPlugin.build/Objects-normal/x86_64/juce_VST_Wrapper-2E77B871A9FAD96A.o /Users/al
ex/Downloads/gen-plugin-export-master/JUCE/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp normal x86_64 c++ com.appl
e.compilers.llvm.clang.1_0.compiler
(1 failure)

BUT if I then build from Xcode, it succeeds and works in the iPhone simulator.


------

If I change to AU, now I get BUILD SUCCEEDED. However if I try loading the build (~/gen-plugin-export-master/AU-Builds/MacOSX/build/Debug/C74GenPlugin.component) the Max console reports:

C74GenPlugin.component: no format AudioUnit exists

I tried moving the component to /Library/Audio/Plug-Ins/Components/ and that didn’t help.


Thanks again sooooo much for looking into this!

cheers

alexmstahl's icon

p.s. my intuition says when changing plugin type, maybe some intermediate output from the previous export needs to be cleaned up first. just a thought.

Timothy Place's icon

The error in Max you posted is a VST plug-in build error. The next error you posted (from Xcode) is a link error for AudioUnit stuff (e.g. AUEffectBase) but the paths still look like you are build a VST. So that's strange.

Have you followed the directions in the ReadMe to copy the various AudioUnit files into the Xcode application bundle? Sometimes updating Xcode will subsequently delete those files...

FWIW, I did update to OS 10.12.5 and it made no difference -- things are still building fine for me for the VST.

Timothy Place's icon

Hi again... I've just pushed a new juce5 branch to the Github repository. It is working here but there could be wrinkles. At least we know it is possible to make it work!

Timothy Place's icon

For the sake of this thread (Alex and I had moved the discussion to email), using the above "juce5" branch did indeed work for gen-plugin-export, JUCE 5, OS 10.12.5, Xcode 8.3.3, and Max 7.3.4.

If anyone else is interested in how to get running with that, here is what I suggest...

1. With the "juce5" branch version of the package, open the help patcher and click the green export button.

If it succeeds, great! If not...

2. Launch the Projucer app (in the JUCE folder).

3. Open the jucer project in the Projucer. This will be called "tmp-C74-Gen-VSTPlugin.jucer" and located inside the "Jucer" folder.

4. Click the little Xcode icon just right of center at the top of the window. This should generate an Xcode project and then open it in Xcode.

5. Once it opens in Xcode, build the project in Xcode (click the "play" button).

alexmstahl's icon

Indeed, the example is working now for all plugin formats. Thanks Tim for your phenomenal support!

Olav Lervik's icon

I have a different issue...I'm not a programmer but know my way around max. when building in Xcode I get following issue: "Shell Script Invocation Error"
please download and install the VST3 SDK
Command /bin/sh failed with exit code 1

in JUCE the right path is selected for VST (I followed the tutorial on their site...). I have googled quite a bit but not found a solution. Xcode 8.3.3, Max 7.3.4, macOS 10.12.6, JUCE 5.1.1

Olav Lervik's icon

some guidance for whomever wishes to add a UI

1offby's icon

Thank you Olav!!!

AudioMatt's icon
Olav Lervik's icon

...with my mind on my patcher and my patcher on my mind....;-)

Carlo Cattano's icon

Hi there . I spent hours trying to export gen~ and compile a vst .
Under windows when using juce/introjucer (from original download) its working well and shows visual studio 2017, but when using the introjucer template in the folder from gen-code-export, it wont show . It just shows vs 2013 and then I get lots of errors when trying to compile.

Any hints about hits? before i start a new thread

Ernest's icon

introjucer needs to be updated for vs 2017. maybe use vs 2015 instead?

Carlo Cattano's icon

Thats the funny fact wich is beyond my understanding. When using Juce normally an launching from its own recent donwloaded introjucer , it works just fine . But when trying code export , and using the provided templates with introjucer , It just shows vs 2015. Im wondering too if I should try to use vs2015 , but it can be tricky on Latest w 10 version maybe and cause some other problems perhaps

Sean Wayland's icon

Hi all ,
I had. the same problem here.
please download and install the VST3 SDK
Command /bin/sh failed with exit code 1

I solved the problem by importing all the generated code from Source-Plugin ( overwriting the standard JUCE audio plugin files ) into a new projucer project. I also copied all the files from exported-code into the source directory without the nested directories. I might have had to add an absolute file path to find one of the header files . Can't remember. I succesfully built a .vst and component file from it.
It seems to load and work in Cubase I will send it around to a few friends see if they can get it to load ..

Sean

Sean Wayland's icon

OLAV! I love your video! So helpful!!
An easier way of solving the module paths that worked for me was to check "use global paths" in each module ..
Sean

Olav Lervik's icon

you're very welcome! :-)...let's hope it still holds up for a while before some version of something changes and everything's different again...I'm happy to see it helps!

Sean Wayland's icon

Thanks Olav,

I prefer PYO to max but I can't get it to compile properly inside juce.

I am having a bit of trouble using the param in gen~ now.

When I use the cycle operator with param it doesn't work in juce. Other operators combined with param seem to work .

I am getting a tonne of compile errors once I include param ..

int d8freq_dim = m_d8freq_18.dim;

int d8freq_channels = m_d8freq_18.channels;

"Member reference base type 't_sample' (aka 'double') is not a structure or union"

I have a "cycle" in gen~
cycle d1freq
and a "param"
param d1freq 0.43 @min 0.1 @max 5
    
Can anyone shed any light here?


Sean

Sean Wayland's icon

I managed to solve the issue ...
I created a float object above the cycle object with a param attached and sent the value of the float into the cycle object and it worked! Time to build a nice gui with Olav's help !!

Sean Wayland's icon

OLAV!
Look !
You rock !!
Thanks!!!

"I'm so happy I didn't have to type all that sh#t"

Olav Lervik's icon

wow! happy to be of help! merry Christmas to all of you max-lers out there!

Sean Wayland's icon

Merry Christmas!
I have one final problem.
When a sliders are saved as a preset in the DAW when a new preset is loaded the sliders head back to zero. I believe the preset is updated the values but not moving the sliders.
Any clues out there on the internet ?
Sean

Sean Wayland's icon

I am thinking of adding this to the JUCE processor class to snap the sliders to the position of all the parameters in the GEN74 struct

I was thinking that I could try set the slider values in the processor class at this point ..
```
void C74GenAudioProcessor::setCurrentProgram (int index)
{

d1LevelSlider::setValue ( C74_GENPLUGIN::getparameter(1))
d2LevelSLier::setValue ( C74_GENPLUGIN::getparameter(2))

}
```

I might try that and see what happens ...

Sean Wayland's icon

I came up with a sh#tty solution that works for now ..

I created a textbutton called "Load Current Preset"

The button just sets the value of the sliders to whatever is stored in the parameters of the C74 class

eg :

``` d1LevelSlider->setValue(processor.getParameter(0));
d1freqSlider->setValue(processor.getParameter(1));
d1timeSlider->setValue(processor.getParameter(2));
```
Perhaps it's better that only the editor class is messing with the slider pointers ...

Calling all that stuff from
setCurrentProgram (int index)
within the processor class might cause threading issues I guess.

Probably an experienced JUCE? C++ programmer ( not me! ) could figure out a more elegant solution. At lease it works pretty good!
Sean

Olav Lervik's icon
AxiomCrux's icon

OMGOMGOMG YES!
I had been so stoked on this a couple years ago when I discovered it and got it working, but then I circled back around to it when I had more time and it didn't work, but just now thanks to this thread I got this working again using the new JUCE5 branch, and holy moly theres even a video about UI/JUCE.. Hell yes!

I think that maybe this should become the main branch, because I was futzing around with the old version a few times this year and thought this got abandoned.. which would be kinda shocking.

A few notes:
The first time I tried with the new branch, I got an error from the script because I had a space in one of the directories names and it didn't even run anything.
The second time It got pretty far but it couldn't find the VST SDK that I had installed based on the standard JUCE location of ~/SDKs/VST_SDK/VST3_SDK as the script was looking in ~/SDKs/VST3 SDK/ with the space instead of underscore and one directory up. This is odd in reference to my earlier error due to a space in the location of the patch folder having a space.

Also in the new branch, do you really need the whole JUCE 5 distro? The examples and extras folder with all their subfolders for different platforms make this rather large, adding about 40mb to this. They have all also been superseded by tiny PIP projects in JUCE 5.3 for that matter.

AxiomCrux's icon

Incidentally, the link in the max gen documentation for VST export results in a page not found :
https://cycling74.com/wiki/index.php/error/404

AxiomCrux's icon

I have been working on figuring out a way to not have to copy-paste all the code as mentioned in the tutorial video by OLAV LERVIK to facilitate using the generated GUI directly without needing to copy paste, and in the process noticing a number of issues in the modifications to the JUCE project that I am trying to figure out how to fix.

For one, the post compile script in the jucer project references the build-results directory which no longer exists, and also I can not quite figure out where the Xcode project is compiling to now.. it appears to be an alias thats directing the file to the user library vst plugins folder now.. so maybe this post compile script simply needs to be removed.

Damn this is one hell of a wormhole..

ctrl+opt's icon

hey'all,

So I was very excited to find this thread as I'm having some of the same issues.
Im on OS 10.12.5 using JUCE v5.3.2 and Xcode v8.3.2
So my initial error was the same as that of Sean and Olav:

please download and install the VST3 SDK
Command /bin/sh failed with exit code 1

That was using the original package on github.

I tried using the updated JUCE-5 branch and still had the same error code.

I tried following Sean's tip above to open a new projucer project and move all my files into the source directory. this resulted in some different errors:

Lexical or preprocessor issues > 'genlib.h' file not found


I tried replacing it with an absolute path but then the next header wasn't found.I tried replacing all three with absolute paths and then everything broke real bad like dozens of errors, so I stepped back.

maybe i should try moving all the stuff into the new Projucer project but with the original branch. not sure if Sean was using the original branch or the juce-5 branch.

wondering if anyone knows what i might be doing wrong or how i could get this to work.

Any help would be greatly appreciated! Thanks in advance!

dsmd's icon

Hi All,

I've got the example to compile. Which makes me very happy!
The suggestion to move all the files into a new introjucer project worked! Thanks Sean.

crtl+opt, I've moved all the generated files into the source directory. And in the fresh introjucer project imported all of them.
I'm using xcode 11.1 and projucer 5.4.5.

Now something weird is happening. Maybe somebody knows what's wrong?
The 'au' plugin is working as expected.
But the vst3 plugin doesn't seem to respond to parameter changes. And I have no clue why this is.
Anybody?

Sean Wayland's icon

My only suggestion here is you try targeting the Steinberg VST 3.6.5 referred to in he docs
https://github.com/Cycling74/gen-plugin-export

there is a link to it here :
https://steinbergmedia.github.io/vst3_doc/vstsdk/index.htmlI
never built a VST3 only the older VST ( VST2? ) with gen~. I don't think steinberg supports the old VST versions any more but I think you still should be able to build it if you can download that sdk somewhere. v
I have a mac running 10.13 something and I still build the older VST plugins using Xcode. I haven't upgraded to catalina.

Sean

dsmd's icon

Thanks Sean,

i’ll try that.

alexmstahl's icon

Revisiting this thread (after starting it 3 years ago.. :). Just checking in, wondering if anyone is currently working in this realm, and perhaps has recommended documentation, advice, or gotchas to look out for, given the current state of max, gen, juce and vst. I'm on macOS 10.14.6, max 8.1.3, Juce 6.0.1. TIA

bearded clumsybear's icon

Hello everyone! I just wanted to thank you all for your efforts in getting this to work. I have successfully built my gen patch using JUCE 5 on macOS 10.14.6. with the help of this thread.

Now I have upgraded the OS to Catalina, 10.15.7 and would like to use JUCE6 for this whole process.
Like @alexmstahl, I would like to know if anyone has experience with this setup.

D1rty Duck's icon

I got it working with JUCE6, XCode and Big Sur on the latest Update.
But I used a diffrent methode to do it: https://github.com/Cycling74/gen-plugin-export
However If you do it like it was explained there your getting the same Error report as CTRL+OPT was posting above. The solution was changing the top of gen_exported.h from
#include "genlib.h"
#include "genlib_exportfunctions.h"
#include "genlib_ops.h"

to:

#include "gen_dsp/genlib.h"
#include "gen_dsp/genlib_exportfunctions.h"
#include "gen_dsp/genlib_ops.h"

But I did not include a gui yet. However since Ableton can also control plugins without a gui, I was at least able to test if the plugin works and it did ^^.

bearded clumsybear's icon

Nice! Good to hear! I will try out your suggestions as soon as I get to update my projects.

Just to be sure I got you right:

you‘re saying that it’s possible to build from the cycling repo with the changes to your includes. But you actually did it another way?

if yes, may I ask what’s your method?

thanks for your reply btw :)

D1rty Duck's icon

I use the method described in the git-tutorial I've linked, which is indeed made cycling 74, but it's a different way than in the tutorial which is linked in the beginning of this thread, this what I meant with different method.

By the way one benefit I've noticed if you use XCode 12.3 (and I guess a few earlier versions, too), it will automatically compile it to run natively on X86 and ARM.

bearded clumsybear's icon

Thanks for clarifying!
ARM compatibility is great news.

bearded clumsybear's icon

Just wanted to let you guys and gals know that I successfully build the AU version of my plugin on macOS 11.1 with Xcode 12.3 and JUCE 6.

Had to change the includes like D1RTY DUCK suggested and I had some issues with building arm64 architecture. so I had to exclude it. Although I guess it's only because Xcode 12 tries to build iOS as well. So just exclude the iOS Simulator SDK with the value arm64.

One thing I still have to figure out is the AU validation for Logic X.
It passes all tests but I got the following result in the end:

--------------------------------------------------
AU VALIDATION SUCCEEDED.
--------------------------------------------------

validation result: crashed validation

so it seems to be working but crashes the validation in the last step.

Any ideas?

D1rty Duck's icon

So I tried now to build a GUI and the gui itself worked but the faders of the gui are not connected to the parameters shown in Ableton.

If I move one of the sliders the sound changes as it should. But if I move a slider on the plugin the slider in Ableton doesn't move. Same thing if I move a slider in Ableton the slider on the plugin dosen't move. So this means I can actually control my plugin with the GUI and I can automate it but if I automate any parameter, the GUI won't reflect the change that is happening.
Any idea why this is happening?
I actually followed the GUI Tutorial of Olav.
Another problem I have is that the GUI only works on the AU version, the VST version doesn't show any GUI at all.

bearded clumsybear's icon

Ah yeah, I remember that I had the same issue. not quite sure how I resolved it. Have to look into it and will try to get back to you with a solution.

Do you have Logic Pro by any chance to check if your build gets validated correctly? asking because I’m struggling with validation like mentioned in the last post.

D1rty Duck's icon

No I don't have Logic, but I'll try it in Garageband.

D1rty Duck's icon

So I was trying the plugin in GarageBand and it's working fine (if you ignore GUIproblem I already as in Ableton). And I didn't had to do anything extra for the validation.
Maybe take at the gitHub-Tutorial, they wrote something about what to try if there are problems with validation: https://github.com/Cycling74/gen-plugin-export

To the GUI thing, do you maybe have an examplepatche? So I could see what's different to what I did?

D1rty Duck's icon

I got halve of the problem solved, now the daw reacts to changes on the plugin siliders. But the plugin GUI still dos not react to parameterchanges in the DAW like automation).

bearded clumsybear's icon

Good to hear! what was the issue?

I just opened my gen JUCE project first time since a year. Have to take a thorough look at what I did there. My sliders seem to be reacting to DAW parameter changes, but it crashes the DAW after a couple of changes.

How is it working on your side?

D1rty Duck's icon

I overwrote them with new parameters in a ValuTreeState. Or with other words, you have to dive deeper into JUCE ,if you really want to create great plugins. There's definitely a few things to learn in JUCE if you want to port gen~ code to a plugin.

bearded clumsybear's icon

True, I'm struggling to properly convert gen~ double sample processing to JUCE float sample processing at the moment. Getting weird stepped processing instead of smooth transitions while moving parameters. Have to figure out what the issue is there.

Like you said, there is a lot to learn to effectively convert gen~ code to c++

D1rty Duck's icon

Hmm just check if you really made clear that it's float not int. For example don't write 100 but 100.f, a bit like in Max. I'm not an expert in C++, but I heard/read this a few times in some JUCE Tutorials. Or the other problem could be that Gen~ is expecting values between 0 and 1, so you have to normalize the value to that range before sending them from JUCE to Gen~. I plan to share one of my projects in the future, with the adjusted code, however I want to optimize the code before and make shure that I have solved all problems ^^, so I have to make a bit more testing to find bugs that may still be in there.

Isabel Kaspriskie's icon

Hi all! The master branch of the gen-plugin-export repository has been updated to use JUCE 6. The export helper patch (located at source/GenPluginExport.maxpat) has been revamped with up to date instructions and step-by-step guidance. The patch also now use Node for Max as a backend post-export script (instead of Python, meaning Windows users no longer have to install Python as a dependency).

The JUCE 5 branch is still available for those who depend on it.

bearded clumsybear's icon

Does someone have any suggestions on how to overwrite the parameters with JUCE Value Tree State parameters?

@D1RTY DUCK
You mentioned that you overwrote them somehow, can you elaborate a bit or show some code snippets?

cheers

D1rty Duck's icon

Just make a Value Tree it will overwrite them automatically.
However there is still a few other things to be done.
First make shure that in gen the parameters are in an order so that it will start with those parameters which you have in your ValueTree ( f.e. I made a synth, so have some parameters in gen to pass over Midi, which of course is not in the valuetree). The order in Gen will be first capital letter, than small ones and at last numbers. Withe the letters they are sortet alphabeticly.

than you have to go into getnumparameters and delet what’s inside. Because it will return the number of parameters in gen, but you actually want it to return the amount of parameters in your ValuTree. You can type in the number manually here or better have it read the amount of parameters in your valueTree.

at last you have to corret setparameter.
this will send the values of your Valutreeparameters to your gencode. But the code in there is made with receving a 0-1 valu in mind that will be corrected to the right valu. But the valuetree parameter will send the right value so you have to delet all that math which “corrects” the vale.

I think this should be everything for the start. If you want to learn more about how valuetrees work and how they are implemented I recommend you “the audioprogrammer” on YouTube he has a lot of great videos about JUCE.