Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Add prelude for commonly used items #161

Merged
merged 5 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions examples/dimension_expander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions examples/fwd_midi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
6 changes: 2 additions & 4 deletions examples/gain_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions examples/ladder_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
5 changes: 1 addition & 4 deletions examples/sine_synth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions examples/transfer_and_smooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 12 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! A collection of commonly used items for implement a Plugin

#[doc(no_inline)]
pub use api::{Events, Supported};
#[doc(no_inline)]
pub use buffer::{AudioBuffer, SendEventBuffer};
#[doc(no_inline)]
pub use event::{Event, MidiEvent};
#[doc(no_inline)]
pub use plugin::{CanDo, Category, HostCallback, Info, Plugin, PluginParameters};
#[doc(no_inline)]
pub use util::{AtomicFloat, ParameterTransfer};