From 5f037d640343e2972a92c9bd3b7fe538babc2a10 Mon Sep 17 00:00:00 2001 From: Nico Chatzi Date: Sat, 13 Mar 2021 09:37:40 +0000 Subject: [PATCH 1/3] Add prelude --- examples/dimension_expander.rs | 5 +---- examples/fwd_midi.rs | 4 +--- examples/gain_effect.rs | 6 ++---- examples/ladder_filter.rs | 4 +--- examples/sine_synth.rs | 5 +---- examples/transfer_and_smooth.rs | 4 +--- src/lib.rs | 4 ++-- src/plugin.rs | 4 ++-- src/prelude.rs | 12 ++++++++++++ 9 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 src/prelude.rs diff --git a/examples/dimension_expander.rs b/examples/dimension_expander.rs index 6aab6706..96d89311 100644 --- a/examples/dimension_expander.rs +++ b/examples/dimension_expander.rs @@ -4,13 +4,10 @@ extern crate vst; extern crate time; -use vst::buffer::AudioBuffer; -use vst::plugin::{Category, HostCallback, Info, Plugin, PluginParameters}; -use vst::util::AtomicFloat; - use std::collections::VecDeque; use std::f64::consts::PI; use std::sync::Arc; +use vst::prelude::*; /// Calculate the length in samples for a delay. Size ranges from 0.0 to 1.0. fn delay(index: usize, mut size: f32) -> isize { diff --git a/examples/fwd_midi.rs b/examples/fwd_midi.rs index 7bb7073d..cb174290 100644 --- a/examples/fwd_midi.rs +++ b/examples/fwd_midi.rs @@ -2,9 +2,7 @@ extern crate vst; use vst::api; -use vst::buffer::{AudioBuffer, SendEventBuffer}; -use vst::event::{Event, MidiEvent}; -use vst::plugin::{CanDo, HostCallback, Info, Plugin}; +use vst::prelude::*; plugin_main!(MyPlugin); // Important! diff --git a/examples/gain_effect.rs b/examples/gain_effect.rs index b07f3489..15837552 100644 --- a/examples/gain_effect.rs +++ b/examples/gain_effect.rs @@ -4,12 +4,10 @@ extern crate vst; extern crate time; -use vst::buffer::AudioBuffer; -use vst::plugin::{Category, HostCallback, Info, Plugin, PluginParameters}; -use vst::util::AtomicFloat; - use std::sync::Arc; +use vst::prelude::*; + /// Simple Gain Effect. /// Note that this does not use a proper scale for sound and shouldn't be used in /// a production amplification effect! This is purely for demonstration purposes, diff --git a/examples/ladder_filter.rs b/examples/ladder_filter.rs index 06b4b8e6..0c6dac81 100644 --- a/examples/ladder_filter.rs +++ b/examples/ladder_filter.rs @@ -16,9 +16,7 @@ use std::f32::consts::PI; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; -use vst::buffer::AudioBuffer; -use vst::plugin::{Category, HostCallback, Info, Plugin, PluginParameters}; -use vst::util::AtomicFloat; +use vst::prelude::*; // this is a 4-pole filter with resonance, which is why there's 4 states and vouts #[derive(Clone)] diff --git a/examples/sine_synth.rs b/examples/sine_synth.rs index e9173762..81a0475a 100644 --- a/examples/sine_synth.rs +++ b/examples/sine_synth.rs @@ -3,10 +3,7 @@ #[macro_use] extern crate vst; -use vst::api::{Events, Supported}; -use vst::buffer::AudioBuffer; -use vst::event::Event; -use vst::plugin::{CanDo, Category, HostCallback, Info, Plugin}; +use vst::prelude::*; use std::f64::consts::PI; diff --git a/examples/transfer_and_smooth.rs b/examples/transfer_and_smooth.rs index 5bdc1106..ba50b121 100644 --- a/examples/transfer_and_smooth.rs +++ b/examples/transfer_and_smooth.rs @@ -10,9 +10,7 @@ extern crate vst; use std::f32; use std::sync::Arc; -use vst::buffer::AudioBuffer; -use vst::plugin::{Category, HostCallback, Info, Plugin, PluginParameters}; -use vst::util::ParameterTransfer; +use vst::prelude::*; const PARAMETER_COUNT: usize = 100; const BASE_FREQUENCY: f32 = 5.0; diff --git a/src/lib.rs b/src/lib.rs index cf37ac44..9903ed18 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ //! //! ## `Plugin` Trait //! All methods in this trait have a default implementation except for the `get_info` method which -//! must be implemented by the plugin. Any of the default implementations may be overriden for +//! must be implemented by the plugin. Any of the default implementations may be overridden for //! custom functionality; the defaults do nothing on their own. //! //! ## `PluginParameters` Trait @@ -152,7 +152,7 @@ pub mod event; pub mod host; mod interfaces; pub mod plugin; - +pub mod prelude; pub mod util; use api::consts::VST_MAGIC; diff --git a/src/plugin.rs b/src/plugin.rs index 1e9b062a..b38947e5 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -67,7 +67,7 @@ pub enum OpCode { /// [index]: parameter /// [ptr]: char buffer, limited to `consts::MAX_PARAM_STR_LEN` (e.g. "db", "ms", etc) GetParameterLabel, - /// [index]: paramter + /// [index]: parameter /// [ptr]: char buffer, limited to `consts::MAX_PARAM_STR_LEN` (e.g. "0.5", "ROOM", etc). GetParameterDisplay, /// [index]: parameter @@ -738,7 +738,7 @@ pub trait PluginParameters: Sync { format!("Param {}", index) } - /// Get the value of paramater at `index`. Should be value between 0.0 and 1.0. + /// Get the value of parameter at `index`. Should be value between 0.0 and 1.0. fn get_parameter(&self, index: i32) -> f32 { 0.0 } diff --git a/src/prelude.rs b/src/prelude.rs new file mode 100644 index 00000000..6febb211 --- /dev/null +++ b/src/prelude.rs @@ -0,0 +1,12 @@ +//! A collection of commonly used items + +#[doc(no_inline)] +pub use crate::api::{Events, Supported}; +#[doc(no_inline)] +pub use crate::buffer::{AudioBuffer, SendEventBuffer}; +#[doc(no_inline)] +pub use crate::event::{Event, MidiEvent}; +#[doc(no_inline)] +pub use crate::plugin::{CanDo, Category, HostCallback, Info, Plugin, PluginParameters}; +#[doc(no_inline)] +pub use crate::util::{AtomicFloat, ParameterTransfer}; From ffc4c43db7962ef57b8ecc0a90f65bcabb5937d0 Mon Sep 17 00:00:00 2001 From: Nico Chatzi Date: Sun, 14 Mar 2021 12:03:12 +0000 Subject: [PATCH 2/3] Remove crate:: in prelude --- src/prelude.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/prelude.rs b/src/prelude.rs index 6febb211..3e76ff88 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,12 +1,12 @@ -//! A collection of commonly used items +//! A collection of commonly used items for implement a Plugin #[doc(no_inline)] -pub use crate::api::{Events, Supported}; +pub use api::{Events, Supported}; #[doc(no_inline)] -pub use crate::buffer::{AudioBuffer, SendEventBuffer}; +pub use buffer::{AudioBuffer, SendEventBuffer}; #[doc(no_inline)] -pub use crate::event::{Event, MidiEvent}; +pub use event::{Event, MidiEvent}; #[doc(no_inline)] -pub use crate::plugin::{CanDo, Category, HostCallback, Info, Plugin, PluginParameters}; +pub use plugin::{CanDo, Category, HostCallback, Info, Plugin, PluginParameters}; #[doc(no_inline)] -pub use crate::util::{AtomicFloat, ParameterTransfer}; +pub use util::{AtomicFloat, ParameterTransfer}; From d89ddd041f01e24daf9521ea6f0a0605a99312a2 Mon Sep 17 00:00:00 2001 From: doomy <2640792-_doomy@users.noreply.gitlab.com> Date: Sat, 26 Feb 2022 10:27:13 -0600 Subject: [PATCH 3/3] fixed fmt issue --- examples/dimension_expander.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dimension_expander.rs b/examples/dimension_expander.rs index 7f926f65..0fbe008a 100644 --- a/examples/dimension_expander.rs +++ b/examples/dimension_expander.rs @@ -6,8 +6,8 @@ extern crate vst; use std::collections::VecDeque; use std::f64::consts::PI; use std::sync::Arc; -use vst::prelude::*; use std::time::{SystemTime, UNIX_EPOCH}; +use vst::prelude::*; /// Calculate the length in samples for a delay. Size ranges from 0.0 to 1.0. fn delay(index: usize, mut size: f32) -> isize {