How To Build and Deploy LV2 Plugin to MOD Duo

From MOD Wiki
Revision as of 05:15, 5 May 2016 by Alercunha (talk | contribs)
Jump to navigation Jump to search

Introduction

In order to have a LV2 plugin running in a MOD Device you'll need the following:

  1. LV2 Basics
  2. Get the LV2 plugin source code
  3. Get the build tools
  4. Create your project make files
  5. Compile it
  6. Deploy it
  7. Publish it

Let's dive in.

LV2 Basics

Get the LV2 plugin source code

For this guide we'll be using an example from the lv2 project itself but any example would do. The example we'll use is eg-amp.lv2.

So we need to clone this repo:

$ cd
$ git clone https://github.com/drobilla/lv2

For this guide we'll include a source code tarball along with the .mk file, so let's create it.

$ cd lv2/plugins/eg-amp.lv2
$ tar -cf ../eg-amp-source.tar *.c *.ttl* wscript

Get the build tools

A LV2 plugin is just a binary. However to run in a MOD Device it must be compiled using a cross-compiler targeting our hardware and software. MOD Duo for example uses an ARM processor running a special flavor of Linux containing a specific set of libraries (dependencies).

Luckily this process has been simplified. All you need is to clone MOD Plugin Builder and follow the instructions.

In summary:

$ cd
$ git clone https://github.com/moddevices/mod-plugin-builder
$ ./bootstrap.sh

Once the process is finished you should have local binary called build.

Create your project make files

The build process is based on Buildroot which requires you to create make files that indicate how you plugin should be built. So let's create a new project folder and the necessary configuration files. The folder defines a package name so you must use the project name and then replace . with -.

$ cd ~/mod-plugin-builder/plugins/package
$ mkdir eg-amp-lv2
$ cp ~/lv2/plugins/eg-amp-source.tar eg-amp-lv2/
$ touch eg-amp-lv2/eg-amp-lv2.mk

The content of the .mk file for our eg-amp example should be:

######################################
#
# eg-amp-lv2
#
######################################

EG_AMP_LV2_VERSION = 1.0
EG_AMP_LV2_SITE_METHOD = file
EG_AMP_LV2_SITE = $(BR2_EXTERNAL)/package/eg-amp-lv2
EG_AMP_LV2_SOURCE = eg-amp-$(EG_AMP_LV2_VERSION).tar
EG_AMP_LV2_DEPENDENCIES =
EG_AMP_LV2_BUNDLES = eg-amp

EG_AMP_LV2_TARGET_WAF = $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(HOST_DIR)/usr/bin/python ./waf

define EG_AMP_LV2_CONFIGURE_CMDS
        (cd $(@D); $(EG_AMP_LV2_TARGET_WAF) configure --prefix=/usr)
endef

define EG_AMP_LV2_BUILD_CMDS
        (cd $(@D); $(EG_AMP_LV2_TARGET_WAF) build -j $(PARALLEL_JOBS))
endef

define EG_AMP_LV2_INSTALL_TARGET_CMDS
        (cd $(@D); $(EG_AMP_LV2_TARGET_WAF) install --destdir=$(TARGET_DIR))
endef

$(eval $(generic-package))

Compile it

$ cd ~/mod-plugin-builder/
$