Wednesday, May 25, 2011

Lv2: New host lib, lilv, a newbies guid to LV2

Hey All,

Ever tried to get your head around the Lv2 spec? Me too, and if one isn't used to the "lingo" of URI's, RDF's, and various other path etc it can all be a bit daunting. Yet some of the coolest and best plugins (check: this Parametric EQ, or this IR reverb) are on the Lv2 standard, so you really do want to support them...

If you wanna get your hands dirty, skip down to the bulletpoints, that's what you'll need to do to get started!

With this new library from David Robillard writing hosts to use these plugins should become easier & faster. The library I'm talking about here is of course Lilv. It depends on two of Robillards other libraries, namely Serd & Sord.

Serd handles the reading & writing of RDF data, as well as Turtle & NTriples. Don't worry, I don't know what they are either. Perhaps in the future I'll try understand them...
Sord is a library for storing RDF data in memory... apparently we'll need that!?

Getting Started:
Create a folder somewhere where's your gonna do all this stuff.

Grab all of the following:
http://download.drobilla.net/lilv-0.4.0.tar.bz2
http://download.drobilla.net/sord-0.4.0.tar.bz2
http://download.drobilla.net/serd-0.4.0.tar.bz2

Ensure these are installed:
lv2core

Untar the lot of those .tar.bz2's from drobilla, and cd into the serd-0.4.0 dir.
./waf configure
./waf
sudo ./waf install

cd into the sord-0.4.0 dir,
./waf configure
./waf
sudo ./waf install

then cd into lilv-0.4.0
./waf configure

This shouldn't give any problems, as we've just installed the 2 dependencies you probably didn't have. If JACK or any other common issues arise, just fix them.

If you get the following errors:
Checking for header lv2/lv2plug.in/ns/lv2core/lv2.h : no
Checking for header lv2/lv2plug.in/ns/ext/event/event.h : no
Checking for header lv2/lv2plug.in/ns/ext/event/event-helpers.h : no
Checking for header lv2/lv2plug.in/ns/ext/uri-map/uri-map.h : no

Then this is what you do:
1. Direct your browser to http://lv2plug.in/spec/
2. Grab lv2core,lv2-event, and lv2-uri-map.
3. Untar lv2core, ./waf configure, ./waf, ./waf install it (the first one should be fixed now)
4. Run "lv2config", this creates some symlinks around to headers
5. Bop open a terminal, cd /usr/include/lv2/lv2plug.in/ns/
6. sudo mkdir ext
7. Copy the event folder into ext, and copy the uri-map folder in too.
8. *CHECK THE DIRECTORY STRUCTURE!!!* the output of ./waf configure tells you *exactly* where its looking for the files, *PUT THEM THERE*. Can't stress this enough. Use your brain & figure out what's not where its meant to be

./waf configure should print out yes yes yes yes yes yes to all dependencies now, so
./waf build,

Only if *building* fails, ie: ./waf fails like so:
[28/36] c: utils/lv2jack.c -> build/utils/lv2jack.c.7.o
In file included from ../utils/lv2jack.c:29:0:
/usr/include/lv2/lv2plug.in/ns/ext/event/event-helpers.h:28:52: fatal error: lv2/http/lv2plug.in/ns/ext/event/event.h: No such file or directory
compilation terminated.

Get to your favorite text editor, and sudo up the cow powers, because we've got a header to edit.
1. sudo /usr/include/lv2/lv2plug.in/ns/ext/event/event-helpers.h
2. Go to line 28. its contents should be: #include "lv2/http/lv2plug.in/ns/ext/event/event.h"
3. Change those contents to "#include "lv2/lv2plug.in/ns/ext/event/event.h"
4. ./waf build again.

Edit: The author of the event extension is planning a release to fix this issue.

and then sudo ./waf install the whole thing.

Boom! You've got lilv running.
Check the lilv-0.4.0/utils directory for some examples of using the library.
If you've built lilv, then in /build/utils there are the binaries of the examples. Run them while looking at the source, understand what to do.

In the /bindings/python dir there are 2 files, lv2_list.py & lv2_apply.py
They might provide some insight into the steps nessiary to get Lv2 plugins instantiated and in a good mood to work... :D

Finally a huge thanks to all the members of LAD who have developed this awesome standard, awesome plugins, and last but not least, awesome hosts! :D
Cheers, -Harry

6 comments:

  1. Nice tut, it's weird, I successfully compiled and installed serd, but sord can't copile because it can't find serd.??

    Global Configuration
    Checking for 'gcc' (c compiler) : ok
    Checking for 'g++' (c++ compiler) : ok
    * Install prefix : /usr/local
    * Debuggable build : False
    * Strict compiler flags : False
    * Build documentation : False

    Sord configuration
    Checking for program pkg-config : /usr/bin/pkg-config
    Checking for 'glib-2.0' >= 2.0.0 : yes
    Checking for 'serd-0' >= 0.3.0 : not found

    ReplyDelete
  2. pX, in the "serd" folder, (after building) you should have a folder called "build". In there there should be a file called "serd-0.pc". This is the file that pkg-config uses to do its dependecy checking. Upon "./waf install", it should say:

    + install /usr/local/lib/pkgconfig/serd-0.pc (from build/serd-0.pc)

    at some point. That means the .pc file is in the right place, assuming your PATH variable is set to include /usr/local/lib/. To test run "pkg-config serd-0".

    Good luck!

    ReplyDelete
  3. # ./waf configure
    Setting top to : /home/px/bin/src/drobilla/serd-0.4.0
    Setting out to : /home/px/bin/src/drobilla/serd-0.4.0/build

    Global Configuration
    Checking for 'gcc' (c compiler) : ok
    Checking for 'g++' (c++ compiler) : ok
    * Install prefix : /usr/local
    * Debuggable build : False
    * Strict compiler flags : False
    * Build documentation : False

    Serd Configuration
    * Utilities : True
    * Unit tests : False

    'configure' finished successfully (0.960s)

    # ./waf
    Waf: Entering directory `/home/px/bin/src/drobilla/serd-0.4.0/build'
    Waf: Leaving directory `/home/px/bin/src/drobilla/serd-0.4.0/build'
    'build' finished successfully (0.095s)

    # sudo ./waf install
    [sudo] password for ____:
    Waf: Entering directory `/home/____/bin/src/drobilla/serd-0.4.0/build'
    - install /usr/local/include/serd-0/serd/serd.h (from serd/serd.h)
    - install /usr/local/lib/pkgconfig/serd-0.pc (from build/serd-0.pc)
    - install /usr/local/lib/libserd-0.so.0.4.0 (from build/libserd-0.so)
    - symlink /usr/local/lib/libserd-0.so.0 (to libserd-0.so.0.4.0)
    - install /usr/local/man/man1/serdi.1 (from doc/serdi.1)
    - symlink /usr/local/lib/libserd-0.so (to libserd-0.so.0.4.0)
    - install /usr/local/bin/serdi (from build/serdi)
    Waf: Leaving directory `/home/____/bin/src/drobilla/serd-0.4.0/build'
    Running /sbin/ldconfig
    'install' finished successfully (0.346s)

    # cd build/ ;ls
    c4che/
    libserd-0.so
    libserd-0.so.0.4.0
    serd-0.pc
    serdi
    .wafpickle-98
    config.log
    libserd-0.so.0
    .lock-wafbuild
    serd-config.h
    src/

    # PATH=$PATH:/usr/local/lib
    # pkg-config serd-0
    # :(

    Did you manage to build anything from the juiced trunk too ? Damn, I lost spent most of this day trying to get to that damned DrumSynth..

    ReplyDelete
  4. pX, Hack fix:
    sudo cp serd-0.pc /usr/lib/pkgconfig/

    Then type "pkg-config --libs ser" and hit tab. It should auto-complete the package name to "serd-0", and print its needed libs.

    Let me know! -Harry

    PS: I haven't worked with Juce/d in a long long time... so I can't help there I'm afraid. Perhaps post on juced-devel or so?

    ReplyDelete
  5. Hello,

    I have a problem :


    Build failed
    -> task failed (exit status 1):
    {task 166612652: cxx offlineworker.cpp -> offlineworker.cpp.0.o}
    ['/usr/bin/g++', '-pg', '-g', '-ldl', '-Wall', '-std=gnu++0x', '-Wextra', '-fpermissive', '-pthread', '-I/usr/include/gtkmm-2.4', '-I/usr/lib/i386-linux-gnu/gtkmm-2.4/include', '-I/usr/include/atkmm-1.6', '-I/usr/include/giomm-2.4', '-I/usr/lib/i386-linux-gnu/giomm-2.4/include', '-I/usr/include/pangomm-1.4', '-I/usr/lib/i386-linux-gnu/pangomm-1.4/include', '-I/usr/include/gtk-2.0', '-I/usr/include/gtk-unix-print-2.0', '-I/usr/include/gdkmm-2.4', '-I/usr/lib/i386-linux-gnu/gdkmm-2.4/include', '-I/usr/include/atk-1.0', '-I/usr/include/glibmm-2.4', '-I/usr/lib/i386-linux-gnu/glibmm-2.4/include', '-I/usr/include/glib-2.0', '-I/usr/lib/i386-linux-gnu/glib-2.0/include', '-I/usr/include/sigc++-2.0', '-I/usr/lib/i386-linux-gnu/sigc++-2.0/include', '-I/usr/include/cairomm-1.0', '-I/usr/lib/i386-linux-gnu/cairomm-1.0/include', '-I/usr/include/pango-1.0', '-I/usr/include/cairo', '-I/usr/include/pixman-1', '-I/usr/include/freetype2', '-I/usr/include/libpng12', '-I/usr/lib/i386-linux-gnu/gtk-2.0/include', '-I/usr/include/gdk-pixbuf-2.0', '-I/usr/include/gio-unix-2.0', '-I/usr/include/lilv-0', '-I/usr/include/suil-0', '-DHAVE_JACK=1', '-DHAVE_SNDFILE=1', '-DHAVE_GTKMM=1', '-DHAVE_GLIBMM=1', '-DHAVE_FLUIDSYNTH=1', '-DHAVE_LIBCONFIG=1', '-DHAVE_LILV=1', '-DHAVE_SUIL=1', '-DHAVE_LIBLO=1', '-DHAVE_LV2_H=1', '-DHAVE_LADSPA_H=1', '-DHAVE_LV2_LV2PLUG_IN_NS_EXT_EVENT_EVENT_H=1', '-DHAVE_LV2_LV2PLUG_IN_NS_EXT_URI_MAP_URI_MAP_H=1', '-DHAVE_LV2_LV2PLUG_IN_NS_EXT_EVENT_EVENT_HELPERS_H=1', '../src/offlineworker.cpp', '-c', '-o', 'src/offlineworker.cpp.0.o']

    Regards
    Ant.

    ReplyDelete
    Replies
    1. Hi Ant,

      You're trying to build Luppp right? Not really LV2 stuff that's mentioned in this post?

      There's an issue tracker over on the Luppp github page, that would be the appropriate place to post, but don't worry about it.

      This problem has occurred before, please see this fix:
      https://github.com/harryhaaren/Luppp/issues/25#issuecomment-3811270

      Good luck, -Harry

      Delete