/CPLUG

C wrapper for VST3, AUv2, CLAP audio plugin formats

Primary LanguageCOtherNOASSERTION

CPLUG

"I just want to build a plugin" - Me (and probably you too!)

CPLUG is a simple wrapper API for the VST3, Audio Unit v2 & CLAP plugin formats. There are no extra dependancies outside of the C APIs. It uses a C99 interface, making it easily compatable with other languages. Efforts have been made to use minimal code, making it easy to read and modify. It uses very few files, making it easy to build and include in other projects.

CPLUG only provides the plumbing of wrapping plugin APIs - no extras! It is intended to be compatible with other libraries of your choice (eg. PUGL, NanoVG, Qt).

CPLUG uses a CLAP style single event queue for processing.

All GUI code is pushed to the user to implement how they chose.

All strings are expected to be \0 terminated & UTF8.

Building

TLDR; To quickly get started, try building the example project using CMake

The idea is cplug.h contains forward declarations of functions which you implement in your own source file. Pair these with a single source file corresponding to the plugin format you're building.

The source files are configurable using macros you define. A full list of these macros can be found in the example project. AUv2 and Standalone builds require a few extra macros which are set in CMakeLists.txt. If you're building these targets, you should read the CMake file.

Source file Lines of code Description Extra dependencies
cplug.h < 300 Common API None
cplug_clap.c < 800 CLAP wrapper #include <clap/clap.h>
cplug_auv2.c < 1,400 Audio Unit v2 wrapper None
cplug_standalone_osx.m < 1,400 Standalone None
cplug_standalone_win.c < 1,600 Standalone None
cplug_vst3.c < 2,200 VST3 wrapper #include <vst3_c_api.h>

Copies of the CLAP API and VST3 C API are included in the src folder. They're both single files.

Tested using compilers MinGW GCC 8, VS 17.5, Clang 15 (Windows), Clang 14 (Mac), using C99 & C++11

Note

Some versions of MinGW may not ship with mmeapi.h, which is required for MIDI in Windows standalone builds. Either define the functions and structs yourself, or use a different compiler for this build

Features

Included:

  • Uses sample accurate automation by default
  • Standalone builds include hotreloading, and a native menu for switching between sample rates, block sizes, MIDI devices and audio drivers.

Not included

  • "Distributable". Support for external GUIs and external processing
  • Parameter groups.
  • Bus activation/deactivation
  • MPE

Most plugins don't support these features, & most users don't ask for them or know about them. This library takes a YAGNI approach to uncommon features. Because this library is such a thin wrapper over the plugin APIs, adding any feature you need yourself should be a breeze.

Roadmap

  • AUv2: Support multiple input/output busses
  • AUv2: Support sample accurate processing AUv2
  • Add example using PUGL & NanoVG
  • Add example using Dear ImGUI
  • Add example using Nuklear
  • (Maybe) Support Max 4 Live?
  • (Maybe) Support FL Studio Plugins?
  • (Maybe) Support Linux
  • (I'd rather not) Support AAX

Useful Resources

Licensing

The files src/vst3_c_api.h and src/cplug_vst3.c are required to use the VST 3 SDK License

The file src/clap/clap.h uses an MIT license included at the top of the file.

Everything else is in the public domain, or MIT if you insist. See LICENSE.

Credits

  • Filipe Coelho - Most of the VST3 wrapper and debugging code is a heavily edited version of his code from the DPF repo
  • Nakst - The drawing used in the example plugin was taken from the CLAP tutorial