# Adding Plugins to the CMT Library

The CMT LADSPA plugin collection is written in C++ and uses a little additional sophistication to make plugin writing easier. This document describes how to add a new plugin to the toolkit.

At the moment CMT is not under public version control, so please send changes to Richard Furse.

CMT plugins interpret `LADSPA_Handle` entities as pointers to objects derived from the `CMT_PluginInstance` class. Plugin instance structures are defined by subclassing this, so writing a descendent of `CMT_PluginInstance` is the first thing to do. The CMT library provides its own implementation of `connect_port()`, `cleanup()` and a templated form of `instantiate()` (see `CMT_Instantiate<>()`). These calls assume that any instantiation or cleanup mechanisms required will be written in the constructor or destructor of the class.

When writing a plugin module, an initialisation function should be included. To ensure this is called, add a call to the `initialise_modules()` function in `descriptor.cpp`. The module should also be added to the `makefile`.

Your initialisation function should construct new `CMT_Desctiptor` plugin descriptor structures and pass them to `registerNewPluginDescriptor()`. The `CMT_Descriptor` is directly descended from `LADSPA_Descriptor` but provides constructor, destructor and `addPort()` methods.

All plugins need unique IDs. During development, use values between 1 and 1000. When the plugin is ready, please request an ID from ladspa@muse.demon.co.uk. Please also add a brief description of your module to `plugins.html`.

In practice, CMT plugin writing is probably best learned by example. For a simple case, see the `mixer.cpp` module. This defines a `SimpleMixer` class to handle instance data, a `runSimpleMixer()` function for use with it and a `mixer_descriptor()` function to provide a description of the plugin to the CMT core. The `mixer_descriptor()` function is declared and referenced in the `descriptor.cpp` module. Additional information is available in `cmt.h` and `ladspa.h`.

CMT plugins are licenced under GPL version 2. Please read and understand this license before submitting plugins to the library.