Difference between revisions of "How To Build and Deploy LV2 Plugin to MOD Duo"

From MOD Wiki
Jump to navigation Jump to search
Line 3: Line 3:
 
In order to have a LV2 plugin running in a MOD Device you'll need the following:
 
In order to have a LV2 plugin running in a MOD Device you'll need the following:
  
# Understand the very basics of LV2
+
# LV2 Basics
# Create a new LV2 plugin
+
# Get the LV2 plugin source code
 
# Get the build tools
 
# Get the build tools
 
# Create your project make files
 
# Create your project make files
Line 13: Line 13:
 
Let's dive in.
 
Let's dive in.
  
== Basics of LV2 ==
+
== LV2 Basics ==
  
 
* [http://www.nongnu.org/ll-plugins/lv2pftci/ LV2 programming for the complete idiot]
 
* [http://www.nongnu.org/ll-plugins/lv2pftci/ LV2 programming for the complete idiot]
* [http://lv2plug.in/ LV2 Official Site]
+
* [http://lv2plug.in/book/ LV2 Book]
 
* [http://harryhaaren.blogspot.com/2012/06/writing-lv2-plugins-lv2-overview.html Writing Lv2 plugins : An Lv2 Overview]
 
* [http://harryhaaren.blogspot.com/2012/06/writing-lv2-plugins-lv2-overview.html Writing Lv2 plugins : An Lv2 Overview]
  
== Create a new LV2 plugin ==
+
== Get the LV2 plugin source code ==
  
TODO: add samples
+
For this guide we'll be using an example from the [https://github.com/drobilla/lv2 lv2 project] itself but any example would do.
 +
The example we'll use is [https://github.com/drobilla/lv2/tree/master/plugins/eg-amp.lv2 eg-amp.lv2].
 +
 
 +
So we need to clone this repo:
 +
 
 +
<source lang="console">
 +
$ cd
 +
$ git clone https://github.com/drobilla/lv2
 +
</source>
 +
 
 +
For this guide we'll include a source code tarball along with the .mk file, so let's create it.
 +
 
 +
<source lang="console">
 +
$ cd lv2/plugins/eg-amp.lv2
 +
$ tar -cf ../eg-amp-source.tar *.c *.ttl* wscript
 +
</source>
  
 
== Get the build tools ==
 
== 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 that particular hardware and software (libraries).
+
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.
Luckily this process has been made easy. All you need is to clone [https://github.com/moddevices/mod-plugin-builder MOD Plugin Builder] and follow the [https://github.com/moddevices/mod-plugin-builder/blob/master/README.md instructions].
+
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 [https://github.com/moddevices/mod-plugin-builder MOD Plugin Builder] and follow the [https://github.com/moddevices/mod-plugin-builder/blob/master/README.md instructions].
 +
 
 +
In summary:
  
 
<source lang="console">
 
<source lang="console">
 +
$ cd
 
$ git clone https://github.com/moddevices/mod-plugin-builder
 
$ git clone https://github.com/moddevices/mod-plugin-builder
 
$ ./bootstrap.sh
 
$ ./bootstrap.sh
 
</source>
 
</source>
 +
 +
Once the process is finished you should have local binary called <code>build</code>.
  
 
== Create your project make files ==
 
== Create your project make files ==
  
mod-plugin-builder is based on [https://buildroot.org/ Buildroot] which requires you to create make files that indicate how you plugin should be built.
+
The build process is based on [https://buildroot.org/ Buildroot] which requires you to create make files that indicate how you plugin should be built.
You must have a <code>{projectname}.mk</code> file in <code>mod-plugin-builder/plugins/package/{projectname}</code> folder.
+
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 <code>.</code> with <code>-</code>.
 +
 
 +
<source lang="console">
 +
$ 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
 +
</source>
 +
 
 +
The content of the .mk file for our eg-amp example should be:
 +
 
 +
<source>
 +
######################################
 +
#
 +
# 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))
 +
 
 +
</source>
 +
 
 +
== Compile it ==
 +
 
 +
<source lang="console">
 +
$ cd ~/mod-plugin-builder/
 +
$
 +
</source>

Revision as of 05:15, 5 May 2016

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/
$