Support VST3 parameter flushes
This commit is contained in:
parent
6ddae6a506
commit
16238f1e00
1 changed files with 34 additions and 31 deletions
|
@ -733,11 +733,44 @@ impl<P: Plugin> IAudioProcessor for Wrapper<'_, P> {
|
||||||
unsafe fn process(&self, data: *mut vst3_sys::vst::ProcessData) -> tresult {
|
unsafe fn process(&self, data: *mut vst3_sys::vst::ProcessData) -> tresult {
|
||||||
check_null_ptr!(data);
|
check_null_ptr!(data);
|
||||||
|
|
||||||
|
// We need to handle incoming automation first
|
||||||
|
let data = &*data;
|
||||||
|
if let Some(param_changes) = data.input_param_changes.upgrade() {
|
||||||
|
let num_param_queues = param_changes.get_parameter_count();
|
||||||
|
for change_queue_idx in 0..num_param_queues {
|
||||||
|
if let Some(param_change_queue) =
|
||||||
|
param_changes.get_parameter_data(change_queue_idx).upgrade()
|
||||||
|
{
|
||||||
|
let param_hash = param_change_queue.get_parameter_id();
|
||||||
|
let num_changes = param_change_queue.get_point_count();
|
||||||
|
|
||||||
|
// TODO: Handle sample accurate parameter changes, possibly in a similar way to
|
||||||
|
// the smoothing
|
||||||
|
let mut sample_offset = 0i32;
|
||||||
|
let mut value = 0.0f64;
|
||||||
|
if num_changes > 0
|
||||||
|
&& param_change_queue.get_point(
|
||||||
|
num_changes - 1,
|
||||||
|
&mut sample_offset,
|
||||||
|
&mut value,
|
||||||
|
) == kResultOk
|
||||||
|
{
|
||||||
|
self.set_normalized_value_by_hash(param_hash, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's possible the host only wanted to send new parameter values
|
||||||
|
if data.num_outputs == 0 {
|
||||||
|
nih_log!("VST3 parameter flush");
|
||||||
|
return kResultOk;
|
||||||
|
}
|
||||||
|
|
||||||
// The setups we suppport are:
|
// The setups we suppport are:
|
||||||
// - 1 input bus
|
// - 1 input bus
|
||||||
// - 1 output bus
|
// - 1 output bus
|
||||||
// - 1 input bus and 1 output bus
|
// - 1 input bus and 1 output bus
|
||||||
let data = &*data;
|
|
||||||
nih_debug_assert!(
|
nih_debug_assert!(
|
||||||
data.num_inputs >= 0
|
data.num_inputs >= 0
|
||||||
&& data.num_inputs <= 1
|
&& data.num_inputs <= 1
|
||||||
|
@ -750,10 +783,6 @@ impl<P: Plugin> IAudioProcessor for Wrapper<'_, P> {
|
||||||
vst3_sys::vst::SymbolicSampleSizes::kSample32 as i32
|
vst3_sys::vst::SymbolicSampleSizes::kSample32 as i32
|
||||||
);
|
);
|
||||||
nih_debug_assert!(data.num_samples >= 0);
|
nih_debug_assert!(data.num_samples >= 0);
|
||||||
if data.num_outputs < 1 {
|
|
||||||
nih_debug_assert_failure!("The host doesn't provide any outputs");
|
|
||||||
return kInvalidArgument;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This vector has been reallocated to contain enough slices as there are output channels
|
// This vector has been reallocated to contain enough slices as there are output channels
|
||||||
let mut output_slices = self.output_slices.borrow_mut();
|
let mut output_slices = self.output_slices.borrow_mut();
|
||||||
|
@ -796,32 +825,6 @@ impl<P: Plugin> IAudioProcessor for Wrapper<'_, P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(param_changes) = data.input_param_changes.upgrade() {
|
|
||||||
let num_param_queues = param_changes.get_parameter_count();
|
|
||||||
for change_queue_idx in 0..num_param_queues {
|
|
||||||
if let Some(param_change_queue) =
|
|
||||||
param_changes.get_parameter_data(change_queue_idx).upgrade()
|
|
||||||
{
|
|
||||||
let param_hash = param_change_queue.get_parameter_id();
|
|
||||||
let num_changes = param_change_queue.get_point_count();
|
|
||||||
|
|
||||||
// TODO: Handle sample accurate parameter changes, possibly in a similar way to
|
|
||||||
// the smoothing
|
|
||||||
let mut sample_offset = 0i32;
|
|
||||||
let mut value = 0.0f64;
|
|
||||||
if num_changes > 0
|
|
||||||
&& param_change_queue.get_point(
|
|
||||||
num_changes - 1,
|
|
||||||
&mut sample_offset,
|
|
||||||
&mut value,
|
|
||||||
) == kResultOk
|
|
||||||
{
|
|
||||||
self.set_normalized_value_by_hash(param_hash, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.plugin.borrow_mut().process(&mut output_slices) {
|
match self.plugin.borrow_mut().process(&mut output_slices) {
|
||||||
ProcessStatus::Error(err) => {
|
ProcessStatus::Error(err) => {
|
||||||
nih_debug_assert_failure!("Process error: {}", err);
|
nih_debug_assert_failure!("Process error: {}", err);
|
||||||
|
|
Loading…
Add table
Reference in a new issue