1
0
Fork 0

Update local parameters when changing from GUI

This commit is contained in:
Robbert van der Helm 2022-02-05 22:26:21 +01:00
parent 83c3410736
commit 7b14106505

View file

@ -221,6 +221,13 @@ impl<P: Plugin> GuiContext for WrapperInner<P> {
match &*self.component_handler.read() { match &*self.component_handler.read() {
Some(handler) => match self.param_ptr_to_hash.get(&param) { Some(handler) => match self.param_ptr_to_hash.get(&param) {
Some(hash) => { Some(hash) => {
// XXX: The host will also report this value to the plugin, this may cause fun
// behaviour with rapid parameter changes. How does JUCE handle this?
self.set_normalized_value_by_hash(
*hash,
normalized,
self.current_buffer_config.load().map(|c| c.sample_rate),
);
handler.perform_edit(*hash, normalized as f64); handler.perform_edit(*hash, normalized as f64);
} }
None => nih_debug_assert_failure!("Unknown parameter: {:?}", param), None => nih_debug_assert_failure!("Unknown parameter: {:?}", param),
@ -377,7 +384,7 @@ impl<P: Plugin> WrapperInner<P> {
unsafe fn set_normalized_value_by_hash( unsafe fn set_normalized_value_by_hash(
&self, &self,
hash: u32, hash: u32,
normalized_value: f64, normalized_value: f32,
sample_rate: Option<f32>, sample_rate: Option<f32>,
) -> tresult { ) -> tresult {
if hash == *BYPASS_PARAM_HASH { if hash == *BYPASS_PARAM_HASH {
@ -389,10 +396,10 @@ impl<P: Plugin> WrapperInner<P> {
// Also update the parameter's smoothing if applicable // Also update the parameter's smoothing if applicable
match (param_ptr, sample_rate) { match (param_ptr, sample_rate) {
(_, Some(sample_rate)) => { (_, Some(sample_rate)) => {
param_ptr.set_normalized_value(normalized_value as f32); param_ptr.set_normalized_value(normalized_value);
param_ptr.update_smoother(sample_rate, false); param_ptr.update_smoother(sample_rate, false);
} }
_ => param_ptr.set_normalized_value(normalized_value as f32), _ => param_ptr.set_normalized_value(normalized_value),
} }
kResultOk kResultOk
@ -946,7 +953,7 @@ impl<P: Plugin> IEditController for Wrapper<P> {
.load() .load()
.map(|c| c.sample_rate); .map(|c| c.sample_rate);
self.inner self.inner
.set_normalized_value_by_hash(id, value, sample_rate) .set_normalized_value_by_hash(id, value as f32, sample_rate)
} }
unsafe fn set_component_handler( unsafe fn set_component_handler(
@ -1143,8 +1150,11 @@ impl<P: Plugin> IAudioProcessor for Wrapper<P> {
&mut value, &mut value,
) == kResultOk ) == kResultOk
{ {
self.inner self.inner.set_normalized_value_by_hash(
.set_normalized_value_by_hash(param_hash, value, sample_rate); param_hash,
value as f32,
sample_rate,
);
} }
} }
} }