1
0
Fork 0

Generate VST3 entry point functions

This commit is contained in:
Robbert van der Helm 2022-01-26 12:37:45 +01:00
parent a1f0f822ec
commit 6edba6555e
6 changed files with 140 additions and 0 deletions

40
Cargo.lock generated
View file

@ -13,6 +13,9 @@ dependencies = [
[[package]]
name = "nih_plug"
version = "0.1.0"
dependencies = [
"vst3-sys",
]
[[package]]
name = "nih_plug_derive"
@ -56,3 +59,40 @@ name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "vst3-com"
version = "0.1.0"
source = "git+https://github.com/RustAudio/vst3-sys.git#6ab2b43928588cdedcf499eecfc5a022e007dd76"
dependencies = [
"vst3-com-macros",
]
[[package]]
name = "vst3-com-macros"
version = "0.2.0"
source = "git+https://github.com/RustAudio/vst3-sys.git#6ab2b43928588cdedcf499eecfc5a022e007dd76"
dependencies = [
"proc-macro2",
"quote",
"syn",
"vst3-com-macros-support",
]
[[package]]
name = "vst3-com-macros-support"
version = "0.2.0"
source = "git+https://github.com/RustAudio/vst3-sys.git#6ab2b43928588cdedcf499eecfc5a022e007dd76"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "vst3-sys"
version = "0.1.0"
source = "git+https://github.com/RustAudio/vst3-sys.git#6ab2b43928588cdedcf499eecfc5a022e007dd76"
dependencies = [
"vst3-com",
]

View file

@ -6,3 +6,4 @@ authors = ["Robbert van der Helm <mail@robbertvanderhelm.nl>"]
license = "GPL-3.0-or-later"
[dependencies]
vst3-sys = { git = "https://github.com/RustAudio/vst3-sys.git" }

View file

@ -18,3 +18,4 @@ pub mod debug;
pub mod params;
pub mod plugin;
pub mod util;
pub mod wrapper;

20
nih_plug/src/wrapper.rs Normal file
View file

@ -0,0 +1,20 @@
// nih-plug: plugins, but rewritten in Rust
// Copyright (C) 2022 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! 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.
pub mod vst3;

View file

@ -0,0 +1,76 @@
// nih-plug: plugins, but rewritten in Rust
// Copyright (C) 2022 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! 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.
use std::pin::Pin;
use crate::plugin::Plugin;
pub struct Vst3Wrapper<P: Plugin> {
plugin: Pin<Box<P>>,
}
// TODO: Come up with some way to hae Cargo spit out a VST3 module. Is that possible without a
// custom per-plugin build script?
#[macro_export]
macro_rules! nih_export_vst3 {
($plugin_ty:ty) => {
// These two entry points are used on Linux, and they would theoretically also be used on
// the BSDs:
// https://github.com/steinbergmedia/vst3_public_sdk/blob/c3948deb407bdbff89de8fb6ab8500ea4df9d6d9/source/main/linuxmain.cpp#L47-L52
#[no_mangle]
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
pub extern "C" fn ModuleEntry(_lib_handle: *mut std::ffi::c_void) -> bool {
true
}
#[no_mangle]
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
pub extern "C" fn ModuleExit() -> bool {
true
}
// These two entry points are used on macOS:
// https://github.com/steinbergmedia/vst3_public_sdk/blob/bc459feee68803346737901471441fd4829ec3f9/source/main/macmain.cpp#L60-L61
#[no_mangle]
#[cfg(target_os = "macos")]
pub extern "C" fn bundleEntry(_lib_handle: *mut std::ffi::c_void) -> bool {
true
}
#[no_mangle]
#[cfg(target_os = "macos")]
pub extern "C" fn bundleExit() -> bool {
true
}
// And these two entry points are used on Windows:
// https://github.com/steinbergmedia/vst3_public_sdk/blob/bc459feee68803346737901471441fd4829ec3f9/source/main/dllmain.cpp#L59-L60
#[no_mangle]
#[cfg(target_os = "windows")]
pub extern "system" fn InitModule() -> bool {
true
}
#[no_mangle]
#[cfg(target_os = "windows")]
pub extern "system" fn DeinitModule() -> bool {
true
}
};
}

View file

@ -111,3 +111,5 @@ impl Plugin for Gain {
}
}
}
nih_export_vst3!(Gain);