Max gen~

From MOD Wiki
Revision as of 13:34, 28 October 2016 by FalkTX (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!)
Except 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.

DPF-Max-Gen

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.

Compiling

Native

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. :)

MOD

Compiling plugins for MOD can be done using mod-plugin-builder.