Add a basic nih_export_clap!() macro
This does not do anything useful yet.
This commit is contained in:
parent
d5d90e3e61
commit
56c1545196
6 changed files with 59 additions and 0 deletions
|
@ -417,4 +417,5 @@ impl Vst3Plugin for Diopser {
|
||||||
const VST3_CATEGORIES: &'static str = "Fx|Filter";
|
const VST3_CATEGORIES: &'static str = "Fx|Filter";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nih_export_clap!(Diopser);
|
||||||
nih_export_vst3!(Diopser);
|
nih_export_vst3!(Diopser);
|
||||||
|
|
|
@ -209,4 +209,5 @@ impl Vst3Plugin for Gain {
|
||||||
const VST3_CATEGORIES: &'static str = "Fx|Dynamics";
|
const VST3_CATEGORIES: &'static str = "Fx|Dynamics";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nih_export_clap!(Gain);
|
||||||
nih_export_vst3!(Gain);
|
nih_export_vst3!(Gain);
|
||||||
|
|
|
@ -136,4 +136,5 @@ impl Vst3Plugin for Gain {
|
||||||
const VST3_CATEGORIES: &'static str = "Fx|Dynamics";
|
const VST3_CATEGORIES: &'static str = "Fx|Dynamics";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nih_export_clap!(Gain);
|
||||||
nih_export_vst3!(Gain);
|
nih_export_vst3!(Gain);
|
||||||
|
|
|
@ -183,4 +183,5 @@ impl Vst3Plugin for Sine {
|
||||||
const VST3_CATEGORIES: &'static str = "Instrument|Synth|Tools";
|
const VST3_CATEGORIES: &'static str = "Instrument|Synth|Tools";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nih_export_clap!(Sine);
|
||||||
nih_export_vst3!(Sine);
|
nih_export_vst3!(Sine);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//! Wrappers for different plugin types. Each wrapper has an entry point macro that you can pass the
|
//! Wrappers for different plugin types. Each wrapper has an entry point macro that you can pass the
|
||||||
//! name of a type that implements `Plugin` to. The macro will handle the rest.
|
//! name of a type that implements `Plugin` to. The macro will handle the rest.
|
||||||
|
|
||||||
|
pub mod clap;
|
||||||
pub(crate) mod state;
|
pub(crate) mod state;
|
||||||
pub(crate) mod util;
|
pub(crate) mod util;
|
||||||
pub mod vst3;
|
pub mod vst3;
|
||||||
|
|
54
src/wrapper/clap.rs
Normal file
54
src/wrapper/clap.rs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
use crate::ClapPlugin;
|
||||||
|
|
||||||
|
/// Re-export for the wrapper.
|
||||||
|
pub use ::clap_sys::entry::clap_plugin_entry;
|
||||||
|
pub use ::clap_sys::version::CLAP_VERSION;
|
||||||
|
|
||||||
|
/// Export a CLAP plugin from this library using the provided plugin type.
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! nih_export_clap {
|
||||||
|
($plugin_ty:ty) => {
|
||||||
|
// We need a function pointer to a [wrapper::get_factory()] that creates a factory for
|
||||||
|
// `$plugin_ty`, so we need to generate the function inside of this macro
|
||||||
|
#[doc(hidden)]
|
||||||
|
mod clap {
|
||||||
|
// We don't need any special initialization or deinitialization handling
|
||||||
|
pub fn init(_plugin_path: *const ::std::os::raw::c_char) -> bool {
|
||||||
|
eprintln!("Init!");
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit() {
|
||||||
|
eprintln!("Deinit!");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_factory(
|
||||||
|
factory_id: *const ::std::os::raw::c_char,
|
||||||
|
) -> *const ::std::ffi::c_void {
|
||||||
|
eprintln!("get factory!! {factory_id:#?}");
|
||||||
|
|
||||||
|
std::ptr::null()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
#[used]
|
||||||
|
pub static clap_entry: ::nih_plug::wrapper::clap::clap_plugin_entry =
|
||||||
|
::nih_plug::wrapper::clap::clap_plugin_entry {
|
||||||
|
clap_version: ::nih_plug::wrapper::clap::CLAP_VERSION,
|
||||||
|
// These function pointers are marked as `extern "C"`but there's no reason why the symbols
|
||||||
|
// would need to be exported, so we need these transmutes
|
||||||
|
init: unsafe {
|
||||||
|
::std::mem::transmute(clap::init as fn(*const ::std::os::raw::c_char) -> bool)
|
||||||
|
},
|
||||||
|
deinit: unsafe { ::std::mem::transmute(clap::deinit as fn()) },
|
||||||
|
get_factory: unsafe {
|
||||||
|
::std::mem::transmute(
|
||||||
|
clap::get_factory
|
||||||
|
as fn(*const ::std::os::raw::c_char) -> *const ::std::ffi::c_void,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue