Expand description
This crate contains the low-level API of reaper-rs.
It is not recommended to use this API directly because it just exposes the raw REAPER C++ functions, types and constants one to one in Rust. If you want idiomatic Rust, type safety and convenience, please use the medium-level or high-level API instead.
At times it can still be useful to access the low-level API, mostly as
fallback if the function that you are looking for has not yet been lifted
to the medium-level API. To get started, best navigate to the Reaper
struct, which contains all exposed functions.
§Example
use c_str_macro::c_str;
use std::ptr::null_mut;
unsafe {
reaper.ShowConsoleMsg(c_str!("Hello world from reaper-rs low-level API!").as_ptr());
let track = reaper.GetTrack(null_mut(), 0);
reaper.DeleteTrack(track);
}§Design
§Goal
The ultimate goal of the low-level API is to be on par with the REAPER C++ API, meaning that everything which is possible with the REAPER C++ API is also possible with the reaper-rs low-level API. Improvements regarding safety, convenience or style are not in its scope. It should serve as a base for more idiomatic APIs built on top of it.
§Generated code
Most parts of the low-level API are auto-generated from
reaper_plugin_functions.h using a combination of bindgen and custom build script.
§C++ glue code
There’s some code which is not auto-generated, most notably the code to “restore” functionality which “got lost in translation”. The problem is that some parts of the REAPER C++ API not just use C but also C++ features, in particular virtual base classes. Rust can’t call virtual functions or implement them.
The solution is to take a detour via C++ glue code:
-
Rust calling a C++ virtual function provided by REAPER:
- Implement a method on the raw struct in Rust which calls a function written in C which in turn calls the C++ virtual function (Rust function → C function → C++ virtual function)
- Example:
midi.rs&midi.cpp
-
REAPER calling a C++ virtual function provided by Rust:
- Implement the virtual base class in C++, let each function delegate to a corresponding free Rust function which in turn calls a method of a trait object (REAPER → C++ virtual function → Rust function)
- Example:
control_surface.cpp&control_surface.rs
Modules§
- raw
- Exposes important raw types, functions and constants from the C++ REAPER API.
Macros§
- reaper_
vst_ plugin - Macro which gathers things that go into the static REAPER VST plug-in context.
Structs§
- Extension
Plugin Context - Additional data available in the context of extension plug-ins.
- Plugin
Context - This represents the context which is needed to access REAPER functions from plug-ins.
- Reaper
- This is the low-level API access point to all REAPER functions.
- Reaper
Function Pointers - Container for the REAPER function pointers.
- Static
Extension Plugin Context - Contains those parts of the REAPER extension plug-in context which must be obtained from static variables.
- Static
VstPlugin Context - Contains those parts of the REAPER VST plug-in context which must be obtained in static scope.
- Swell
- This is the low-level API access point to all SWELL functions.
- Swell
Function Pointers - Container for the SWELL function pointers.
- VstPlugin
Context - Additional data available in the context of VST plug-ins.
Enums§
- Context
From Extension Plugin Error - An error which can occur when attempting to create a REAPER plug-in context from an extension plug-in.
- Context
From VstPlugin Error - An error which can occur when attempting to create a REAPER plug-in context from a VST plug-in.
- Type
Specific Plugin Context - Additional stuff available in the plug-in context specific to a certain plug-in type.
Traits§
- IReaper
Control Surface - This is the Rust analog to the C++ virtual base class
IReaperControlSurface. - PCM_
sink - This is the Rust analog to the C++ virtual base class
PCM_sink. - PCM_
source - This is the Rust analog to the C++ virtual base class
PCM_source. - Project
State Context - This is the Rust analog to the C++ virtual base class
ProjectStateContext.
Functions§
- bootstrap_
extension_ ⚠plugin - This is a convenience function for bootstrapping extension plug-ins.
- copy_
heap_ ⚠buf_ to_ buf - Copies the content of the given heap buffer to the given output buffer (which must be sized correctly).
- create_
cpp_ ⚠to_ rust_ control_ surface - Creates an
IReaperControlSurfaceobject on C++ side and returns a pointer to it. - create_
cpp_ ⚠to_ rust_ pcm_ sink - Creates a
PCM_sinkobject on C++ side and returns a pointer to it. - create_
cpp_ ⚠to_ rust_ pcm_ source - Creates a
PCM_sourceobject on C++ side and returns a pointer to it. - create_
cpp_ ⚠to_ rust_ project_ state_ context - Creates a
ProjectStateContextobject on C++ side and returns a pointer to it. - create_
heap_ buf - Creates a heap buffer and passes ownership to the caller.
- delete_
cpp_ ⚠control_ surface - Destroys a C++
IReaperControlSurfaceobject. - delete_
cpp_ ⚠pcm_ sink - Destroys a C++
PCM_sinkobject. - delete_
cpp_ ⚠pcm_ source - Destroys a C++
PCM_sourceobject. - delete_
cpp_ ⚠project_ state_ context - Destroys a C++
ProjectStateContextobject. - delete_
cpp_ ⚠reaper_ pitch_ shift - Destroys a C++
IReaperPitchShiftobject. - delete_
cpp_ ⚠reaper_ resample_ interface - Destroys a C++
REAPER_Resample_Interfaceobject. - execute_
plugin_ ⚠destroy_ hooks - This function executes all registered plug-in destroy hooks.
- firewall
- This function catches panics before they reach REAPER.
- load_
pcm_ ⚠source_ state_ from_ buf - Restores the PCM source state from the given buffer.
- register_
hinstance - Registers the module handle globally.
- register_
plugin_ ⚠destroy_ hook - Registers a function that will be executed when the plug-in module gets unloaded.
- register_
swell_ function_ provider - Registers the given SWELL function provider globally.
- save_
pcm_ ⚠source_ state_ to_ heap_ buf - Saves the state of the given PCM source into the given heap buffer and returns the size of the data written into the buffer.
- static_
extension_ plugin_ context - Exposes the (hopefully) obtained static extension plug-in context.
- static_
vst_ plugin_ context - Exposes the (hopefully) obtained static VST plug-in context.