During the course of my student's thesis at the LMS, I researched the LV2 Audio Plugin Standard and developed a simple plugin that is capable of physically simulating the vibrations of a guitar string using the Functional Transformation Method. The plugin is playable via MIDI. It is based in part on the VST-plugin "FTM String" by Daniel Maaß, on the VST-plugin "FTM Psycho String" by Alexander Müller and on the LV2-plugin "Simple Sine Generator" by Nedko Arnaudov.
Basics of physical Simulation
Vibrating objects such as guitar strings vibrate in a complex pattern which is determined by a lot of factors like the geometry of the object, the material it is made of, the tension the object is under and so on. By assuming certain simplifications to these conditions and neglecting minor factors, it is possible to formulate a partial differential equation (PDE) which describes the vibration of the object in a simplified, but still adequately detailed fashion. Solving this PDE leads to a mathematical solution of the vibration of the object. However, since these PDEs tend to be very complex, they generally can not be solved analytically and instead, a numerical solution is desired.
The Functional Transformation Method (FTM)
The Functional Transformation Method was developed at the Chair of Multimedia Communications and Signal Processing as a method for physical simulation of real-word vibrant systems like guitar strings or membranes. The oscillation of the string can be described by a partial differential equation (PDE) which contains the numerous physical parameters of the string. By a series of integral transformations (namely the Laplace transform and the Sturm-Liouville transform), the PDE is transformed into a multidimensional transfer function, which can be discretized for example with the impulse invariant transformation (IIT). By applying the inverse Sturm-Liouville transform and the inverse Z-transform the discrete transfer function can be transformed back into the discrete time and space domain. This yields a discrete solution of the partial differential equation which can be implemented easily in common programming languages such as Matlab or C.
The LV2 Audio Plugin Standard
This task is accomplished by separating static data and the actual code of the plugin in different files. The static data, e.g. information about the plugin author, audio and midi ports of the plugin etc. are stored in RDF files, which are simple, easily readable textfiles that are written in the so-called Turtle syntax. The necessary components to set up a LV2 environment are found in the LV2 Core Package, available at this location. The lv2_guitar plugin was developed using version 2.0 of the core package; however at the time of writing this page version 3.0 was the latest core package available. This should not be a problem, however, since revisions of LV2 should be backwards compatible. Mainly, the core package consists of a C header file lv2.h and the RDF Schema for LV2 plugins lv2.ttl.
To run a plugin, a host application is needed. There are numerous host applications available, the plugin lv2_guitar was successfully tested with lv2_jack_host from the Simple C library for LV2 hosts by Dave Robillard and with Elven by Lars Luthman (this host application however is not compatible with LV2 revision 3, according to the author).
Plugins can be written in C or C++ and are compiled as shared object files (dynamic libraries) that can be loaded by the host application. A plugin typically consists of several files (at least the binary and the mandatory RDF file manifest.ttl), which are stored within the same directory. Such a directory is called a bundle.
The lv2_guitar Plugin
The plugin consists of the following files:
The file lv2_guitar.c contains the sourcecode of the plugin, which is compiled into a dynamic library lv2_guitar.so. The RDF-files manifest.ttl and lv2_guitar.ttl contain the static information data for the plugin, which is mainly information about the input- and output-ports of the plugin (it would have been possible to collect all the information in manifest.ttl, but it is considered good practice to collect all plugin-specific information in a separate file). install_lv2.sh and remove_lv2.sh are shell-scripts that are called by the Makefile when make is called with the options install or uninstall.
Since this plugin makes use of the Events extension, which it uses to receive Midi-events, and of the URI Map extension which is used to convert URIs to integers, the header files for these extensions are also included:
If you have successfully compiled other LV2 plugins, building lv2_guitar should be straightforward, just enter
$> make $> make install
and the plugin should compile and install into the plugins folder. It can then be loaded by any LV2 host that supports event ports.
Provided you're using Jack, you should see the plugin appear with two audio output ports (stereo left and right) and one midi input port. Connect the audio ports to your audio hardware and the midi port to your (virtual or real) midi keyboard and you should be able to play a physical simulation of a guitar string, computed using the functional transformation method.
References and Links
- LV2 Homepage
- Tutorial "LV2 programming for the complete idiot"
- Plugins and host-application by Lars Luthman
- David Robillard's homepage; various projects around the LV2 standard
- Calf audio plugin pack; various LV2 plugins
I would like to thank:
- Professor Rabenstein for supervising my thesis
- Alexander Müller for providing me with his student's thesis, which hepled me a lot in understanding the FTM
- The LV2 developers on the IRC-channel #lad, especially Nedko Arnaudov, Lars Luthman, Krzysztof Foltman and David Robillard, who always patiently answered my questions, even the stupid ones