A crate offering low-level, safe Rust wrappers to create audio plugins using the CLAP audio plugin API.
This library is made of lightweight, low-level wrappers built on top
of clap-sys.
This is part of the Clack project. See the
clack-host crate if you need to make CLAP hosts, and the
clack-extensions crate that contains wrappers for all the standard
CLAP extensions (for both plugins and hosts).
Features
-
Safe: The #1 goal of this project is to provide the full functionality of the CLAP plugin APIs through fully memory-safe and thread-safe wrappers.
This allows for making safer, less crash-prone plugins, but also allows to fully trust Rust's type system when making large refactorings or performance optimizations, especially when dealing with CLAP's powerful, multithreaded model.
-
Low-level: When safe designs permit it, Clack aims to be as close as possible to the underlying CLAP C API. Whenever it is safe to do so, it does not make any assumptions or interpretations about any operation, and simply passes data through to the user.
Anything that's possible to do with the CLAP C API, should also be possible to do using only safe Rust and Clack.
-
Lightweight: Considering the performance sensitivity of audio plugins, Clack aims to add as little overhead as possible to any operation (being a low-level library helps!). It reduces runtime checks and memory allocations to an absolute minimum, heavily leveraging zero-cost abstractions or user-provided buffers for example.
-
Extensible: Following the intent of the underlying CLAP API, Clack allows third-party users and crates to use, add, or extend extensions, event types, factories, and more. As a matter of fact, all extensions in the
clack-extensionscrate are implemented using tools all Clack users have access to, and users may add or replace the provided implementations with their own! -
Reasonably defensive: While Clack performs very little extra sanity checks to keep its overhead as low as possible, it will report any erroneous behavior it stumbles upon to user code if possible, or just log it and fall back to the safest option otherwise (e.g. in case of panics originating from user code).
-
Fairly ergonomic: Despite Clack being a low-level, fast API, it also tries to provide some additional ergonomic APIs when wrapping the C APIs, as long as they don't have any impact on performance or low-level capability. Examples include using Rust's
Option,Result, allowing the use of iterators, implementing standard traits for e.g. I/O,Fromimplementations for buffer types, etc.
clack-plugin example
This example code implements a very simple gain plugin that amplifies every input by 2.0. More involved
examples are available in the examples directory, and in the crate's documentation.
use *;
;
;
clack_export_entry!;
Compiling this code as a "cdylib" library crate will
produce a CLAP-compliant dynamic library file in your project's target folder.
License
This crate is distributed under the terms of both the MIT license and the Apache license, version 2.0. Contributions are accepted under the same terms.