Max gen~

From MOD Wiki
Revision as of 13:45, 28 October 2016 by Jesseverhage (talk | contribs)
Jump to navigation Jump to search

This page describes how to get Max gen~ objects working as LV2 plugins, with the purpose of running them on the MOD.
Note that the same procedure also allows for building cross-platform VST2 plugins (Linux, Mac and Windows), but without a custom graphical interface.
In this page we'll focus on LV2 and MOD.

NOTE: This is a work in progress! (specially this page!)
Expect some information to be missing.

How it works

This works by mixing pre-existing plugin wrapper code with the gen~'s code export feature.
By exporting the code we can compile them together to create an LV2 plugin binary, then generate the meta-data from it.

The idea was based on the official gen-plugin-export project made by Cycling '74.
We're not using that project for MOD because it uses Juce, which requires quite a few things that unnecessary (not to mention a graphical server).

Based on that project was made DPF-Max-Gen, which uses the much simpler (and limited) DPF instead of Juce.
That way we no longer require X11, freetype and quite a few other things that Juce needs in Linux. The final binary code is also a lot smaller.
Since the plugin DSP code is all done in Max, the wrapper for exposing it as plugin does not really matter per se.
So we use the most lightweight and simple approach possible - in this case being DPF.


If you open the DPF-Max-Gen project page, you'll see a few things inside.
The most important part is the 'plugins' folder. Inside it there's more folders, each containing a separate plugin (with the exception of 'common', which provides the common/base code for gen~).

Taking the example of bitcrush, we have:

  • DistrhoPluginInfo.h
  • DistrhoPluginMaxGen.cpp
  • Makefile
  • gen_exported.cpp
  • gen_exported.h
  • gen~.bitcrush.maxpat

DistrhoPluginInfo.h is a C header file, required by DPF, that describes some plugin meta-data.
This includes name, author, description, LV2 URI and the amount of audio channels.
Modify this file as needed. Remember that LV2 URIs are global and unique, and don't have to be real online URLs.

DistrhoPluginMaxGen.cpp is a symlink to the real DistrhoPluginMaxGen.cpp file located in the common folder.
This symlink is here so that we compile a different instance per plugin, but the actual code is the same.
Do not modify this file.

Makefile contains the build rules for compiling the plugin.
The only thing that needs change here is the 'NAME' parameter, which specifies the target LV2 bundle and binary name for the plugin.

gen_exported.cpp/h is the output from Max gen~ code export utility.
You should get a few more files when export code, but only these 2 matter.

gen~.bitcrush.maxpat is the Max patch that was used to generate this plugin, being here only for reference.



Before trying to build the plugins for MOD, it's a good idea to see if they work locally on your own PC first.
After you git-clone the DPF-Max-Gen project (recursively, it has submodules), you can just do: cd DPF-Max-Gen make

If you're running Mac OS use 'make MACOS=true'.

After it finishes you'll have LV2 and VST2 plugins inside the bin folder.
See if they work on your favourite host. :)


Compiling plugins for MOD can be done using mod-plugin-builder.
See How_To_Build_and_Deploy_LV2_Plugin_to_MOD_Duo for more details.

Making your own plugins

Right now we do not have the process of turning the gen~ exported code into a plugin directly. You'll have to do some manual work.

A good starting point might be to just fork the DPF-Max-Gen project and use it to start your own.
The 'Makefile' file in the root folder contains the list of plugins to build, which reside in the plugins folder.

If you've handled makefiles before it should be pretty straight forward.
If not please contact us for ideas and discussion on how to possibly automate the creation of this type of plugin.