From 61454eb12e356f5d8e0840f64fd72740dcb7c5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Meki=C4=87?= Date: Sat, 5 Dec 2026 16:17:50 +0100 Subject: [PATCH] Improve Compressor and Transient --- README.md | 4 +- src/common/bus.rs | 8 +- src/common/clap_harness.rs | 94 +- src/common/mod.rs | 2 +- src/common/param_events.rs | 60 +- src/compressor/dsp/mod.rs | 10 +- src/compressor/gui.rs | 222 ++-- src/compressor/params.rs | 2391 +++++++++++++++++++++++++++++++++++- src/compressor/plugin.rs | 486 ++------ src/invert/plugin.rs | 12 +- src/lag/plugin.rs | 12 +- src/reverb/plugin.rs | 12 +- src/transient/dsp.rs | 10 +- src/transient/gui.rs | 16 +- src/transient/params.rs | 1265 ++++++++++++++++++- src/transient/plugin.rs | 125 +- src/volume/plugin.rs | 12 +- 17 files changed, 4071 insertions(+), 670 deletions(-) diff --git a/README.md b/README.md index 11f05a0..0dcd766 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ support for changing channel number, it will be implemented, but only then. - Instruments: Drums, Kick, Random, Sampler, Synth - Effects: Bitcrusher, Chorus, Compressor, DeEsser, Delay, Flanger, Formant, - Gate, Limiter, Modeler, Parametric EQ, Phaser, Reverb, Saturator, Stereo, - Transient, Tuner, Vocoder, Volume, Wah + Gate, Invert, Lag, Limiter, Modeler, Parametric EQ, Phaser, Reverb, Saturator, + Stereo, Transient, Tuner, Vocoder, Volume, Wah [Plugin documentation](https://doc.maolan.rs/plugins.html) diff --git a/src/common/bus.rs b/src/common/bus.rs index 58dfbe5..d006da5 100644 --- a/src/common/bus.rs +++ b/src/common/bus.rs @@ -62,14 +62,14 @@ impl Default for EqBands { #[derive(Clone, Copy)] pub struct CompressorGrData { pub valid_bands: usize, - pub gr_db: [f32; 8], + pub gr_db: [f32; 32], } impl Default for CompressorGrData { fn default() -> Self { Self { valid_bands: 0, - gr_db: [0.0; 8], + gr_db: [0.0; 32], } } } @@ -91,7 +91,7 @@ pub enum PluginType { } pub const BILLBOARD_MAGIC: u32 = 0x4D414F4C; -pub const BILLBOARD_VERSION: u32 = 1; +pub const BILLBOARD_VERSION: u32 = 2; pub const MAX_SLOTS: usize = 64; #[repr(C, align(256))] @@ -127,7 +127,7 @@ pub const BILLBOARD_SIZE: usize = const _: () = assert!(std::mem::size_of::() == 256); const _: () = assert!(std::mem::align_of::() == 256); -const _: () = assert!(std::mem::size_of::() == 5240); +const _: () = assert!(std::mem::size_of::() == 5336); const _: () = assert!(std::mem::align_of::() == 8); use std::sync::OnceLock; diff --git a/src/common/clap_harness.rs b/src/common/clap_harness.rs index ccbda93..f5a88ee 100644 --- a/src/common/clap_harness.rs +++ b/src/common/clap_harness.rs @@ -39,7 +39,7 @@ use portable_atomic::AtomicF64; use crate::common::bus; use crate::common::param_store::ParamStore; use crate::common::{ - ClapParamId, SharedStateExt, apply_param_events, copy_str_to_array, + ClapParamId, PARAM_WORDS, ParamBits, SharedStateExt, apply_param_events, copy_str_to_array, emit_pending_param_events_to_host, }; @@ -199,10 +199,10 @@ impl ParamHost for ParamSharedState

{ pub struct ParamSharedState { pub params: ParamStore

, sample_rate: AtomicF64, - pending_param_notifications: AtomicU64, - pending_gesture_begin: AtomicU64, - pending_gesture_end: AtomicU64, - active_local_gestures: AtomicU64, + pending_param_notifications: [AtomicU64; PARAM_WORDS], + pending_gesture_begin: [AtomicU64; PARAM_WORDS], + pending_gesture_end: [AtomicU64; PARAM_WORDS], + active_local_gestures: [AtomicU64; PARAM_WORDS], host: AtomicPtr, pub poll_notifier: Mutex>, } @@ -212,10 +212,10 @@ impl Default for ParamSharedState

{ Self { params: ParamStore::with_defaults(&P::defaults()), sample_rate: AtomicF64::new(48_000.0), - pending_param_notifications: AtomicU64::new(0), - pending_gesture_begin: AtomicU64::new(0), - pending_gesture_end: AtomicU64::new(0), - active_local_gestures: AtomicU64::new(0), + pending_param_notifications: std::array::from_fn(|_| AtomicU64::new(0)), + pending_gesture_begin: std::array::from_fn(|_| AtomicU64::new(0)), + pending_gesture_end: std::array::from_fn(|_| AtomicU64::new(0)), + active_local_gestures: std::array::from_fn(|_| AtomicU64::new(0)), host: AtomicPtr::new(null_mut()), poll_notifier: Mutex::new(None), } @@ -266,9 +266,8 @@ impl ParamSharedState

{ } fn mark_param_notification_pending(&self, id: P) { - let bit = 1_u64 << (id.as_index() as u32); - self.pending_param_notifications - .fetch_or(bit, Ordering::AcqRel); + let bit = 1_u64 << (id.as_index() % 64); + self.pending_param_notifications[id.as_index() / 64].fetch_or(bit, Ordering::AcqRel); } pub fn set_param_outbound_only(&self, id: P, value: f64) { @@ -276,16 +275,16 @@ impl ParamSharedState

{ } pub fn mark_gesture_begin_pending(&self, id: P) { - let bit = 1_u64 << (id.as_index() as u32); - self.pending_gesture_begin.fetch_or(bit, Ordering::AcqRel); - self.active_local_gestures.fetch_or(bit, Ordering::AcqRel); + let bit = 1_u64 << (id.as_index() % 64); + self.pending_gesture_begin[id.as_index() / 64].fetch_or(bit, Ordering::AcqRel); + self.active_local_gestures[id.as_index() / 64].fetch_or(bit, Ordering::AcqRel); self.mark_dirty(); } pub fn mark_gesture_end_pending(&self, id: P) { - let bit = 1_u64 << (id.as_index() as u32); - self.pending_gesture_end.fetch_or(bit, Ordering::AcqRel); - self.active_local_gestures.fetch_and(!bit, Ordering::AcqRel); + let bit = 1_u64 << (id.as_index() % 64); + self.pending_gesture_end[id.as_index() / 64].fetch_or(bit, Ordering::AcqRel); + self.active_local_gestures[id.as_index() / 64].fetch_and(!bit, Ordering::AcqRel); self.mark_dirty(); } @@ -398,43 +397,48 @@ impl SharedStateExt

for ParamSharedState

{ self.params.get(id) } fn set_gesture_active(&self, id: P, active: bool) { - let bit = 1_u64 << (id.as_index() as u32); + let bit = 1_u64 << (id.as_index() % 64); if active { - self.active_local_gestures.fetch_or(bit, Ordering::AcqRel); + self.active_local_gestures[id.as_index() / 64].fetch_or(bit, Ordering::AcqRel); } else { - self.active_local_gestures.fetch_and(!bit, Ordering::AcqRel); + self.active_local_gestures[id.as_index() / 64].fetch_and(!bit, Ordering::AcqRel); } } fn is_gesture_active(&self, id: P) -> bool { - let bit = 1_u64 << (id.as_index() as u32); - (self.active_local_gestures.load(Ordering::Acquire) & bit) != 0 + let bit = 1_u64 << (id.as_index() % 64); + (self.active_local_gestures[id.as_index() / 64].load(Ordering::Acquire) & bit) != 0 } fn set_param_from_host(&self, id: P, value: f64) { self.set_param_internal(id, value, false); } - fn take_pending_param_notifications(&self) -> u64 { - self.pending_param_notifications.swap(0, Ordering::AcqRel) + fn take_pending_param_notifications(&self) -> ParamBits { + std::array::from_fn(|word| self.pending_param_notifications[word].swap(0, Ordering::AcqRel)) } - fn requeue_pending_param_notifications(&self, bits: u64) { - if bits != 0 { - self.pending_param_notifications - .fetch_or(bits, Ordering::AcqRel); + fn requeue_pending_param_notifications(&self, bits: ParamBits) { + for (word, bits) in bits.into_iter().enumerate() { + if bits != 0 { + self.pending_param_notifications[word].fetch_or(bits, Ordering::AcqRel); + } } } - fn take_pending_gesture_begin(&self) -> u64 { - self.pending_gesture_begin.swap(0, Ordering::AcqRel) + fn take_pending_gesture_begin(&self) -> ParamBits { + std::array::from_fn(|word| self.pending_gesture_begin[word].swap(0, Ordering::AcqRel)) } - fn requeue_pending_gesture_begin(&self, bits: u64) { - if bits != 0 { - self.pending_gesture_begin.fetch_or(bits, Ordering::AcqRel); + fn requeue_pending_gesture_begin(&self, bits: ParamBits) { + for (word, bits) in bits.into_iter().enumerate() { + if bits != 0 { + self.pending_gesture_begin[word].fetch_or(bits, Ordering::AcqRel); + } } } - fn take_pending_gesture_end(&self) -> u64 { - self.pending_gesture_end.swap(0, Ordering::AcqRel) + fn take_pending_gesture_end(&self) -> ParamBits { + std::array::from_fn(|word| self.pending_gesture_end[word].swap(0, Ordering::AcqRel)) } - fn requeue_pending_gesture_end(&self, bits: u64) { - if bits != 0 { - self.pending_gesture_end.fetch_or(bits, Ordering::AcqRel); + fn requeue_pending_gesture_end(&self, bits: ParamBits) { + for (word, bits) in bits.into_iter().enumerate() { + if bits != 0 { + self.pending_gesture_end[word].fetch_or(bits, Ordering::AcqRel); + } } } } @@ -1799,22 +1803,22 @@ macro_rules! delegate_param_shared_ext { fn set_param_from_host(&self, id: $P, value: f64) { self.core.set_param_from_host(id, value); } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> $crate::common::ParamBits { self.core.take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: $crate::common::ParamBits) { self.core.requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> $crate::common::ParamBits { self.core.take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: $crate::common::ParamBits) { self.core.requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> $crate::common::ParamBits { self.core.take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: $crate::common::ParamBits) { self.core.requeue_pending_gesture_end(bits); } } diff --git a/src/common/mod.rs b/src/common/mod.rs index f92dcbe..f3eb899 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -49,6 +49,6 @@ pub mod wavetable; pub mod wavetable_factory; pub use param_events::{ - ClapParamId, SharedStateExt, apply_param_events, copy_str_to_array, + ClapParamId, PARAM_WORDS, ParamBits, SharedStateExt, apply_param_events, copy_str_to_array, emit_pending_param_events_to_host, }; diff --git a/src/common/param_events.rs b/src/common/param_events.rs index d6f31e8..615587e 100644 --- a/src/common/param_events.rs +++ b/src/common/param_events.rs @@ -10,6 +10,9 @@ use maolan_clap::{ }; use std::mem::size_of; +pub const PARAM_WORDS: usize = 16; +pub type ParamBits = [u64; PARAM_WORDS]; + pub trait ClapParamId: Copy + Clone + PartialEq + Eq + Send + Sync + 'static { const COUNT: usize; fn as_index(self) -> usize; @@ -21,12 +24,12 @@ pub trait SharedStateExt { fn set_gesture_active(&self, id: P, active: bool); fn is_gesture_active(&self, id: P) -> bool; fn set_param_from_host(&self, id: P, value: f64); - fn take_pending_param_notifications(&self) -> u64; - fn requeue_pending_param_notifications(&self, bits: u64); - fn take_pending_gesture_begin(&self) -> u64; - fn requeue_pending_gesture_begin(&self, bits: u64); - fn take_pending_gesture_end(&self) -> u64; - fn requeue_pending_gesture_end(&self, bits: u64); + fn take_pending_param_notifications(&self) -> ParamBits; + fn requeue_pending_param_notifications(&self, bits: ParamBits); + fn take_pending_gesture_begin(&self) -> ParamBits; + fn requeue_pending_gesture_begin(&self, bits: ParamBits); + fn take_pending_gesture_end(&self) -> ParamBits; + fn requeue_pending_gesture_end(&self, bits: ParamBits); } impl> SharedStateExt

for std::sync::Arc { @@ -42,22 +45,22 @@ impl> SharedStateExt

for std::sync::Arc< fn set_param_from_host(&self, id: P, value: f64) { (**self).set_param_from_host(id, value); } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> ParamBits { (**self).take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: ParamBits) { (**self).requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> ParamBits { (**self).take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: ParamBits) { (**self).requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> ParamBits { (**self).take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: ParamBits) { (**self).requeue_pending_gesture_end(bits); } } @@ -123,34 +126,39 @@ pub fn emit_pending_param_events_to_host>( let pending_values = shared.take_pending_param_notifications(); let pending_end = shared.take_pending_gesture_end(); - if pending_begin == 0 && pending_values == 0 && pending_end == 0 { + if pending_begin.iter().all(|bits| *bits == 0) + && pending_values.iter().all(|bits| *bits == 0) + && pending_end.iter().all(|bits| *bits == 0) + { return; } - let mut failed_begin = 0_u64; - let mut failed_values = 0_u64; - let mut failed_end = 0_u64; + let mut failed_begin = [0_u64; PARAM_WORDS]; + let mut failed_values = [0_u64; PARAM_WORDS]; + let mut failed_end = [0_u64; PARAM_WORDS]; for id in (0..P::COUNT).filter_map(|i| P::from_raw(i as u32)) { - let bit = 1_u64 << (id.as_index() as u32); - if pending_begin & bit != 0 { - let begin = ParamGesture::begin(ClapId::from(id.as_index() as u16)); + let index = id.as_index(); + let word = index / 64; + let bit = 1_u64 << (index % 64); + if pending_begin[word] & bit != 0 { + let begin = ParamGesture::begin(ClapId::from(index as u16)); if out_events.try_push(begin).is_err() { - failed_begin |= bit; + failed_begin[word] |= bit; } } - if pending_values & bit != 0 { + if pending_values[word] & bit != 0 { let event_builder = ParamValue::build() - .param_id(ClapId::from(id.as_index() as u16)) + .param_id(ClapId::from(index as u16)) .value(shared.params_get(id)); let event = event_builder.event(); if out_events.try_push(event).is_err() { - failed_values |= bit; + failed_values[word] |= bit; } } - if pending_end & bit != 0 { - let end = ParamGesture::end(ClapId::from(id.as_index() as u16)); + if pending_end[word] & bit != 0 { + let end = ParamGesture::end(ClapId::from(index as u16)); if out_events.try_push(end).is_err() { - failed_end |= bit; + failed_end[word] |= bit; } } } diff --git a/src/compressor/dsp/mod.rs b/src/compressor/dsp/mod.rs index f7bbac9..50c5d66 100644 --- a/src/compressor/dsp/mod.rs +++ b/src/compressor/dsp/mod.rs @@ -1,4 +1,4 @@ -pub const MAX_BANDS: usize = 6; +pub const MAX_BANDS: usize = 32; const MAX_SPLITS: usize = MAX_BANDS - 1; #[derive(Debug, Clone, Copy)] @@ -455,7 +455,13 @@ impl Default for Compressor { wet_gain: 1.0, bypass: false, band_count: 1, - split_hz: [120.0, 1000.0, 6000.0, 10_000.0, 14_000.0], + split_hz: std::array::from_fn(|split| { + const DEFAULTS: [f32; 5] = [120.0, 1000.0, 6000.0, 10_000.0, 14_000.0]; + DEFAULTS.get(split).copied().unwrap_or_else(|| { + let fraction = (split - 4) as f32 / 26.0; + 14_000.0 * (20_000.0_f32 / 14_000.0).powf(fraction) + }) + }), bands: [BandCompressor::default(); MAX_BANDS], detector_split: StereoSplitBank::default(), audio_split: StereoSplitBank::default(), diff --git a/src/compressor/gui.rs b/src/compressor/gui.rs index fd5b190..cd5efd0 100644 --- a/src/compressor/gui.rs +++ b/src/compressor/gui.rs @@ -40,6 +40,7 @@ use raw_window_handle::RawWindowHandle; use raw_window_handle::{HandleError, HasWindowHandle, WindowHandle}; use crate::compressor::{ + dsp::MAX_BANDS, params::{PARAMS, ParamId}, plugin::SharedState, }; @@ -48,7 +49,6 @@ use maolan_widgets::multi_toggler::horizontal_multi_toggler; pub const EDITOR_WIDTH: u32 = 1024; pub const EDITOR_HEIGHT: u32 = 720; -const MAX_COMPRESSOR_BANDS: usize = 6; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ChannelMode { @@ -404,7 +404,7 @@ fn update(state: &mut State, message: Message) -> Task { } Message::CreateBand(freq) => { let band_count = active_band_count(&state.shared); - if band_count < MAX_COMPRESSOR_BANDS { + if band_count < MAX_BANDS { let mut splits = active_splits(&state.shared); splits.push(freq.clamp(20.0, 20_000.0)); splits.sort_by(|a, b| a.total_cmp(b)); @@ -430,7 +430,7 @@ fn update(state: &mut State, message: Message) -> Task { .position(|split| (*split - freq).abs() < 1.0) .map(|index| index + 1) .unwrap_or(band_count) - .min(MAX_COMPRESSOR_BANDS - 1), + .min(MAX_BANDS - 1), ); } } @@ -737,54 +737,27 @@ fn active_band_count(shared: &SharedState) -> usize { .params .get(ParamId::BandCount) .round() - .clamp(1.0, MAX_COMPRESSOR_BANDS as f64) as usize + .clamp(1.0, MAX_BANDS as f64) as usize } -fn split_param_ids() -> [ParamId; MAX_COMPRESSOR_BANDS - 1] { - [ - ParamId::Split1, - ParamId::Split2, - ParamId::Split3, - ParamId::Split4, - ParamId::Split5, - ] +fn split_param_ids() -> [ParamId; MAX_BANDS - 1] { + std::array::from_fn(ParamId::split) } -fn threshold_param_ids() -> [ParamId; MAX_COMPRESSOR_BANDS] { - [ - ParamId::B1Threshold, - ParamId::B2Threshold, - ParamId::B3Threshold, - ParamId::B4Threshold, - ParamId::B5Threshold, - ParamId::B6Threshold, - ] +fn threshold_param_ids() -> [ParamId; MAX_BANDS] { + std::array::from_fn(ParamId::band_threshold) } -fn range_param_ids() -> [ParamId; MAX_COMPRESSOR_BANDS] { - [ - ParamId::B1Range, - ParamId::B2Range, - ParamId::B3Range, - ParamId::B4Range, - ParamId::B5Range, - ParamId::B6Range, - ] +fn range_param_ids() -> [ParamId; MAX_BANDS] { + std::array::from_fn(ParamId::band_range) } -fn makeup_param_ids() -> [ParamId; MAX_COMPRESSOR_BANDS] { - [ - ParamId::B1Makeup, - ParamId::B2Makeup, - ParamId::B3Makeup, - ParamId::B4Makeup, - ParamId::B5Makeup, - ParamId::B6Makeup, - ] +fn makeup_param_ids() -> [ParamId; MAX_BANDS] { + std::array::from_fn(ParamId::band_makeup) } fn split_param_for_index(index: usize) -> ParamId { - split_param_ids()[index.min(MAX_COMPRESSOR_BANDS - 2)] + split_param_ids()[index.min(MAX_BANDS - 2)] } fn active_splits(shared: &SharedState) -> Vec { @@ -797,75 +770,28 @@ fn active_splits(shared: &SharedState) -> Vec { splits } -fn band_ids() -> [BandIds; MAX_COMPRESSOR_BANDS] { - [ - BandIds { - th: ParamId::B1Threshold, - range: ParamId::B1Range, - ratio: ParamId::B1Ratio, - att: ParamId::B1Attack, - rel: ParamId::B1Release, - knee: ParamId::B1Knee, - makeup: ParamId::B1Makeup, - }, - BandIds { - th: ParamId::B2Threshold, - range: ParamId::B2Range, - ratio: ParamId::B2Ratio, - att: ParamId::B2Attack, - rel: ParamId::B2Release, - knee: ParamId::B2Knee, - makeup: ParamId::B2Makeup, - }, - BandIds { - th: ParamId::B3Threshold, - range: ParamId::B3Range, - ratio: ParamId::B3Ratio, - att: ParamId::B3Attack, - rel: ParamId::B3Release, - knee: ParamId::B3Knee, - makeup: ParamId::B3Makeup, - }, - BandIds { - th: ParamId::B4Threshold, - range: ParamId::B4Range, - ratio: ParamId::B4Ratio, - att: ParamId::B4Attack, - rel: ParamId::B4Release, - knee: ParamId::B4Knee, - makeup: ParamId::B4Makeup, - }, - BandIds { - th: ParamId::B5Threshold, - range: ParamId::B5Range, - ratio: ParamId::B5Ratio, - att: ParamId::B5Attack, - rel: ParamId::B5Release, - knee: ParamId::B5Knee, - makeup: ParamId::B5Makeup, - }, - BandIds { - th: ParamId::B6Threshold, - range: ParamId::B6Range, - ratio: ParamId::B6Ratio, - att: ParamId::B6Attack, - rel: ParamId::B6Release, - knee: ParamId::B6Knee, - makeup: ParamId::B6Makeup, - }, - ] +fn band_ids() -> [BandIds; MAX_BANDS] { + std::array::from_fn(|band| BandIds { + th: ParamId::band_threshold(band), + range: ParamId::band_range(band), + ratio: ParamId::band_ratio(band), + att: ParamId::band_attack(band), + rel: ParamId::band_release(band), + knee: ParamId::band_knee(band), + makeup: ParamId::band_makeup(band), + }) } fn threshold_param_for_band(band: usize) -> ParamId { - threshold_param_ids()[band.min(MAX_COMPRESSOR_BANDS - 1)] + threshold_param_ids()[band.min(MAX_BANDS - 1)] } fn range_param_for_band(band: usize) -> ParamId { - range_param_ids()[band.min(MAX_COMPRESSOR_BANDS - 1)] + range_param_ids()[band.min(MAX_BANDS - 1)] } fn makeup_param_for_band(band: usize) -> ParamId { - makeup_param_ids()[band.min(MAX_COMPRESSOR_BANDS - 1)] + makeup_param_ids()[band.min(MAX_BANDS - 1)] } struct ThresholdCurveParams { @@ -874,10 +800,10 @@ struct ThresholdCurveParams { input_gain_db: f32, sc_boost: u32, sample_rate: f32, - thresholds: [f32; MAX_COMPRESSOR_BANDS], - ranges: [f32; MAX_COMPRESSOR_BANDS], - gains: [f32; MAX_COMPRESSOR_BANDS], - gain_reduction_db: [f32; MAX_COMPRESSOR_BANDS], + thresholds: [f32; MAX_BANDS], + ranges: [f32; MAX_BANDS], + gains: [f32; MAX_BANDS], + gain_reduction_db: [f32; MAX_BANDS], selected_band: Option, } @@ -886,14 +812,14 @@ fn threshold_curves(params: ThresholdCurveParams) -> Vec f32 { let mut weighted_sum = 0.0; let mut total_weight = 0.0; @@ -1416,7 +1342,7 @@ pub fn parent_from_window( mod tests { use super::*; - fn curve_for_thresholds(thresholds: [f32; MAX_COMPRESSOR_BANDS]) -> Vec<(f32, f32)> { + fn curve_for_thresholds(thresholds: [f32; MAX_BANDS]) -> Vec<(f32, f32)> { let curves = threshold_curves(ThresholdCurveParams { splits: vec![200.0, 2000.0, 8000.0], band_count: 4, @@ -1424,9 +1350,9 @@ mod tests { sc_boost: 0, sample_rate: 48_000.0, thresholds, - ranges: [-6.0; MAX_COMPRESSOR_BANDS], - gains: [0.0; MAX_COMPRESSOR_BANDS], - gain_reduction_db: [0.0; MAX_COMPRESSOR_BANDS], + ranges: [-6.0; MAX_BANDS], + gains: [0.0; MAX_BANDS], + gain_reduction_db: [0.0; MAX_BANDS], selected_band: Some(0), }); assert_eq!(curves.len(), 3); @@ -1434,8 +1360,8 @@ mod tests { } fn range_curve_for_values( - thresholds: [f32; MAX_COMPRESSOR_BANDS], - ranges: [f32; MAX_COMPRESSOR_BANDS], + thresholds: [f32; MAX_BANDS], + ranges: [f32; MAX_BANDS], ) -> Vec<(f32, f32)> { let curves = threshold_curves(ThresholdCurveParams { splits: vec![200.0, 2000.0, 8000.0], @@ -1445,25 +1371,25 @@ mod tests { sample_rate: 48_000.0, thresholds, ranges, - gains: [0.0; MAX_COMPRESSOR_BANDS], - gain_reduction_db: [0.0; MAX_COMPRESSOR_BANDS], + gains: [0.0; MAX_BANDS], + gain_reduction_db: [0.0; MAX_BANDS], selected_band: Some(0), }); assert_eq!(curves.len(), 3); curves[1].points.clone() } - fn gain_curve_for_values(gains: [f32; MAX_COMPRESSOR_BANDS]) -> Vec<(f32, f32)> { + fn gain_curve_for_values(gains: [f32; MAX_BANDS]) -> Vec<(f32, f32)> { let curves = threshold_curves(ThresholdCurveParams { splits: vec![200.0, 2000.0, 8000.0], band_count: 4, input_gain_db: 0.0, sc_boost: 0, sample_rate: 48_000.0, - thresholds: [-10.0; MAX_COMPRESSOR_BANDS], - ranges: [-6.0; MAX_COMPRESSOR_BANDS], + thresholds: [-10.0; MAX_BANDS], + ranges: [-6.0; MAX_BANDS], gains, - gain_reduction_db: [0.0; MAX_COMPRESSOR_BANDS], + gain_reduction_db: [0.0; MAX_BANDS], selected_band: Some(0), }); assert_eq!(curves.len(), 3); @@ -1472,7 +1398,7 @@ mod tests { #[test] fn equal_thresholds_draw_flat_contour() { - let points = curve_for_thresholds([-10.5; MAX_COMPRESSOR_BANDS]); + let points = curve_for_thresholds([-10.5; MAX_BANDS]); for &(_, db) in &points { assert!( (db + 10.5).abs() < 1.0e-4, @@ -1563,10 +1489,10 @@ mod tests { input_gain_db: 0.0, sc_boost: 0, sample_rate: 48_000.0, - thresholds: [-10.0; MAX_COMPRESSOR_BANDS], - ranges: [-6.0; MAX_COMPRESSOR_BANDS], - gains: [0.0; MAX_COMPRESSOR_BANDS], - gain_reduction_db: [0.0; MAX_COMPRESSOR_BANDS], + thresholds: [-10.0; MAX_BANDS], + ranges: [-6.0; MAX_BANDS], + gains: [0.0; MAX_BANDS], + gain_reduction_db: [0.0; MAX_BANDS], selected_band: Some(0), }); @@ -1592,10 +1518,10 @@ mod tests { input_gain_db: 0.0, sc_boost: 0, sample_rate: 48_000.0, - thresholds: [-10.0; MAX_COMPRESSOR_BANDS], - ranges: [-6.0; MAX_COMPRESSOR_BANDS], - gains: [0.0; MAX_COMPRESSOR_BANDS], - gain_reduction_db: [3.0; MAX_COMPRESSOR_BANDS], + thresholds: [-10.0; MAX_BANDS], + ranges: [-6.0; MAX_BANDS], + gains: [0.0; MAX_BANDS], + gain_reduction_db: [3.0; MAX_BANDS], selected_band: Some(0), }); @@ -1615,10 +1541,10 @@ mod tests { input_gain_db: 0.0, sc_boost: 0, sample_rate: 48_000.0, - thresholds: [-10.0; MAX_COMPRESSOR_BANDS], - ranges: [6.0; MAX_COMPRESSOR_BANDS], - gains: [0.0; MAX_COMPRESSOR_BANDS], - gain_reduction_db: [-4.0; MAX_COMPRESSOR_BANDS], + thresholds: [-10.0; MAX_BANDS], + ranges: [6.0; MAX_BANDS], + gains: [0.0; MAX_BANDS], + gain_reduction_db: [-4.0; MAX_BANDS], selected_band: Some(0), }); @@ -1638,10 +1564,10 @@ mod tests { input_gain_db: 0.0, sc_boost: 0, sample_rate: 48_000.0, - thresholds: [-10.0; MAX_COMPRESSOR_BANDS], - ranges: [-6.0; MAX_COMPRESSOR_BANDS], - gains: [0.0; MAX_COMPRESSOR_BANDS], - gain_reduction_db: [24.0; MAX_COMPRESSOR_BANDS], + thresholds: [-10.0; MAX_BANDS], + ranges: [-6.0; MAX_BANDS], + gains: [0.0; MAX_BANDS], + gain_reduction_db: [24.0; MAX_BANDS], selected_band: Some(0), }); @@ -1655,8 +1581,7 @@ mod tests { #[test] fn range_contour_draws_gain_plus_range() { - let points = - range_curve_for_values([-10.0; MAX_COMPRESSOR_BANDS], [-6.0; MAX_COMPRESSOR_BANDS]); + let points = range_curve_for_values([-10.0; MAX_BANDS], [-6.0; MAX_BANDS]); for &(_, db) in &points { assert!( (db + 6.0).abs() < 1.0e-4, @@ -1664,8 +1589,7 @@ mod tests { ); } - let points = - range_curve_for_values([-10.0; MAX_COMPRESSOR_BANDS], [4.0; MAX_COMPRESSOR_BANDS]); + let points = range_curve_for_values([-10.0; MAX_BANDS], [4.0; MAX_BANDS]); for &(_, db) in &points { assert!( (db - 4.0).abs() < 1.0e-4, @@ -1676,7 +1600,7 @@ mod tests { #[test] fn gain_contour_draws_makeup_gain() { - let points = gain_curve_for_values([3.0; MAX_COMPRESSOR_BANDS]); + let points = gain_curve_for_values([3.0; MAX_BANDS]); for &(_, db) in &points { assert!( (db - 3.0).abs() < 1.0e-4, @@ -1684,7 +1608,7 @@ mod tests { ); } - let points = gain_curve_for_values([-5.5; MAX_COMPRESSOR_BANDS]); + let points = gain_curve_for_values([-5.5; MAX_BANDS]); for &(_, db) in &points { assert!( (db + 5.5).abs() < 1.0e-4, @@ -1695,7 +1619,15 @@ mod tests { #[test] fn different_thresholds_ease_across_split() { - let points = curve_for_thresholds([-20.0, -8.0, -8.0, -8.0, 0.0, 0.0]); + let points = curve_for_thresholds(std::array::from_fn(|band| { + if band == 0 { + -20.0 + } else if band < 4 { + -8.0 + } else { + 0.0 + } + })); let low = points .iter() .find(|(freq, _)| *freq > 90.0) diff --git a/src/compressor/params.rs b/src/compressor/params.rs index 83cc1bc..2d3f516 100644 --- a/src/compressor/params.rs +++ b/src/compressor/params.rs @@ -65,6 +65,214 @@ crate::define_params! { B6Makeup = 57, B6Range = 58, ExternalSidechain = 59, + Split6 = 60, + Split7 = 61, + Split8 = 62, + Split9 = 63, + Split10 = 64, + Split11 = 65, + Split12 = 66, + Split13 = 67, + Split14 = 68, + Split15 = 69, + Split16 = 70, + Split17 = 71, + Split18 = 72, + Split19 = 73, + Split20 = 74, + Split21 = 75, + Split22 = 76, + Split23 = 77, + Split24 = 78, + Split25 = 79, + Split26 = 80, + Split27 = 81, + Split28 = 82, + Split29 = 83, + Split30 = 84, + Split31 = 85, + B7Threshold = 86, + B7Ratio = 87, + B7Attack = 88, + B7Release = 89, + B7Knee = 90, + B7Makeup = 91, + B7Range = 92, + B8Threshold = 93, + B8Ratio = 94, + B8Attack = 95, + B8Release = 96, + B8Knee = 97, + B8Makeup = 98, + B8Range = 99, + B9Threshold = 100, + B9Ratio = 101, + B9Attack = 102, + B9Release = 103, + B9Knee = 104, + B9Makeup = 105, + B9Range = 106, + B10Threshold = 107, + B10Ratio = 108, + B10Attack = 109, + B10Release = 110, + B10Knee = 111, + B10Makeup = 112, + B10Range = 113, + B11Threshold = 114, + B11Ratio = 115, + B11Attack = 116, + B11Release = 117, + B11Knee = 118, + B11Makeup = 119, + B11Range = 120, + B12Threshold = 121, + B12Ratio = 122, + B12Attack = 123, + B12Release = 124, + B12Knee = 125, + B12Makeup = 126, + B12Range = 127, + B13Threshold = 128, + B13Ratio = 129, + B13Attack = 130, + B13Release = 131, + B13Knee = 132, + B13Makeup = 133, + B13Range = 134, + B14Threshold = 135, + B14Ratio = 136, + B14Attack = 137, + B14Release = 138, + B14Knee = 139, + B14Makeup = 140, + B14Range = 141, + B15Threshold = 142, + B15Ratio = 143, + B15Attack = 144, + B15Release = 145, + B15Knee = 146, + B15Makeup = 147, + B15Range = 148, + B16Threshold = 149, + B16Ratio = 150, + B16Attack = 151, + B16Release = 152, + B16Knee = 153, + B16Makeup = 154, + B16Range = 155, + B17Threshold = 156, + B17Ratio = 157, + B17Attack = 158, + B17Release = 159, + B17Knee = 160, + B17Makeup = 161, + B17Range = 162, + B18Threshold = 163, + B18Ratio = 164, + B18Attack = 165, + B18Release = 166, + B18Knee = 167, + B18Makeup = 168, + B18Range = 169, + B19Threshold = 170, + B19Ratio = 171, + B19Attack = 172, + B19Release = 173, + B19Knee = 174, + B19Makeup = 175, + B19Range = 176, + B20Threshold = 177, + B20Ratio = 178, + B20Attack = 179, + B20Release = 180, + B20Knee = 181, + B20Makeup = 182, + B20Range = 183, + B21Threshold = 184, + B21Ratio = 185, + B21Attack = 186, + B21Release = 187, + B21Knee = 188, + B21Makeup = 189, + B21Range = 190, + B22Threshold = 191, + B22Ratio = 192, + B22Attack = 193, + B22Release = 194, + B22Knee = 195, + B22Makeup = 196, + B22Range = 197, + B23Threshold = 198, + B23Ratio = 199, + B23Attack = 200, + B23Release = 201, + B23Knee = 202, + B23Makeup = 203, + B23Range = 204, + B24Threshold = 205, + B24Ratio = 206, + B24Attack = 207, + B24Release = 208, + B24Knee = 209, + B24Makeup = 210, + B24Range = 211, + B25Threshold = 212, + B25Ratio = 213, + B25Attack = 214, + B25Release = 215, + B25Knee = 216, + B25Makeup = 217, + B25Range = 218, + B26Threshold = 219, + B26Ratio = 220, + B26Attack = 221, + B26Release = 222, + B26Knee = 223, + B26Makeup = 224, + B26Range = 225, + B27Threshold = 226, + B27Ratio = 227, + B27Attack = 228, + B27Release = 229, + B27Knee = 230, + B27Makeup = 231, + B27Range = 232, + B28Threshold = 233, + B28Ratio = 234, + B28Attack = 235, + B28Release = 236, + B28Knee = 237, + B28Makeup = 238, + B28Range = 239, + B29Threshold = 240, + B29Ratio = 241, + B29Attack = 242, + B29Release = 243, + B29Knee = 244, + B29Makeup = 245, + B29Range = 246, + B30Threshold = 247, + B30Ratio = 248, + B30Attack = 249, + B30Release = 250, + B30Knee = 251, + B30Makeup = 252, + B30Range = 253, + B31Threshold = 254, + B31Ratio = 255, + B31Attack = 256, + B31Release = 257, + B31Knee = 258, + B31Makeup = 259, + B31Range = 260, + B32Threshold = 261, + B32Ratio = 262, + B32Attack = 263, + B32Release = 264, + B32Knee = 265, + B32Makeup = 266, + B32Range = 267, } pub const PARAMS: [ParamDef] = [ { @@ -512,7 +720,7 @@ crate::define_params! { name: "Band Count", module: "Crossover", min: 1.0, - max: 6.0, + max: 32.0, default: 1.0, step: 1.0, flags: AUTOMATABLE | CLAP_PARAM_IS_STEPPED, @@ -667,9 +875,2190 @@ crate::define_params! { step: 1.0, flags: BOOL_FLAGS, } + { + id: ParamId::Split6, + name: "Split 6", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 14193.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split7, + name: "Split 7", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 14389.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split8, + name: "Split 8", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 14588.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split9, + name: "Split 9", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 14790.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split10, + name: "Split 10", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 14994.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split11, + name: "Split 11", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 15201.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split12, + name: "Split 12", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 15411.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split13, + name: "Split 13", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 15624.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split14, + name: "Split 14", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 15840.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split15, + name: "Split 15", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 16059.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split16, + name: "Split 16", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 16280.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split17, + name: "Split 17", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 16505.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split18, + name: "Split 18", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 16733.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split19, + name: "Split 19", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 16964.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split20, + name: "Split 20", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 17199.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split21, + name: "Split 21", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 17436.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split22, + name: "Split 22", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 17677.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split23, + name: "Split 23", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 17921.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split24, + name: "Split 24", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 18169.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split25, + name: "Split 25", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 18420.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split26, + name: "Split 26", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 18674.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split27, + name: "Split 27", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 18932.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split28, + name: "Split 28", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 19194.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split29, + name: "Split 29", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 19459.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split30, + name: "Split 30", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 19728.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split31, + name: "Split 31", + module: "Crossover", + min: 20.0, + max: 20_000.0, + default: 20000.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::B7Threshold, + name: "Band 7 Threshold", + module: "Band 7", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B7Ratio, + name: "Band 7 Ratio", + module: "Band 7", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B7Attack, + name: "Band 7 Attack", + module: "Band 7", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B7Release, + name: "Band 7 Release", + module: "Band 7", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B7Knee, + name: "Band 7 Knee", + module: "Band 7", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B7Makeup, + name: "Band 7 Makeup", + module: "Band 7", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B7Range, + name: "Band 7 Range", + module: "Band 7", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B8Threshold, + name: "Band 8 Threshold", + module: "Band 8", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B8Ratio, + name: "Band 8 Ratio", + module: "Band 8", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B8Attack, + name: "Band 8 Attack", + module: "Band 8", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B8Release, + name: "Band 8 Release", + module: "Band 8", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B8Knee, + name: "Band 8 Knee", + module: "Band 8", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B8Makeup, + name: "Band 8 Makeup", + module: "Band 8", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B8Range, + name: "Band 8 Range", + module: "Band 8", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B9Threshold, + name: "Band 9 Threshold", + module: "Band 9", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B9Ratio, + name: "Band 9 Ratio", + module: "Band 9", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B9Attack, + name: "Band 9 Attack", + module: "Band 9", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B9Release, + name: "Band 9 Release", + module: "Band 9", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B9Knee, + name: "Band 9 Knee", + module: "Band 9", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B9Makeup, + name: "Band 9 Makeup", + module: "Band 9", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B9Range, + name: "Band 9 Range", + module: "Band 9", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B10Threshold, + name: "Band 10 Threshold", + module: "Band 10", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B10Ratio, + name: "Band 10 Ratio", + module: "Band 10", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B10Attack, + name: "Band 10 Attack", + module: "Band 10", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B10Release, + name: "Band 10 Release", + module: "Band 10", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B10Knee, + name: "Band 10 Knee", + module: "Band 10", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B10Makeup, + name: "Band 10 Makeup", + module: "Band 10", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B10Range, + name: "Band 10 Range", + module: "Band 10", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B11Threshold, + name: "Band 11 Threshold", + module: "Band 11", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B11Ratio, + name: "Band 11 Ratio", + module: "Band 11", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B11Attack, + name: "Band 11 Attack", + module: "Band 11", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B11Release, + name: "Band 11 Release", + module: "Band 11", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B11Knee, + name: "Band 11 Knee", + module: "Band 11", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B11Makeup, + name: "Band 11 Makeup", + module: "Band 11", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B11Range, + name: "Band 11 Range", + module: "Band 11", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B12Threshold, + name: "Band 12 Threshold", + module: "Band 12", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B12Ratio, + name: "Band 12 Ratio", + module: "Band 12", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B12Attack, + name: "Band 12 Attack", + module: "Band 12", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B12Release, + name: "Band 12 Release", + module: "Band 12", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B12Knee, + name: "Band 12 Knee", + module: "Band 12", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B12Makeup, + name: "Band 12 Makeup", + module: "Band 12", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B12Range, + name: "Band 12 Range", + module: "Band 12", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B13Threshold, + name: "Band 13 Threshold", + module: "Band 13", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B13Ratio, + name: "Band 13 Ratio", + module: "Band 13", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B13Attack, + name: "Band 13 Attack", + module: "Band 13", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B13Release, + name: "Band 13 Release", + module: "Band 13", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B13Knee, + name: "Band 13 Knee", + module: "Band 13", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B13Makeup, + name: "Band 13 Makeup", + module: "Band 13", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B13Range, + name: "Band 13 Range", + module: "Band 13", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B14Threshold, + name: "Band 14 Threshold", + module: "Band 14", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B14Ratio, + name: "Band 14 Ratio", + module: "Band 14", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B14Attack, + name: "Band 14 Attack", + module: "Band 14", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B14Release, + name: "Band 14 Release", + module: "Band 14", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B14Knee, + name: "Band 14 Knee", + module: "Band 14", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B14Makeup, + name: "Band 14 Makeup", + module: "Band 14", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B14Range, + name: "Band 14 Range", + module: "Band 14", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B15Threshold, + name: "Band 15 Threshold", + module: "Band 15", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B15Ratio, + name: "Band 15 Ratio", + module: "Band 15", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B15Attack, + name: "Band 15 Attack", + module: "Band 15", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B15Release, + name: "Band 15 Release", + module: "Band 15", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B15Knee, + name: "Band 15 Knee", + module: "Band 15", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B15Makeup, + name: "Band 15 Makeup", + module: "Band 15", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B15Range, + name: "Band 15 Range", + module: "Band 15", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B16Threshold, + name: "Band 16 Threshold", + module: "Band 16", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B16Ratio, + name: "Band 16 Ratio", + module: "Band 16", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B16Attack, + name: "Band 16 Attack", + module: "Band 16", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B16Release, + name: "Band 16 Release", + module: "Band 16", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B16Knee, + name: "Band 16 Knee", + module: "Band 16", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B16Makeup, + name: "Band 16 Makeup", + module: "Band 16", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B16Range, + name: "Band 16 Range", + module: "Band 16", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B17Threshold, + name: "Band 17 Threshold", + module: "Band 17", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B17Ratio, + name: "Band 17 Ratio", + module: "Band 17", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B17Attack, + name: "Band 17 Attack", + module: "Band 17", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B17Release, + name: "Band 17 Release", + module: "Band 17", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B17Knee, + name: "Band 17 Knee", + module: "Band 17", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B17Makeup, + name: "Band 17 Makeup", + module: "Band 17", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B17Range, + name: "Band 17 Range", + module: "Band 17", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B18Threshold, + name: "Band 18 Threshold", + module: "Band 18", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B18Ratio, + name: "Band 18 Ratio", + module: "Band 18", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B18Attack, + name: "Band 18 Attack", + module: "Band 18", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B18Release, + name: "Band 18 Release", + module: "Band 18", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B18Knee, + name: "Band 18 Knee", + module: "Band 18", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B18Makeup, + name: "Band 18 Makeup", + module: "Band 18", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B18Range, + name: "Band 18 Range", + module: "Band 18", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B19Threshold, + name: "Band 19 Threshold", + module: "Band 19", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B19Ratio, + name: "Band 19 Ratio", + module: "Band 19", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B19Attack, + name: "Band 19 Attack", + module: "Band 19", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B19Release, + name: "Band 19 Release", + module: "Band 19", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B19Knee, + name: "Band 19 Knee", + module: "Band 19", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B19Makeup, + name: "Band 19 Makeup", + module: "Band 19", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B19Range, + name: "Band 19 Range", + module: "Band 19", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B20Threshold, + name: "Band 20 Threshold", + module: "Band 20", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B20Ratio, + name: "Band 20 Ratio", + module: "Band 20", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B20Attack, + name: "Band 20 Attack", + module: "Band 20", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B20Release, + name: "Band 20 Release", + module: "Band 20", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B20Knee, + name: "Band 20 Knee", + module: "Band 20", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B20Makeup, + name: "Band 20 Makeup", + module: "Band 20", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B20Range, + name: "Band 20 Range", + module: "Band 20", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B21Threshold, + name: "Band 21 Threshold", + module: "Band 21", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B21Ratio, + name: "Band 21 Ratio", + module: "Band 21", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B21Attack, + name: "Band 21 Attack", + module: "Band 21", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B21Release, + name: "Band 21 Release", + module: "Band 21", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B21Knee, + name: "Band 21 Knee", + module: "Band 21", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B21Makeup, + name: "Band 21 Makeup", + module: "Band 21", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B21Range, + name: "Band 21 Range", + module: "Band 21", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B22Threshold, + name: "Band 22 Threshold", + module: "Band 22", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B22Ratio, + name: "Band 22 Ratio", + module: "Band 22", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B22Attack, + name: "Band 22 Attack", + module: "Band 22", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B22Release, + name: "Band 22 Release", + module: "Band 22", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B22Knee, + name: "Band 22 Knee", + module: "Band 22", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B22Makeup, + name: "Band 22 Makeup", + module: "Band 22", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B22Range, + name: "Band 22 Range", + module: "Band 22", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B23Threshold, + name: "Band 23 Threshold", + module: "Band 23", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B23Ratio, + name: "Band 23 Ratio", + module: "Band 23", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B23Attack, + name: "Band 23 Attack", + module: "Band 23", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B23Release, + name: "Band 23 Release", + module: "Band 23", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B23Knee, + name: "Band 23 Knee", + module: "Band 23", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B23Makeup, + name: "Band 23 Makeup", + module: "Band 23", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B23Range, + name: "Band 23 Range", + module: "Band 23", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B24Threshold, + name: "Band 24 Threshold", + module: "Band 24", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B24Ratio, + name: "Band 24 Ratio", + module: "Band 24", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B24Attack, + name: "Band 24 Attack", + module: "Band 24", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B24Release, + name: "Band 24 Release", + module: "Band 24", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B24Knee, + name: "Band 24 Knee", + module: "Band 24", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B24Makeup, + name: "Band 24 Makeup", + module: "Band 24", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B24Range, + name: "Band 24 Range", + module: "Band 24", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B25Threshold, + name: "Band 25 Threshold", + module: "Band 25", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B25Ratio, + name: "Band 25 Ratio", + module: "Band 25", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B25Attack, + name: "Band 25 Attack", + module: "Band 25", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B25Release, + name: "Band 25 Release", + module: "Band 25", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B25Knee, + name: "Band 25 Knee", + module: "Band 25", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B25Makeup, + name: "Band 25 Makeup", + module: "Band 25", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B25Range, + name: "Band 25 Range", + module: "Band 25", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B26Threshold, + name: "Band 26 Threshold", + module: "Band 26", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B26Ratio, + name: "Band 26 Ratio", + module: "Band 26", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B26Attack, + name: "Band 26 Attack", + module: "Band 26", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B26Release, + name: "Band 26 Release", + module: "Band 26", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B26Knee, + name: "Band 26 Knee", + module: "Band 26", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B26Makeup, + name: "Band 26 Makeup", + module: "Band 26", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B26Range, + name: "Band 26 Range", + module: "Band 26", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B27Threshold, + name: "Band 27 Threshold", + module: "Band 27", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B27Ratio, + name: "Band 27 Ratio", + module: "Band 27", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B27Attack, + name: "Band 27 Attack", + module: "Band 27", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B27Release, + name: "Band 27 Release", + module: "Band 27", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B27Knee, + name: "Band 27 Knee", + module: "Band 27", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B27Makeup, + name: "Band 27 Makeup", + module: "Band 27", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B27Range, + name: "Band 27 Range", + module: "Band 27", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B28Threshold, + name: "Band 28 Threshold", + module: "Band 28", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B28Ratio, + name: "Band 28 Ratio", + module: "Band 28", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B28Attack, + name: "Band 28 Attack", + module: "Band 28", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B28Release, + name: "Band 28 Release", + module: "Band 28", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B28Knee, + name: "Band 28 Knee", + module: "Band 28", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B28Makeup, + name: "Band 28 Makeup", + module: "Band 28", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B28Range, + name: "Band 28 Range", + module: "Band 28", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B29Threshold, + name: "Band 29 Threshold", + module: "Band 29", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B29Ratio, + name: "Band 29 Ratio", + module: "Band 29", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B29Attack, + name: "Band 29 Attack", + module: "Band 29", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B29Release, + name: "Band 29 Release", + module: "Band 29", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B29Knee, + name: "Band 29 Knee", + module: "Band 29", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B29Makeup, + name: "Band 29 Makeup", + module: "Band 29", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B29Range, + name: "Band 29 Range", + module: "Band 29", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B30Threshold, + name: "Band 30 Threshold", + module: "Band 30", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B30Ratio, + name: "Band 30 Ratio", + module: "Band 30", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B30Attack, + name: "Band 30 Attack", + module: "Band 30", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B30Release, + name: "Band 30 Release", + module: "Band 30", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B30Knee, + name: "Band 30 Knee", + module: "Band 30", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B30Makeup, + name: "Band 30 Makeup", + module: "Band 30", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B30Range, + name: "Band 30 Range", + module: "Band 30", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B31Threshold, + name: "Band 31 Threshold", + module: "Band 31", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B31Ratio, + name: "Band 31 Ratio", + module: "Band 31", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B31Attack, + name: "Band 31 Attack", + module: "Band 31", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B31Release, + name: "Band 31 Release", + module: "Band 31", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B31Knee, + name: "Band 31 Knee", + module: "Band 31", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B31Makeup, + name: "Band 31 Makeup", + module: "Band 31", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B31Range, + name: "Band 31 Range", + module: "Band 31", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B32Threshold, + name: "Band 32 Threshold", + module: "Band 32", + min: -52.5, + max: 30.0, + default: -3.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B32Ratio, + name: "Band 32 Ratio", + module: "Band 32", + min: 1.0, + max: 100.0, + default: 4.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B32Attack, + name: "Band 32 Attack", + module: "Band 32", + min: 0.0, + max: 2000.0, + default: 20.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B32Release, + name: "Band 32 Release", + module: "Band 32", + min: 0.0, + max: 5000.0, + default: 100.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B32Knee, + name: "Band 32 Knee", + module: "Band 32", + min: 0.0, + max: 24.0, + default: 6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B32Makeup, + name: "Band 32 Makeup", + module: "Band 32", + min: -24.0, + max: 24.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::B32Range, + name: "Band 32 Range", + module: "Band 32", + min: -30.0, + max: 30.0, + default: -12.0, + step: 0.1, + flags: AUTOMATABLE, + } ]; } +impl ParamId { + pub fn split(index: usize) -> Self { + match index { + 0 => Self::Split1, + 1 => Self::Split2, + 2 => Self::Split3, + 3 => Self::Split4, + 4 => Self::Split5, + _ => Self::from_raw(60 + (index - 5) as u32).unwrap(), + } + } + + fn extended_band(band: usize, offset: u32) -> Self { + Self::from_raw(86 + (band - 6) as u32 * 7 + offset).unwrap() + } + + pub fn band_threshold(band: usize) -> Self { + match band { + 0 => Self::B1Threshold, + 1 => Self::B2Threshold, + 2 => Self::B3Threshold, + 3 => Self::B4Threshold, + 4 => Self::B5Threshold, + 5 => Self::B6Threshold, + _ => Self::extended_band(band, 0), + } + } + + pub fn band_ratio(band: usize) -> Self { + match band { + 0 => Self::B1Ratio, + 1 => Self::B2Ratio, + 2 => Self::B3Ratio, + 3 => Self::B4Ratio, + 4 => Self::B5Ratio, + 5 => Self::B6Ratio, + _ => Self::extended_band(band, 1), + } + } + + pub fn band_attack(band: usize) -> Self { + match band { + 0 => Self::B1Attack, + 1 => Self::B2Attack, + 2 => Self::B3Attack, + 3 => Self::B4Attack, + 4 => Self::B5Attack, + 5 => Self::B6Attack, + _ => Self::extended_band(band, 2), + } + } + + pub fn band_release(band: usize) -> Self { + match band { + 0 => Self::B1Release, + 1 => Self::B2Release, + 2 => Self::B3Release, + 3 => Self::B4Release, + 4 => Self::B5Release, + 5 => Self::B6Release, + _ => Self::extended_band(band, 3), + } + } + + pub fn band_knee(band: usize) -> Self { + match band { + 0 => Self::B1Knee, + 1 => Self::B2Knee, + 2 => Self::B3Knee, + 3 => Self::B4Knee, + 4 => Self::B5Knee, + 5 => Self::B6Knee, + _ => Self::extended_band(band, 4), + } + } + + pub fn band_makeup(band: usize) -> Self { + match band { + 0 => Self::B1Makeup, + 1 => Self::B2Makeup, + 2 => Self::B3Makeup, + 3 => Self::B4Makeup, + 4 => Self::B5Makeup, + 5 => Self::B6Makeup, + _ => Self::extended_band(band, 5), + } + } + + pub fn band_range(band: usize) -> Self { + match band { + 0 => Self::B1Range, + 1 => Self::B2Range, + 2 => Self::B3Range, + 3 => Self::B4Range, + 4 => Self::B5Range, + 5 => Self::B6Range, + _ => Self::extended_band(band, 6), + } + } +} + const AUTOMATABLE: u32 = CLAP_PARAM_IS_AUTOMATABLE | CLAP_PARAM_REQUIRES_PROCESS; const BOOL_FLAGS: u32 = AUTOMATABLE | CLAP_PARAM_IS_STEPPED; const ENUM_FLAGS: u32 = AUTOMATABLE | CLAP_PARAM_IS_STEPPED | CLAP_PARAM_IS_ENUM; diff --git a/src/compressor/plugin.rs b/src/compressor/plugin.rs index 8f93149..3e2c9bd 100644 --- a/src/compressor/plugin.rs +++ b/src/compressor/plugin.rs @@ -160,22 +160,22 @@ impl crate::common::SharedStateExt for SharedState { self.core.request_audio_ports_rescan(); } } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> crate::common::ParamBits { self.core.take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_end(bits); } } @@ -320,102 +320,30 @@ impl AudioProcessor { .set_dry_gain(shared.params.get(ParamId::DryGain) as f32); self.compressor .set_wet_gain(shared.params.get(ParamId::WetGain) as f32); - self.compressor - .set_split_hz(0, shared.params.get(ParamId::Split1) as f32); - self.compressor - .set_split_hz(1, shared.params.get(ParamId::Split2) as f32); - self.compressor - .set_split_hz(2, shared.params.get(ParamId::Split3) as f32); - self.compressor - .set_split_hz(3, shared.params.get(ParamId::Split4) as f32); - self.compressor - .set_split_hz(4, shared.params.get(ParamId::Split5) as f32); + for split in 0..crate::compressor::dsp::MAX_BANDS - 1 { + self.compressor + .set_split_hz(split, shared.params.get(ParamId::split(split)) as f32); + } self.compressor .set_band_count(shared.params.get(ParamId::BandCount).round() as usize); - self.compressor - .set_band_threshold_db(0, shared.params.get(ParamId::B1Threshold) as f32); - self.compressor - .set_band_range_db(0, shared.params.get(ParamId::B1Range) as f32); - self.compressor - .set_band_ratio(0, shared.params.get(ParamId::B1Ratio) as f32); - self.compressor - .set_band_attack_ms(0, shared.params.get(ParamId::B1Attack) as f32); - self.compressor - .set_band_release_ms(0, shared.params.get(ParamId::B1Release) as f32); - self.compressor - .set_band_knee_db(0, shared.params.get(ParamId::B1Knee) as f32); - self.compressor - .set_band_makeup_db(0, shared.params.get(ParamId::B1Makeup) as f32); - self.compressor - .set_band_threshold_db(1, shared.params.get(ParamId::B2Threshold) as f32); - self.compressor - .set_band_range_db(1, shared.params.get(ParamId::B2Range) as f32); - self.compressor - .set_band_ratio(1, shared.params.get(ParamId::B2Ratio) as f32); - self.compressor - .set_band_attack_ms(1, shared.params.get(ParamId::B2Attack) as f32); - self.compressor - .set_band_release_ms(1, shared.params.get(ParamId::B2Release) as f32); - self.compressor - .set_band_knee_db(1, shared.params.get(ParamId::B2Knee) as f32); - self.compressor - .set_band_makeup_db(1, shared.params.get(ParamId::B2Makeup) as f32); - self.compressor - .set_band_threshold_db(2, shared.params.get(ParamId::B3Threshold) as f32); - self.compressor - .set_band_range_db(2, shared.params.get(ParamId::B3Range) as f32); - self.compressor - .set_band_ratio(2, shared.params.get(ParamId::B3Ratio) as f32); - self.compressor - .set_band_attack_ms(2, shared.params.get(ParamId::B3Attack) as f32); - self.compressor - .set_band_release_ms(2, shared.params.get(ParamId::B3Release) as f32); - self.compressor - .set_band_knee_db(2, shared.params.get(ParamId::B3Knee) as f32); - self.compressor - .set_band_makeup_db(2, shared.params.get(ParamId::B3Makeup) as f32); - self.compressor - .set_band_threshold_db(3, shared.params.get(ParamId::B4Threshold) as f32); - self.compressor - .set_band_range_db(3, shared.params.get(ParamId::B4Range) as f32); - self.compressor - .set_band_ratio(3, shared.params.get(ParamId::B4Ratio) as f32); - self.compressor - .set_band_attack_ms(3, shared.params.get(ParamId::B4Attack) as f32); - self.compressor - .set_band_release_ms(3, shared.params.get(ParamId::B4Release) as f32); - self.compressor - .set_band_knee_db(3, shared.params.get(ParamId::B4Knee) as f32); - self.compressor - .set_band_makeup_db(3, shared.params.get(ParamId::B4Makeup) as f32); - self.compressor - .set_band_threshold_db(4, shared.params.get(ParamId::B5Threshold) as f32); - self.compressor - .set_band_range_db(4, shared.params.get(ParamId::B5Range) as f32); - self.compressor - .set_band_ratio(4, shared.params.get(ParamId::B5Ratio) as f32); - self.compressor - .set_band_attack_ms(4, shared.params.get(ParamId::B5Attack) as f32); - self.compressor - .set_band_release_ms(4, shared.params.get(ParamId::B5Release) as f32); - self.compressor - .set_band_knee_db(4, shared.params.get(ParamId::B5Knee) as f32); - self.compressor - .set_band_makeup_db(4, shared.params.get(ParamId::B5Makeup) as f32); - self.compressor - .set_band_threshold_db(5, shared.params.get(ParamId::B6Threshold) as f32); - self.compressor - .set_band_range_db(5, shared.params.get(ParamId::B6Range) as f32); - self.compressor - .set_band_ratio(5, shared.params.get(ParamId::B6Ratio) as f32); - self.compressor - .set_band_attack_ms(5, shared.params.get(ParamId::B6Attack) as f32); - self.compressor - .set_band_release_ms(5, shared.params.get(ParamId::B6Release) as f32); - self.compressor - .set_band_knee_db(5, shared.params.get(ParamId::B6Knee) as f32); - self.compressor - .set_band_makeup_db(5, shared.params.get(ParamId::B6Makeup) as f32); + for band in 0..crate::compressor::dsp::MAX_BANDS { + self.compressor.set_band_threshold_db( + band, + shared.params.get(ParamId::band_threshold(band)) as f32, + ); + self.compressor + .set_band_range_db(band, shared.params.get(ParamId::band_range(band)) as f32); + self.compressor + .set_band_ratio(band, shared.params.get(ParamId::band_ratio(band)) as f32); + self.compressor + .set_band_attack_ms(band, shared.params.get(ParamId::band_attack(band)) as f32); + self.compressor + .set_band_release_ms(band, shared.params.get(ParamId::band_release(band)) as f32); + self.compressor + .set_band_knee_db(band, shared.params.get(ParamId::band_knee(band)) as f32); + self.compressor + .set_band_makeup_db(band, shared.params.get(ParamId::band_makeup(band)) as f32); + } self.compressor .set_sc_mode(shared.params.get_enum(ParamId::ScMode)); self.compressor @@ -614,6 +542,26 @@ impl AudioProcessor { } fn param_text(id: ParamId, value: f64) -> String { + for split in 5..crate::compressor::dsp::MAX_BANDS - 1 { + if id == ParamId::split(split) { + return format!("{value:.0} Hz"); + } + } + for band in 6..crate::compressor::dsp::MAX_BANDS { + if id == ParamId::band_attack(band) || id == ParamId::band_release(band) { + return format!("{value:.1} ms"); + } + if id == ParamId::band_ratio(band) { + return format!("{value:.1}:1"); + } + if id == ParamId::band_threshold(band) + || id == ParamId::band_range(band) + || id == ParamId::band_knee(band) + || id == ParamId::band_makeup(band) + { + return format!("{value:.1} dB"); + } + } match id { ParamId::Channels => match value.round() as i32 { 1 => "Mono".into(), @@ -712,6 +660,36 @@ fn param_text(id: ParamId, value: f64) -> String { fn parse_param_text(id: ParamId, text: &str) -> Option { let text = text.trim(); + for split in 5..crate::compressor::dsp::MAX_BANDS - 1 { + if id == ParamId::split(split) { + return text + .trim_end_matches("hz") + .trim_end_matches("Hz") + .trim() + .parse() + .ok(); + } + } + for band in 6..crate::compressor::dsp::MAX_BANDS { + if id == ParamId::band_attack(band) || id == ParamId::band_release(band) { + return text.trim_end_matches("ms").trim().parse().ok(); + } + if id == ParamId::band_ratio(band) { + return text.trim_end_matches(":1").trim().parse().ok(); + } + if id == ParamId::band_threshold(band) + || id == ParamId::band_range(band) + || id == ParamId::band_knee(band) + || id == ParamId::band_makeup(band) + { + return text + .trim_end_matches("db") + .trim_end_matches("dB") + .trim() + .parse() + .ok(); + } + } match id { ParamId::ScMode => match text.to_ascii_lowercase().as_str() { "peak" => Some(0.0), @@ -907,295 +885,91 @@ fn apply_param_id( ParamId::InputGain => { compressor.set_input_gain_db(value as f32); dirty.input_output = true; - true + return true; } ParamId::OutputGain => { compressor.set_output_gain_db(value as f32); dirty.input_output = true; - true + return true; } ParamId::DryGain => { compressor.set_dry_gain(value as f32); dirty.input_output = true; - true + return true; } ParamId::WetGain => { compressor.set_wet_gain(value as f32); dirty.input_output = true; - true - } - ParamId::Split1 => { - compressor.set_split_hz(0, value as f32); - dirty.splits = true; - true - } - ParamId::Split2 => { - compressor.set_split_hz(1, value as f32); - dirty.splits = true; - true - } - ParamId::Split3 => { - compressor.set_split_hz(2, value as f32); - dirty.splits = true; - true - } - ParamId::Split4 => { - compressor.set_split_hz(3, value as f32); - dirty.splits = true; - true - } - ParamId::Split5 => { - compressor.set_split_hz(4, value as f32); - dirty.splits = true; - true + return true; } ParamId::BandCount => { compressor.set_band_count(value.round() as usize); dirty.splits = true; - true - } - ParamId::B1Threshold => { - compressor.set_band_threshold_db(0, value as f32); - dirty.bands = true; - true - } - ParamId::B1Ratio => { - compressor.set_band_ratio(0, value as f32); - dirty.bands = true; - true - } - ParamId::B1Range => { - compressor.set_band_range_db(0, value as f32); - dirty.bands = true; - true - } - ParamId::B1Attack => { - compressor.set_band_attack_ms(0, value as f32); - dirty.bands = true; - true - } - ParamId::B1Release => { - compressor.set_band_release_ms(0, value as f32); - dirty.bands = true; - true - } - ParamId::B1Knee => { - compressor.set_band_knee_db(0, value as f32); - dirty.bands = true; - true - } - ParamId::B1Makeup => { - compressor.set_band_makeup_db(0, value as f32); - dirty.bands = true; - true - } - ParamId::B2Threshold => { - compressor.set_band_threshold_db(1, value as f32); - dirty.bands = true; - true - } - ParamId::B2Ratio => { - compressor.set_band_ratio(1, value as f32); - dirty.bands = true; - true - } - ParamId::B2Range => { - compressor.set_band_range_db(1, value as f32); - dirty.bands = true; - true - } - ParamId::B2Attack => { - compressor.set_band_attack_ms(1, value as f32); - dirty.bands = true; - true - } - ParamId::B2Release => { - compressor.set_band_release_ms(1, value as f32); - dirty.bands = true; - true - } - ParamId::B2Knee => { - compressor.set_band_knee_db(1, value as f32); - dirty.bands = true; - true - } - ParamId::B2Makeup => { - compressor.set_band_makeup_db(1, value as f32); - dirty.bands = true; - true - } - ParamId::B3Threshold => { - compressor.set_band_threshold_db(2, value as f32); - dirty.bands = true; - true - } - ParamId::B3Ratio => { - compressor.set_band_ratio(2, value as f32); - dirty.bands = true; - true - } - ParamId::B3Range => { - compressor.set_band_range_db(2, value as f32); - dirty.bands = true; - true - } - ParamId::B3Attack => { - compressor.set_band_attack_ms(2, value as f32); - dirty.bands = true; - true - } - ParamId::B3Release => { - compressor.set_band_release_ms(2, value as f32); - dirty.bands = true; - true - } - ParamId::B3Knee => { - compressor.set_band_knee_db(2, value as f32); - dirty.bands = true; - true - } - ParamId::B3Makeup => { - compressor.set_band_makeup_db(2, value as f32); - dirty.bands = true; - true - } - ParamId::B4Threshold => { - compressor.set_band_threshold_db(3, value as f32); - dirty.bands = true; - true - } - ParamId::B4Ratio => { - compressor.set_band_ratio(3, value as f32); - dirty.bands = true; - true - } - ParamId::B4Range => { - compressor.set_band_range_db(3, value as f32); - dirty.bands = true; - true - } - ParamId::B4Attack => { - compressor.set_band_attack_ms(3, value as f32); - dirty.bands = true; - true - } - ParamId::B4Release => { - compressor.set_band_release_ms(3, value as f32); - dirty.bands = true; - true - } - ParamId::B4Knee => { - compressor.set_band_knee_db(3, value as f32); - dirty.bands = true; - true - } - ParamId::B4Makeup => { - compressor.set_band_makeup_db(3, value as f32); - dirty.bands = true; - true - } - ParamId::B5Threshold => { - compressor.set_band_threshold_db(4, value as f32); - dirty.bands = true; - true - } - ParamId::B5Ratio => { - compressor.set_band_ratio(4, value as f32); - dirty.bands = true; - true - } - ParamId::B5Range => { - compressor.set_band_range_db(4, value as f32); - dirty.bands = true; - true - } - ParamId::B5Attack => { - compressor.set_band_attack_ms(4, value as f32); - dirty.bands = true; - true - } - ParamId::B5Release => { - compressor.set_band_release_ms(4, value as f32); - dirty.bands = true; - true - } - ParamId::B5Knee => { - compressor.set_band_knee_db(4, value as f32); - dirty.bands = true; - true - } - ParamId::B5Makeup => { - compressor.set_band_makeup_db(4, value as f32); - dirty.bands = true; - true - } - ParamId::B6Threshold => { - compressor.set_band_threshold_db(5, value as f32); - dirty.bands = true; - true - } - ParamId::B6Ratio => { - compressor.set_band_ratio(5, value as f32); - dirty.bands = true; - true - } - ParamId::B6Range => { - compressor.set_band_range_db(5, value as f32); - dirty.bands = true; - true - } - ParamId::B6Attack => { - compressor.set_band_attack_ms(5, value as f32); - dirty.bands = true; - true - } - ParamId::B6Release => { - compressor.set_band_release_ms(5, value as f32); - dirty.bands = true; - true - } - ParamId::B6Knee => { - compressor.set_band_knee_db(5, value as f32); - dirty.bands = true; - true - } - ParamId::B6Makeup => { - compressor.set_band_makeup_db(5, value as f32); - dirty.bands = true; - true + return true; } ParamId::ScMode => { - compressor.set_sc_mode(value.round().clamp(0.0, 1.0) as u32); + compressor.set_sc_mode(value.round() as u32); dirty.global = true; - true + return true; } ParamId::Mode => { - compressor.set_mode(value.round().clamp(0.0, 1.0) as u32); + compressor.set_mode(value.round() as u32); dirty.global = true; - true + return true; } ParamId::Topology => { - compressor.set_topology_mode(value.round().clamp(0.0, 1.0) as u32); + compressor.set_topology_mode(value.round() as u32); dirty.global = true; - true + return true; } ParamId::Lookahead => { compressor.set_lookahead_ms(value as f32); dirty.global = true; - true + return true; } ParamId::ScBoost => { - compressor.set_sc_boost(value.round().clamp(0.0, 4.0) as u32); + compressor.set_sc_boost(value.round() as u32); dirty.global = true; - true + return true; } ParamId::Bypass => { compressor.set_bypass(value >= 0.5); dirty.global = true; - true + return true; + } + ParamId::Channels | ParamId::ExternalSidechain => return true, + _ => {} + } + + for split in 0..crate::compressor::dsp::MAX_BANDS - 1 { + if id == ParamId::split(split) { + compressor.set_split_hz(split, value as f32); + dirty.splits = true; + return true; + } + } + for band in 0..crate::compressor::dsp::MAX_BANDS { + if id == ParamId::band_threshold(band) { + compressor.set_band_threshold_db(band, value as f32); + } else if id == ParamId::band_range(band) { + compressor.set_band_range_db(band, value as f32); + } else if id == ParamId::band_ratio(band) { + compressor.set_band_ratio(band, value as f32); + } else if id == ParamId::band_attack(band) { + compressor.set_band_attack_ms(band, value as f32); + } else if id == ParamId::band_release(band) { + compressor.set_band_release_ms(band, value as f32); + } else if id == ParamId::band_knee(band) { + compressor.set_band_knee_db(band, value as f32); + } else if id == ParamId::band_makeup(band) { + compressor.set_band_makeup_db(band, value as f32); + } else { + continue; } - ParamId::Channels | ParamId::ExternalSidechain => true, + dirty.bands = true; + return true; } + false } impl Processor for AudioProcessor { @@ -1379,9 +1153,19 @@ mod tests { let shared = SharedState::default(); shared.set_param_outbound_only(ParamId::B1Threshold, 12.0); shared.set_param_outbound_only(ParamId::B6Threshold, 30.0); + shared.set_param_outbound_only(ParamId::B32Threshold, 24.0); assert_eq!(shared.params.get(ParamId::B1Threshold), 12.0); assert_eq!(shared.params.get(ParamId::B6Threshold), 30.0); + assert_eq!(shared.params.get(ParamId::B32Threshold), 24.0); + let index = ParamId::B32Threshold.as_index(); + let bit = 1_u64 << (index % 64); + assert_ne!( + shared.take_pending_param_notifications()[index / 64] & bit, + 0 + ); + shared.mark_gesture_begin_pending(ParamId::B32Threshold); + assert_ne!(shared.take_pending_gesture_begin()[index / 64] & bit, 0); } #[test] diff --git a/src/invert/plugin.rs b/src/invert/plugin.rs index 239e925..63fde50 100644 --- a/src/invert/plugin.rs +++ b/src/invert/plugin.rs @@ -138,27 +138,27 @@ impl crate::common::SharedStateExt for SharedState { } } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> crate::common::ParamBits { self.core.take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_end(bits); } } diff --git a/src/lag/plugin.rs b/src/lag/plugin.rs index f221aad..5774f3d 100644 --- a/src/lag/plugin.rs +++ b/src/lag/plugin.rs @@ -141,27 +141,27 @@ impl crate::common::SharedStateExt for SharedState { self.handle_param_change(id); } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> crate::common::ParamBits { self.core.take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_end(bits); } } diff --git a/src/reverb/plugin.rs b/src/reverb/plugin.rs index 4acf151..b33b37a 100644 --- a/src/reverb/plugin.rs +++ b/src/reverb/plugin.rs @@ -136,22 +136,22 @@ impl crate::common::SharedStateExt for SharedState { self.core.set_param_from_host(id, value); self.bump_params_version(); } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> crate::common::ParamBits { self.core.take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_end(bits); } } diff --git a/src/transient/dsp.rs b/src/transient/dsp.rs index c9190bf..29679d3 100644 --- a/src/transient/dsp.rs +++ b/src/transient/dsp.rs @@ -1,4 +1,4 @@ -pub const MAX_BANDS: usize = 4; +pub const MAX_BANDS: usize = 32; const MAX_SPLITS: usize = MAX_BANDS - 1; #[derive(Debug, Clone, Copy)] @@ -34,7 +34,13 @@ impl Default for TransientParams { fn default() -> Self { Self { band_count: 1, - split_hz: [120.0, 1000.0, 6000.0], + split_hz: std::array::from_fn(|split| { + const DEFAULTS: [f32; 3] = [120.0, 1000.0, 6000.0]; + DEFAULTS.get(split).copied().unwrap_or_else(|| { + let fraction = (split - 2) as f32 / 28.0; + 6000.0 * (20_000.0_f32 / 6000.0).powf(fraction) + }) + }), bands: [BandParams::default(); MAX_BANDS], master_range_db: 0.0, master_sensitivity: 0.0, diff --git a/src/transient/gui.rs b/src/transient/gui.rs index 18b3a95..4c50f64 100644 --- a/src/transient/gui.rs +++ b/src/transient/gui.rs @@ -722,9 +722,19 @@ mod tests { let _ = update(&mut state, Message::CreateBand(200.0)); let _ = update(&mut state, Message::CreateBand(8_000.0)); let _ = update(&mut state, Message::CreateBand(500.0)); - assert_eq!(state.shared.params.get(ParamId::BandCount), 4.0); - assert_eq!(active_splits(&state.shared), [200.0, 2_000.0, 8_000.0]); - assert_eq!(state.selected_band, 3); + assert_eq!(state.shared.params.get(ParamId::BandCount), 5.0); + assert_eq!( + active_splits(&state.shared), + [200.0, 500.0, 2_000.0, 8_000.0] + ); + assert_eq!(state.selected_band, 2); + for band in 5..MAX_BANDS { + let _ = update(&mut state, Message::CreateBand(500.0 * (band + 1) as f32)); + } + assert_eq!(state.shared.params.get(ParamId::BandCount), 32.0); + assert_eq!(state.selected_band, MAX_BANDS - 1); + let _ = update(&mut state, Message::CreateBand(1_000.0)); + assert_eq!(state.shared.params.get(ParamId::BandCount), 32.0); } #[test] diff --git a/src/transient/params.rs b/src/transient/params.rs index 0fca379..9df213f 100644 --- a/src/transient/params.rs +++ b/src/transient/params.rs @@ -25,6 +25,118 @@ crate::define_params! { Band4On = 18, Band4Range = 19, Band4Sensitivity = 20, + Split4 = 21, + Split5 = 22, + Split6 = 23, + Split7 = 24, + Split8 = 25, + Split9 = 26, + Split10 = 27, + Split11 = 28, + Split12 = 29, + Split13 = 30, + Split14 = 31, + Split15 = 32, + Split16 = 33, + Split17 = 34, + Split18 = 35, + Split19 = 36, + Split20 = 37, + Split21 = 38, + Split22 = 39, + Split23 = 40, + Split24 = 41, + Split25 = 42, + Split26 = 43, + Split27 = 44, + Split28 = 45, + Split29 = 46, + Split30 = 47, + Split31 = 48, + Band5On = 49, + Band5Range = 50, + Band5Sensitivity = 51, + Band6On = 52, + Band6Range = 53, + Band6Sensitivity = 54, + Band7On = 55, + Band7Range = 56, + Band7Sensitivity = 57, + Band8On = 58, + Band8Range = 59, + Band8Sensitivity = 60, + Band9On = 61, + Band9Range = 62, + Band9Sensitivity = 63, + Band10On = 64, + Band10Range = 65, + Band10Sensitivity = 66, + Band11On = 67, + Band11Range = 68, + Band11Sensitivity = 69, + Band12On = 70, + Band12Range = 71, + Band12Sensitivity = 72, + Band13On = 73, + Band13Range = 74, + Band13Sensitivity = 75, + Band14On = 76, + Band14Range = 77, + Band14Sensitivity = 78, + Band15On = 79, + Band15Range = 80, + Band15Sensitivity = 81, + Band16On = 82, + Band16Range = 83, + Band16Sensitivity = 84, + Band17On = 85, + Band17Range = 86, + Band17Sensitivity = 87, + Band18On = 88, + Band18Range = 89, + Band18Sensitivity = 90, + Band19On = 91, + Band19Range = 92, + Band19Sensitivity = 93, + Band20On = 94, + Band20Range = 95, + Band20Sensitivity = 96, + Band21On = 97, + Band21Range = 98, + Band21Sensitivity = 99, + Band22On = 100, + Band22Range = 101, + Band22Sensitivity = 102, + Band23On = 103, + Band23Range = 104, + Band23Sensitivity = 105, + Band24On = 106, + Band24Range = 107, + Band24Sensitivity = 108, + Band25On = 109, + Band25Range = 110, + Band25Sensitivity = 111, + Band26On = 112, + Band26Range = 113, + Band26Sensitivity = 114, + Band27On = 115, + Band27Range = 116, + Band27Sensitivity = 117, + Band28On = 118, + Band28Range = 119, + Band28Sensitivity = 120, + Band29On = 121, + Band29Range = 122, + Band29Sensitivity = 123, + Band30On = 124, + Band30Range = 125, + Band30Sensitivity = 126, + Band31On = 127, + Band31Range = 128, + Band31Sensitivity = 129, + Band32On = 130, + Band32Range = 131, + Band32Sensitivity = 132, } pub const PARAMS: [ParamDef] = [ { @@ -32,7 +144,7 @@ crate::define_params! { name: "Band Count", module: "Configuration", min: 1.0, - max: 4.0, + max: 32.0, default: 1.0, step: 1.0, flags: STEPPED, @@ -237,24 +349,1167 @@ crate::define_params! { step: 0.1, flags: AUTOMATABLE, } + { + id: ParamId::Split4, + name: "Crossover 4", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 6264.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split5, + name: "Crossover 5", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 6539.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split6, + name: "Crossover 6", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 6826.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split7, + name: "Crossover 7", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 7126.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split8, + name: "Crossover 8", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 7439.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split9, + name: "Crossover 9", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 7766.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split10, + name: "Crossover 10", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 8107.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split11, + name: "Crossover 11", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 8463.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split12, + name: "Crossover 12", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 8835.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split13, + name: "Crossover 13", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 9223.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split14, + name: "Crossover 14", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 9629.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split15, + name: "Crossover 15", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 10052.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split16, + name: "Crossover 16", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 10493.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split17, + name: "Crossover 17", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 10954.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split18, + name: "Crossover 18", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 11436.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split19, + name: "Crossover 19", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 11938.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split20, + name: "Crossover 20", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 12463.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split21, + name: "Crossover 21", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 13010.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split22, + name: "Crossover 22", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 13582.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split23, + name: "Crossover 23", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 14179.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split24, + name: "Crossover 24", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 14802.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split25, + name: "Crossover 25", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 15452.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split26, + name: "Crossover 26", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 16131.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split27, + name: "Crossover 27", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 16840.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split28, + name: "Crossover 28", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 17580.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split29, + name: "Crossover 29", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 18352.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split30, + name: "Crossover 30", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 19158.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Split31, + name: "Crossover 31", + module: "Configuration", + min: 20.0, + max: 20000.0, + default: 20000.0, + step: 1.0, + flags: AUTOMATABLE, + } + { + id: ParamId::Band5On, + name: "Band 5 On", + module: "Band 5", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band5Range, + name: "Band 5 Range", + module: "Band 5", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band5Sensitivity, + name: "Band 5 Sensitivity", + module: "Band 5", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band6On, + name: "Band 6 On", + module: "Band 6", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band6Range, + name: "Band 6 Range", + module: "Band 6", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band6Sensitivity, + name: "Band 6 Sensitivity", + module: "Band 6", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band7On, + name: "Band 7 On", + module: "Band 7", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band7Range, + name: "Band 7 Range", + module: "Band 7", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band7Sensitivity, + name: "Band 7 Sensitivity", + module: "Band 7", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band8On, + name: "Band 8 On", + module: "Band 8", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band8Range, + name: "Band 8 Range", + module: "Band 8", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band8Sensitivity, + name: "Band 8 Sensitivity", + module: "Band 8", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band9On, + name: "Band 9 On", + module: "Band 9", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band9Range, + name: "Band 9 Range", + module: "Band 9", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band9Sensitivity, + name: "Band 9 Sensitivity", + module: "Band 9", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band10On, + name: "Band 10 On", + module: "Band 10", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band10Range, + name: "Band 10 Range", + module: "Band 10", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band10Sensitivity, + name: "Band 10 Sensitivity", + module: "Band 10", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band11On, + name: "Band 11 On", + module: "Band 11", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band11Range, + name: "Band 11 Range", + module: "Band 11", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band11Sensitivity, + name: "Band 11 Sensitivity", + module: "Band 11", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band12On, + name: "Band 12 On", + module: "Band 12", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band12Range, + name: "Band 12 Range", + module: "Band 12", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band12Sensitivity, + name: "Band 12 Sensitivity", + module: "Band 12", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band13On, + name: "Band 13 On", + module: "Band 13", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band13Range, + name: "Band 13 Range", + module: "Band 13", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band13Sensitivity, + name: "Band 13 Sensitivity", + module: "Band 13", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band14On, + name: "Band 14 On", + module: "Band 14", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band14Range, + name: "Band 14 Range", + module: "Band 14", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band14Sensitivity, + name: "Band 14 Sensitivity", + module: "Band 14", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band15On, + name: "Band 15 On", + module: "Band 15", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band15Range, + name: "Band 15 Range", + module: "Band 15", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band15Sensitivity, + name: "Band 15 Sensitivity", + module: "Band 15", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band16On, + name: "Band 16 On", + module: "Band 16", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band16Range, + name: "Band 16 Range", + module: "Band 16", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band16Sensitivity, + name: "Band 16 Sensitivity", + module: "Band 16", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band17On, + name: "Band 17 On", + module: "Band 17", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band17Range, + name: "Band 17 Range", + module: "Band 17", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band17Sensitivity, + name: "Band 17 Sensitivity", + module: "Band 17", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band18On, + name: "Band 18 On", + module: "Band 18", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band18Range, + name: "Band 18 Range", + module: "Band 18", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band18Sensitivity, + name: "Band 18 Sensitivity", + module: "Band 18", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band19On, + name: "Band 19 On", + module: "Band 19", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band19Range, + name: "Band 19 Range", + module: "Band 19", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band19Sensitivity, + name: "Band 19 Sensitivity", + module: "Band 19", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band20On, + name: "Band 20 On", + module: "Band 20", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band20Range, + name: "Band 20 Range", + module: "Band 20", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band20Sensitivity, + name: "Band 20 Sensitivity", + module: "Band 20", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band21On, + name: "Band 21 On", + module: "Band 21", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band21Range, + name: "Band 21 Range", + module: "Band 21", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band21Sensitivity, + name: "Band 21 Sensitivity", + module: "Band 21", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band22On, + name: "Band 22 On", + module: "Band 22", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band22Range, + name: "Band 22 Range", + module: "Band 22", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band22Sensitivity, + name: "Band 22 Sensitivity", + module: "Band 22", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band23On, + name: "Band 23 On", + module: "Band 23", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band23Range, + name: "Band 23 Range", + module: "Band 23", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band23Sensitivity, + name: "Band 23 Sensitivity", + module: "Band 23", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band24On, + name: "Band 24 On", + module: "Band 24", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band24Range, + name: "Band 24 Range", + module: "Band 24", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band24Sensitivity, + name: "Band 24 Sensitivity", + module: "Band 24", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band25On, + name: "Band 25 On", + module: "Band 25", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band25Range, + name: "Band 25 Range", + module: "Band 25", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band25Sensitivity, + name: "Band 25 Sensitivity", + module: "Band 25", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band26On, + name: "Band 26 On", + module: "Band 26", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band26Range, + name: "Band 26 Range", + module: "Band 26", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band26Sensitivity, + name: "Band 26 Sensitivity", + module: "Band 26", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band27On, + name: "Band 27 On", + module: "Band 27", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band27Range, + name: "Band 27 Range", + module: "Band 27", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band27Sensitivity, + name: "Band 27 Sensitivity", + module: "Band 27", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band28On, + name: "Band 28 On", + module: "Band 28", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band28Range, + name: "Band 28 Range", + module: "Band 28", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band28Sensitivity, + name: "Band 28 Sensitivity", + module: "Band 28", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band29On, + name: "Band 29 On", + module: "Band 29", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band29Range, + name: "Band 29 Range", + module: "Band 29", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band29Sensitivity, + name: "Band 29 Sensitivity", + module: "Band 29", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band30On, + name: "Band 30 On", + module: "Band 30", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band30Range, + name: "Band 30 Range", + module: "Band 30", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band30Sensitivity, + name: "Band 30 Sensitivity", + module: "Band 30", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band31On, + name: "Band 31 On", + module: "Band 31", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band31Range, + name: "Band 31 Range", + module: "Band 31", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band31Sensitivity, + name: "Band 31 Sensitivity", + module: "Band 31", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band32On, + name: "Band 32 On", + module: "Band 32", + min: 0.0, + max: 1.0, + default: 1.0, + step: 1.0, + flags: STEPPED, + } + { + id: ParamId::Band32Range, + name: "Band 32 Range", + module: "Band 32", + min: -90.0, + max: 20.0, + default: -6.0, + step: 0.1, + flags: AUTOMATABLE, + } + { + id: ParamId::Band32Sensitivity, + name: "Band 32 Sensitivity", + module: "Band 32", + min: -90.0, + max: 20.0, + default: 0.0, + step: 0.1, + flags: AUTOMATABLE, + } ]; } impl ParamId { pub fn band_on(band: usize) -> Self { - Self::from_raw(9 + band as u32 * 3).unwrap() + match band { + 0 => Self::Band1On, + 1 => Self::Band2On, + 2 => Self::Band3On, + 3 => Self::Band4On, + _ => Self::from_raw(49 + (band - 4) as u32 * 3).unwrap(), + } } pub fn band_range(band: usize) -> Self { - Self::from_raw(10 + band as u32 * 3).unwrap() + match band { + 0 => Self::Band1Range, + 1 => Self::Band2Range, + 2 => Self::Band3Range, + 3 => Self::Band4Range, + _ => Self::from_raw(50 + (band - 4) as u32 * 3).unwrap(), + } } pub fn band_sensitivity(band: usize) -> Self { - Self::from_raw(11 + band as u32 * 3).unwrap() + match band { + 0 => Self::Band1Sensitivity, + 1 => Self::Band2Sensitivity, + 2 => Self::Band3Sensitivity, + 3 => Self::Band4Sensitivity, + _ => Self::from_raw(51 + (band - 4) as u32 * 3).unwrap(), + } } pub fn split(index: usize) -> Self { - Self::from_raw(1 + index as u32).unwrap() + match index { + 0 => Self::Split1, + 1 => Self::Split2, + 2 => Self::Split3, + _ => Self::from_raw(21 + (index - 3) as u32).unwrap(), + } } } diff --git a/src/transient/plugin.rs b/src/transient/plugin.rs index 78ae7bb..4befadf 100644 --- a/src/transient/plugin.rs +++ b/src/transient/plugin.rs @@ -142,27 +142,27 @@ impl SharedStateExt for SharedState { self.core.set_param_from_host(id, value); } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> crate::common::ParamBits { self.core.take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_end(bits); } } @@ -217,11 +217,7 @@ impl ParamSpec for ParamId { fn runtime_params(shared: &SharedState) -> TransientParams { TransientParams { band_count: shared.params.get(ParamId::BandCount).round() as usize, - split_hz: [ - shared.params.get(ParamId::Split1) as f32, - shared.params.get(ParamId::Split2) as f32, - shared.params.get(ParamId::Split3) as f32, - ], + split_hz: std::array::from_fn(|split| shared.params.get(ParamId::split(split)) as f32), bands: std::array::from_fn(|band| BandParams { on: shared.params.get_bool(ParamId::band_on(band)), range_db: shared.params.get(ParamId::band_range(band)) as f32, @@ -361,62 +357,68 @@ fn peak_db(samples: &[f32]) -> f32 { } fn param_text(id: ParamId, value: f64) -> String { + for split in 0..crate::transient::dsp::MAX_BANDS - 1 { + if id == ParamId::split(split) { + return format!("{value:.0} Hz"); + } + } + for band in 0..crate::transient::dsp::MAX_BANDS { + if id == ParamId::band_on(band) { + return if value >= 0.5 { "On" } else { "Off" }.to_string(); + } + if id == ParamId::band_range(band) { + return format!("{value:.1} dB"); + } + if id == ParamId::band_sensitivity(band) { + return format!("{value:.1}"); + } + } match id { ParamId::BandCount => format!("{value:.0}"), - ParamId::Split1 | ParamId::Split2 | ParamId::Split3 => format!("{value:.0} Hz"), - ParamId::MasterRange - | ParamId::OutputGain - | ParamId::Band1Range - | ParamId::Band2Range - | ParamId::Band3Range - | ParamId::Band4Range => format!("{value:.1} dB"), - ParamId::MasterSensitivity - | ParamId::Band1Sensitivity - | ParamId::Band2Sensitivity - | ParamId::Band3Sensitivity - | ParamId::Band4Sensitivity => format!("{value:.1}"), + ParamId::MasterRange | ParamId::OutputGain => format!("{value:.1} dB"), + ParamId::MasterSensitivity => format!("{value:.1}"), ParamId::Duration | ParamId::Release => format!("{value:.2} ms"), - ParamId::Band1On | ParamId::Band2On | ParamId::Band3On | ParamId::Band4On => { - if value >= 0.5 { - "On".to_string() - } else { - "Off".to_string() - } - } + _ => format!("{value:.2}"), } } fn parse_param_text(id: ParamId, text: &str) -> Option { let text = text.trim(); - match id { - ParamId::BandCount => text.parse().ok(), - ParamId::Split1 | ParamId::Split2 | ParamId::Split3 => { - text.trim_end_matches("Hz").trim().parse().ok() + for split in 0..crate::transient::dsp::MAX_BANDS - 1 { + if id == ParamId::split(split) { + return text.trim_end_matches("Hz").trim().parse().ok(); } - ParamId::MasterRange - | ParamId::OutputGain - | ParamId::Band1Range - | ParamId::Band2Range - | ParamId::Band3Range - | ParamId::Band4Range => text + } + for band in 0..crate::transient::dsp::MAX_BANDS { + if id == ParamId::band_on(band) { + return match text.to_ascii_lowercase().as_str() { + "on" | "1" => Some(1.0), + "off" | "0" => Some(0.0), + _ => text.parse().ok(), + }; + } + if id == ParamId::band_range(band) { + return text + .trim_end_matches("db") + .trim_end_matches("dB") + .trim() + .parse() + .ok(); + } + if id == ParamId::band_sensitivity(band) { + return text.parse().ok(); + } + } + match id { + ParamId::BandCount | ParamId::MasterSensitivity => text.parse().ok(), + ParamId::MasterRange | ParamId::OutputGain => text .trim_end_matches("db") .trim_end_matches("dB") .trim() .parse() .ok(), - ParamId::MasterSensitivity - | ParamId::Band1Sensitivity - | ParamId::Band2Sensitivity - | ParamId::Band3Sensitivity - | ParamId::Band4Sensitivity => text.parse().ok(), ParamId::Duration | ParamId::Release => text.trim_end_matches("ms").trim().parse().ok(), - ParamId::Band1On | ParamId::Band2On | ParamId::Band3On | ParamId::Band4On => { - match text.to_ascii_lowercase().as_str() { - "on" | "1" => Some(1.0), - "off" | "0" => Some(0.0), - _ => text.parse().ok(), - } - } + _ => text.parse().ok(), } } @@ -489,19 +491,24 @@ mod tests { #[test] fn band_helpers_cover_all_bands() { for band in 0..crate::transient::dsp::MAX_BANDS { - assert_eq!(ParamId::band_on(band).as_index(), 9 + band * 3); - assert_eq!(ParamId::band_range(band).as_index(), 10 + band * 3); - assert_eq!(ParamId::band_sensitivity(band).as_index(), 11 + band * 3); + let base = if band < 4 { + 9 + band * 3 + } else { + 49 + (band - 4) * 3 + }; + assert_eq!(ParamId::band_on(band).as_index(), base); + assert_eq!(ParamId::band_range(band).as_index(), base + 1); + assert_eq!(ParamId::band_sensitivity(band).as_index(), base + 2); } } #[test] fn state_roundtrip_preserves_dynamic_bands() { let shared = SharedState::default(); - shared.params.set(ParamId::BandCount, 4.0); + shared.params.set(ParamId::BandCount, 32.0); shared.params.set(ParamId::Split2, 1800.0); shared.params.set(ParamId::Band3Range, -8.0); - shared.params.set(ParamId::Band4On, 0.0); + shared.params.set(ParamId::Band32On, 0.0); shared.params.set(ParamId::MasterSensitivity, 3.0); let bytes = PluginState::from_runtime(&shared.params) .to_bytes(STATE_HEADER_PREFIX) @@ -510,10 +517,10 @@ mod tests { PluginState::from_bytes(&bytes, STATE_HEADER_PREFIX) .expect("state should load") .apply(&restored.params); - assert_eq!(restored.params.get(ParamId::BandCount), 4.0); + assert_eq!(restored.params.get(ParamId::BandCount), 32.0); assert_eq!(restored.params.get(ParamId::Split2), 1800.0); assert_eq!(restored.params.get(ParamId::Band3Range), -8.0); - assert!(!restored.params.get_bool(ParamId::Band4On)); + assert!(!restored.params.get_bool(ParamId::Band32On)); assert_eq!(restored.params.get(ParamId::MasterSensitivity), 3.0); } } diff --git a/src/volume/plugin.rs b/src/volume/plugin.rs index 5c55991..2ccdb15 100644 --- a/src/volume/plugin.rs +++ b/src/volume/plugin.rs @@ -153,27 +153,27 @@ impl crate::common::SharedStateExt for SharedState { } } - fn take_pending_param_notifications(&self) -> u64 { + fn take_pending_param_notifications(&self) -> crate::common::ParamBits { self.core.take_pending_param_notifications() } - fn requeue_pending_param_notifications(&self, bits: u64) { + fn requeue_pending_param_notifications(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_param_notifications(bits); } - fn take_pending_gesture_begin(&self) -> u64 { + fn take_pending_gesture_begin(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_begin() } - fn requeue_pending_gesture_begin(&self, bits: u64) { + fn requeue_pending_gesture_begin(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_begin(bits); } - fn take_pending_gesture_end(&self) -> u64 { + fn take_pending_gesture_end(&self) -> crate::common::ParamBits { self.core.take_pending_gesture_end() } - fn requeue_pending_gesture_end(&self, bits: u64) { + fn requeue_pending_gesture_end(&self, bits: crate::common::ParamBits) { self.core.requeue_pending_gesture_end(bits); } }