Christopher Arndt
b37954a27b
Signed-off-by: Christopher Arndt <chris@chrisarndt.de> |
||
---|---|---|
examples | ||
src | ||
tests | ||
.gitignore | ||
LICENSE | ||
README.md | ||
config.nims | ||
nymph.nimble |
README.md
nymph
A Nim library for writing audio and MIDI plugins conforming to the LV2 standard
Examples
Build the amp.lv2
example plugin:
nimble build_ex amp
Check the amp.lv2
plugin bundle with lv2lint
:
nimble lv2lint amp
Run the lv2bm
benchmark with the amp.lv2
plugin:
nimble lv2bm amp
Install the amp.lv2
example plugin:
cp -a examples/amp.lv2 ~/.lv2
Other example plugins can be found in the examples directory and can be built and tested with similar commands. Just change the example name to the basename of the plugin's LV2 bundle dir.
Currently, there are just a few other example plugins:
miditranspose
: shows how to handle receiving and sending MIDI events.multimodefilter
: shows a multimode state-variable filter implementation ported from C++ to Nim.tiltfilter
: shows a multimode tilt equalizer filter implementation ported from Rust to Nim.faustlpf
: shows how to integrate DSP C code generated from a FAUST source file in Nim (in this example the FAUST code implements a simple non-resonant low-pass filter from the FAUST standard library).
How To
Note: I'll use mydsp
as the base name for the new plugin in the
examples below. Substitute your own plugin basename wherever you see it used
below.
-
Install this library:
nimble install https://github.com/SpotlightKid/nymph.git
-
Make a directory named
mydsp.lv2
and copyexamples/amp.lv2/manifest.ttl
into it. Also copyexamples/amp.lv2/amp.ttl
tomydsp.lv2/mydsp.ttl
. -
Copy
examples/amp_plugin.nim
into your project asmydsp_plugin.nim
. -
Edit
mydsp.lv2/manifest.ttl
:- Change the plugin URI.
- Change the plugin's shared library name defined via
lv2:binary
tolibmydsp.so
. - Change file name referenced via
rdfs:seeAlso
tomydsp.ttl
.
-
Edit
mydsp.lv2/mydsp.ttl
:- Change the plugin URI.
- Define audio, control and atom ports as needed.
-
Edit
mydsp_plugin.nim
:- Change the
PluginUri
constant at the top. - Change the
PluginPort
enum and list the ports in the order defined inmydsp.ttl
. - Rename and update the definition of the
AmpPlugin
object type and define its members with the appropriate data types for the plugin ports they will be connected to. Update the type name in theinstantiate
,deactivate
,connectPorts
andrun
procs. - Update and extend the
case
statement inconnectPort
to connect ports to your plugin object instance members. - Implement your DSP code in the
run
proc.
- Change the
-
Compile the plugin shared library object with:
nim c --app:lib --noMain:on --mm:arc \ --out:mydsp.lv2/libmydsp.so mydsp_plugin.nim
See the definition of the
build_ex
task in the nymph.nimble file on how to create a nimble task to simplify compilation and additional compiler args you might want to use.
Dependencies
Required:
- Nim >= 2.0
Optional:
- lv2bm - For benchmarking and stress-testing plugins
- lv2lint - For checking conformity of plugin bundles