diff --git a/crates/mix/src/lib.rs b/crates/mix/src/lib.rs index 355c237..ee40bda 100644 --- a/crates/mix/src/lib.rs +++ b/crates/mix/src/lib.rs @@ -2722,11 +2722,10 @@ mod tests { let mut eng = MixEngine::new(48_000.0, 512); eng.set_external_instances(true); let sets = Arc::new(std::sync::atomic::AtomicUsize::new(0)); - let make = |db: f32| { + let make = |blob: &[u8]| { let mut gain = soundcraft_dsp::create("gain").unwrap(); gain.prepare(48_000.0, 512, 1); - gain.set_param("gain", db); - Box::new(Stateful { inner: gain, sets: Arc::clone(&sets) }) + Box::new(Stateful { inner: gain, blob: blob.to_vec(), sets: Arc::clone(&sets) }) }; eng.adopt(vec![PreparedInstance { track: t, slot: 0, id: "clap:test.fake".into(), ch: 1, plugin: make(b"old") }]); render_block(&mut eng, &s, 0); diff --git a/crates/vst3-host/src/ffi.rs b/crates/vst3-host/src/ffi.rs index 007b425..ca10647 100644 --- a/crates/vst3-host/src/ffi.rs +++ b/crates/vst3-host/src/ffi.rs @@ -1587,48 +1587,6 @@ fn rect_size(r: &sb::ViewRect) -> (f64, f64) { (f64::from(w), f64::from(h)) } -/// Normalized values the host set (automation, the session) that the edit controller hasn't been -/// told yet, one slot per parameter. The audio thread fills a slot without locking or allocating; -/// [`EditorLink::save_state`] sends what is waiting before it reads the controller's state, so -/// values the controller keeps in its own state are saved as set. -pub(crate) struct ControllerPending { - ids: Vec, - slots: Vec, -} - -/// An empty slot: a NaN bit pattern, which `set` never stores. -const NO_VALUE: u64 = u64::MAX; - -impl ControllerPending { - pub fn new(ids: &[u32]) -> ControllerPending { - ControllerPending { ids: ids.to_vec(), slots: ids.iter().map(|_| AtomicU64::new(NO_VALUE)).collect() } - } - - /// Notes the value of parameter `i` (index into the plugin's parameter list). - pub fn set(&self, i: usize, n: f64) { - if let Some(s) = self.slots.get(i) - && n.is_finite() - { - s.store(n.clamp(0.0, 1.0).to_bits(), Ordering::Release); - } - } - - /// Forgets every waiting value (a loaded state replaces them). - pub fn clear(&self) { - for s in &self.slots { - s.store(NO_VALUE, Ordering::Release); - } - } - - /// Takes the waiting values as `(ParamID, normalized)`. - fn take(&self) -> impl Iterator + '_ { - self.ids.iter().zip(&self.slots).filter_map(|(&id, s)| { - let b = s.swap(NO_VALUE, Ordering::AcqRel); - (b != NO_VALUE).then(|| (id, f64::from_bits(b))) - }) - } -} - #[derive(Default)] struct EditorInner { /// `None` once the instance is gone. @@ -1638,8 +1596,6 @@ struct EditorInner { view: Option>, frame: Option>, window: Option, - /// Host-set values for the controller, sent before its state is read. - pending: Option>, } /// The link between an instance and its editor and state handles. The instance may process on @@ -1767,13 +1723,6 @@ impl EditorLink { pub fn save_state(&self) -> Option> { let g = self.lock(); let component = g.component.as_ref()?; - if let (Some(c), Some(p)) = (&g.controller, &g.pending) { - for (id, n) in p.take() { - // SAFETY: valid controller (cleared under this lock before the instance - // terminates); UI thread, as `getState` below. - unsafe { c.setParamNormalized(id, n) }; - } - } // SAFETY: valid component (the instance clears it under this lock before it terminates); // the stream lives in `read_state` for the whole call. let comp = Instance::read_state(|s| unsafe { component.getState(s) })?; @@ -1791,11 +1740,6 @@ impl EditorLink { Some(out) } - /// Shares the instance's table of host-set values with the state reader. - pub fn set_controller_pending(&self, p: Arc) { - self.lock().pending = Some(p); - } - /// Closes the editor. Main thread only (no-op elsewhere). pub fn close(&self) { if window::on_main_thread() { diff --git a/crates/vst3-host/src/plugin.rs b/crates/vst3-host/src/plugin.rs index 5cf9018..2975465 100644 --- a/crates/vst3-host/src/plugin.rs +++ b/crates/vst3-host/src/plugin.rs @@ -114,7 +114,6 @@ impl Vst3Plugin { }) .collect(); p.values = values; - p.inst.state_link().set_controller_pending(Arc::clone(&p.controller_pending)); p } @@ -235,7 +234,6 @@ impl Plugin for Vst3Plugin { } else if self.pending.len() < self.pending.capacity() { self.pending.push((vid, n)); } - self.controller_pending.set(i, n); true }