From 96ec1da037fb8a06aa1534ec16c854e68a287604 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 22 Apr 2022 17:17:42 +0200 Subject: [PATCH] Export the standalone target for gain_gui_vizia --- plugins/examples/gain_gui_vizia/Cargo.toml | 5 ++-- plugins/examples/gain_gui_vizia/src/lib.rs | 2 +- plugins/examples/gain_gui_vizia/src/main.rs | 7 ++++++ src/wrapper/standalone.rs | 27 +++++++++++++++++++-- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 plugins/examples/gain_gui_vizia/src/main.rs diff --git a/plugins/examples/gain_gui_vizia/Cargo.toml b/plugins/examples/gain_gui_vizia/Cargo.toml index 8be178e9..08a26a07 100644 --- a/plugins/examples/gain_gui_vizia/Cargo.toml +++ b/plugins/examples/gain_gui_vizia/Cargo.toml @@ -8,10 +8,11 @@ license = "ISC" description = "A simple gain plugin with an vizia GUI" [lib] -crate-type = ["cdylib"] +# The `lib` artifact is needed for the standalone target +crate-type = ["cdylib", "lib"] [dependencies] -nih_plug = { path = "../../../", features = ["assert_process_allocs"] } +nih_plug = { path = "../../../", features = ["assert_process_allocs", "standalone"] } nih_plug_vizia = { path = "../../../nih_plug_vizia" } atomic_float = "0.1" diff --git a/plugins/examples/gain_gui_vizia/src/lib.rs b/plugins/examples/gain_gui_vizia/src/lib.rs index 8c931ad6..c61bf8af 100644 --- a/plugins/examples/gain_gui_vizia/src/lib.rs +++ b/plugins/examples/gain_gui_vizia/src/lib.rs @@ -6,7 +6,7 @@ use std::sync::Arc; mod editor; /// This is mostly identical to the gain example, minus some fluff, and with a GUI. -struct Gain { +pub struct Gain { params: Arc, editor_state: Arc, diff --git a/plugins/examples/gain_gui_vizia/src/main.rs b/plugins/examples/gain_gui_vizia/src/main.rs new file mode 100644 index 00000000..01f9aa97 --- /dev/null +++ b/plugins/examples/gain_gui_vizia/src/main.rs @@ -0,0 +1,7 @@ +use nih_plug::prelude::*; + +use gain_gui_vizia::Gain; + +fn main() { + nih_export_standalone::(); +} diff --git a/src/wrapper/standalone.rs b/src/wrapper/standalone.rs index 2eff5dca..ac880db0 100644 --- a/src/wrapper/standalone.rs +++ b/src/wrapper/standalone.rs @@ -8,8 +8,31 @@ mod wrapper; /// Open an NIH-plug plugin as a standalone application. If the plugin has an editor, this will open /// the editor and block until the editor is closed. Otherwise this will block until SIGINT is -/// received. This is mainly useful for quickly testing plugin GUIs. You should call this function -/// from a `main()` function. +/// received. This is mainly useful for quickly testing plugin GUIs. In order to use this, you will +/// first need to make your plugin's main struct `pub` and expose a `lib` artifact in addition to +/// your plugin's `cdylib`: +/// +/// ```toml +/// # Cargo.toml +/// +/// [lib] +/// # The `lib` artifact is needed for the standalone target +/// crate-type = ["cdylib", "lib"] +/// ``` +/// +/// You can then create a `src/main.rs` file that calls this function: +/// +/// ```ignore +/// // src/main.rs +/// +/// use plugin_name::prelude::*; +/// +/// use plugin_name::PluginName; +/// +/// fn main() { +/// nih_export_standalone::(); +/// } +/// ``` /// /// By default this will connect to the 'default' audio and MIDI ports. Use the command line options /// to change this. `--help` lists all available options.