Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housekeeping #164

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
588 changes: 321 additions & 267 deletions Cargo.lock

Large diffs are not rendered by default.

96 changes: 55 additions & 41 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,34 @@ repository = "https://github.com/robbert-vdh/nih-plug"
[workspace]
resolver = "2"
members = [
"nih_plug_derive",
"nih_plug_egui",
"nih_plug_iced",
"nih_plug_vizia",
"nih_plug_xtask",

"cargo_nih_plug",
"xtask",

"plugins/examples/gain",
"plugins/examples/gain_gui_egui",
"plugins/examples/gain_gui_iced",
"plugins/examples/gain_gui_vizia",
"plugins/examples/midi_inverter",
"plugins/examples/poly_mod_synth",
"plugins/examples/sine",
"plugins/examples/stft",
"plugins/examples/sysex",

"plugins/soft_vacuum",
"plugins/buffr_glitch",
"plugins/crisp",
"plugins/crossover",
"plugins/diopser",
"plugins/loudness_war_winner",
"plugins/puberty_simulator",
"plugins/safety_limiter",
"plugins/spectral_compressor",
"nih_plug_derive",
"nih_plug_egui",
"nih_plug_iced",
"nih_plug_vizia",
"nih_plug_xtask",

"cargo_nih_plug",
"xtask",

"plugins/examples/gain",
"plugins/examples/gain_gui_egui",
"plugins/examples/gain_gui_iced",
"plugins/examples/gain_gui_vizia",
"plugins/examples/midi_inverter",
"plugins/examples/poly_mod_synth",
"plugins/examples/sine",
"plugins/examples/stft",
"plugins/examples/sysex",

"plugins/soft_vacuum",
"plugins/buffr_glitch",
"plugins/crisp",
"plugins/crossover",
"plugins/diopser",
"plugins/loudness_war_winner",
"plugins/puberty_simulator",
"plugins/safety_limiter",
"plugins/spectral_compressor",
]

[features]
Expand All @@ -54,7 +54,14 @@ assert_process_allocs = ["dep:assert_no_alloc"]
# Enables an export target for standalone binaries through the
# `nih_export_standalone()` function. Disabled by default as this requires
# building additional dependencies for audio and MIDI handling.
standalone = ["dep:baseview", "dep:clap", "dep:cpal", "dep:jack", "dep:midir", "dep:rtrb"]
standalone = [
"dep:baseview",
"dep:clap",
"dep:cpal",
"dep:jack",
"dep:midir",
"dep:rtrb",
]
# Enables the `nih_export_vst3!()` macro. Enabled by default. This feature
# exists mostly for GPL-compliance reasons, since even if you don't use the VST3
# wrapper you might otherwise still include a couple (unused) symbols from the
Expand Down Expand Up @@ -83,9 +90,9 @@ backtrace = "0.3.65"
bitflags = "1.3"
cfg-if = "1.0"
# This supports CLAP 1.1.8
clap-sys = { git = "https://github.com/robbert-vdh/clap-sys.git", branch = "feature/cstr-macro" }
clap-sys = { git = "https://github.com/robbert-vdh/clap-sys.git", branch = "feature/cstr-macro" }
once_cell = "1.19"
crossbeam = "0.8"
lazy_static = "1.4"
log = { version = "0.4", features = ["std", "release_max_level_info"] }
midi-consts = "0.1"
nih_log = "0.3.1"
Expand All @@ -96,14 +103,22 @@ serde_json = "1.0"
widestring = "1.0.0-beta.1"

# Used for the `assert_process_allocs` feature
assert_no_alloc = { git = "https://github.com/robbert-vdh/rust-assert-no-alloc.git", branch = "feature/nested-permit-forbid", features = ["backtrace", "log"], optional = true }
assert_no_alloc = { git = "https://github.com/robbert-vdh/rust-assert-no-alloc.git", branch = "feature/nested-permit-forbid", features = [
"backtrace",
"log",
], optional = true }

# Used for the `standalone` feature
# NOTE: OpenGL support is not needed here, but rust-analyzer gets confused when
# some crates do use it and others don't
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4", features = ["opengl"], optional = true }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "579130ecb4f9f315ae52190af42f0ea46aeaa4a2", features = [
"opengl",
], optional = true }
# All the claps!
clap = { version = "4.1.8", features = ["derive", "wrap_help"], optional = true }
clap = { version = "4.1.8", features = [
"derive",
"wrap_help",
], optional = true }
cpal = { version = "0.15", optional = true }
jack = { version = "0.11.4", optional = true }
midir = { version = "0.9.1", optional = true }
Expand All @@ -112,10 +127,9 @@ rtrb = { version = "0.2.2", optional = true }
# Used for the `vst3` feature
vst3-sys = { git = "https://github.com/robbert-vdh/vst3-sys.git", branch = "fix/drop-box-from-raw", optional = true }

# Used for the `zstd` feature
zstd = { version = "0.12.3", optional = true }

[dev-dependencies]
[dev-dependencies] # Used for the `zstd` feature
murl-digital marked this conversation as resolved.
Show resolved Hide resolved
approx = "0.5.1"

[target.'cfg(all(target_family = "unix", not(target_os = "macos")))'.dependencies]
Expand All @@ -128,11 +142,11 @@ core-foundation = "0.9.3"
[target.'cfg(target_os = "windows")'.dependencies.windows]
version = "0.44"
features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_UI_WindowsAndMessaging",
"Win32_System_LibraryLoader",
"Win32_System_Performance",
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_UI_WindowsAndMessaging",
"Win32_System_LibraryLoader",
"Win32_System_Performance",
]

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion nih_plug_egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ raw-window-handle = "0.5"
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "45465c5f46abed6c6ce370fffde5edc8e4cd5aa3" }
crossbeam = "0.8"
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "68c4d0e8e5c1c702a888a245f4ac50eddfdfcaed", default-features = false }
lazy_static = "1.4"
once_cell = "1.19"
murl-digital marked this conversation as resolved.
Show resolved Hide resolved
parking_lot = "0.12"
# To make the state persistable
serde = { version = "1.0", features = ["derive"] }
11 changes: 5 additions & 6 deletions nih_plug_egui/src/widgets/param_slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use egui_baseview::egui::{
self, emath, vec2, Key, Response, Sense, Stroke, TextEdit, TextStyle, Ui, Vec2, Widget,
WidgetText,
};
use lazy_static::lazy_static;
use nih_plug::prelude::{Param, ParamSetter};
use once_cell::sync::Lazy;
use parking_lot::Mutex;

use super::util;
Expand All @@ -14,11 +14,10 @@ use super::util;
/// noramlized parameter.
const GRANULAR_DRAG_MULTIPLIER: f32 = 0.0015;

lazy_static! {
static ref DRAG_NORMALIZED_START_VALUE_MEMORY_ID: egui::Id = egui::Id::new((file!(), 0));
static ref DRAG_AMOUNT_MEMORY_ID: egui::Id = egui::Id::new((file!(), 1));
static ref VALUE_ENTRY_MEMORY_ID: egui::Id = egui::Id::new((file!(), 2));
}
static DRAG_NORMALIZED_START_VALUE_MEMORY_ID: Lazy<egui::Id> =
Lazy::new(|| egui::Id::new((file!(), 0)));
static DRAG_AMOUNT_MEMORY_ID: Lazy<egui::Id> = Lazy::new(|| egui::Id::new((file!(), 1)));
static VALUE_ENTRY_MEMORY_ID: Lazy<egui::Id> = Lazy::new(|| egui::Id::new((file!(), 2)));

/// A slider widget similar to [`egui::widgets::Slider`] that knows about NIH-plug parameters ranges
/// and can get values for it. The slider supports double click and control click to reset,
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl<'slice, 'sample> Block<'slice, 'sample> {
}

/// Get a SIMD vector containing the channel data for a specific sample in this block. If `LANES
/// > channels.len()` then this will be padded with zeroes. If `LANES < channels.len()` then
/// \> channels.len()` then this will be padded with zeroes. If `LANES < channels.len()` then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a formatter doing something weird here too. May want to look into that!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a clippy warning actually, something about using a special character so I escaped it manually. I'll double back on this

/// this won't contain all values.
///
/// Returns a `None` value if `sample_index` is out of bounds.
Expand Down
11 changes: 5 additions & 6 deletions src/event_loop/background_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use anymap::Entry;
use crossbeam::channel;
use once_cell::sync::Lazy;
use parking_lot::Mutex;
use std::sync::{Arc, Weak};
use std::thread::{self, JoinHandle};
Expand Down Expand Up @@ -71,12 +72,10 @@ where
}

// Rust does not allow us to use the `T` and `E` type variable in statics, so this is a
// workaround to have a singleton that also works if for whatever reason there arem ultiple `T`
// and `E`s in a single process (won't happen with normal plugin usage, but sho knwos).
lazy_static::lazy_static! {
static ref HANDLE_MAP: Mutex<anymap::Map<dyn std::any::Any + Send>> =
Mutex::new(anymap::Map::new());
}
// workaround to have a singleton that also works if for whatever reason there are multiple `T`
// and `E`s in a single process (won't happen with normal plugin usage, but who knows?).
static HANDLE_MAP: Lazy<Mutex<anymap::Map<dyn std::any::Any + Send>>> =
Lazy::new(|| Mutex::new(anymap::Map::new()));

impl<T: Send + 'static, E: MainThreadExecutor<T> + 'static> WorkerThread<T, E> {
fn spawn() -> Self {
Expand Down
6 changes: 3 additions & 3 deletions src/formatters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn v2s_f32_percentage(digits: usize) -> Arc<dyn Fn(f32) -> String + Send + S
pub fn s2v_f32_percentage() -> Arc<dyn Fn(&str) -> Option<f32> + Send + Sync> {
Arc::new(|string| {
string
.trim_end_matches(&[' ', '%'])
.trim_end_matches([' ', '%'])
.parse()
.ok()
.map(|x: f32| x / 100.0)
Expand Down Expand Up @@ -104,7 +104,7 @@ pub fn v2s_f32_gain_to_db(digits: usize) -> Arc<dyn Fn(f32) -> String + Send + S
/// Used in conjunction with [`v2s_f32_gain_to_db()`]. `-inf dB` will be parsed to 0.0.
pub fn s2v_f32_gain_to_db() -> Arc<dyn Fn(&str) -> Option<f32> + Send + Sync> {
Arc::new(|string| {
let string = string.trim_end_matches(&[' ', 'd', 'D', 'b', 'B', 'f', 'F', 's', 'S']);
let string = string.trim_end_matches([' ', 'd', 'D', 'b', 'B', 'f', 'F', 's', 'S']);
// NOTE: The above line strips the `f`, so checked for `-inf` here will always return false
if string.eq_ignore_ascii_case("-in") {
Some(0.0)
Expand All @@ -131,7 +131,7 @@ pub fn s2v_f32_panning() -> Arc<dyn Fn(&str) -> Option<f32> + Send + Sync> {
Arc::new(|string| {
let string = string.trim();
let cleaned_string = string
.trim_end_matches(&[' ', 'l', 'L', 'c', 'C', 'r', 'R'])
.trim_end_matches([' ', 'l', 'L', 'c', 'C', 'r', 'R'])
.parse()
.ok();
match string.chars().last()?.to_uppercase().next()? {
Expand Down
1 change: 0 additions & 1 deletion src/wrapper/clap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub use clap_sys::factory::plugin_factory::{clap_plugin_factory, CLAP_PLUGIN_FAC
pub use clap_sys::host::clap_host;
pub use clap_sys::plugin::{clap_plugin, clap_plugin_descriptor};
pub use clap_sys::version::CLAP_VERSION;
pub use lazy_static::lazy_static;

/// Export one or more CLAP plugins from this library using the provided plugin types.
#[macro_export]
Expand Down
2 changes: 1 addition & 1 deletion src/wrapper/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const AARCH64_FTZ_BIT: u64 = 1 << 24;

#[cfg(all(
debug_assertions,
physical_sizefeature = "assert_process_allocs",
feature = "assert_process_allocs",
murl-digital marked this conversation as resolved.
Show resolved Hide resolved
all(windows, target_env = "gnu")
))]
compile_error!("The 'assert_process_allocs' feature does not work correctly in combination with the 'x86_64-pc-windows-gnu' target, see https://github.com/Windfisch/rust-assert-no-alloc/issues/7");
Expand Down
Loading