1
0
Fork 0

Remove the mandatory VST3 output bus

This doesn't seem to be necessary anymore. Perhaps this was just an
incorrect check for parameter flushes.
This commit is contained in:
Robbert van der Helm 2023-02-26 01:05:50 +01:00
parent e41a1b94b5
commit d2b7970991

View file

@ -114,10 +114,11 @@ impl<P: Vst3Plugin> IComponent for Wrapper<P> {
x if x == vst3_sys::vst::MediaTypes::kAudio as i32 x if x == vst3_sys::vst::MediaTypes::kAudio as i32
&& dir == vst3_sys::vst::BusDirections::kOutput as i32 => && dir == vst3_sys::vst::BusDirections::kOutput as i32 =>
{ {
// HACK: Bitwig will not call the process function at all if the plugin does not have any let main_busses = if current_audio_io_layout.main_output_channels.is_some() {
// audio IO, so we'll add a zero channel output to work around this if that is the 1
// case } else {
let main_busses = 1; 0
};
let aux_busses = current_audio_io_layout.aux_output_ports.len() as i32; let aux_busses = current_audio_io_layout.aux_output_ports.len() as i32;
main_busses + aux_busses main_busses + aux_busses
@ -198,12 +199,10 @@ impl<P: Vst3Plugin> IComponent for Wrapper<P> {
info.direction = dir; info.direction = dir;
info.flags = vst3_sys::vst::BusFlags::kDefaultActive as u32; info.flags = vst3_sys::vst::BusFlags::kDefaultActive as u32;
// HACK: Bitwig will not call the process function at all if the plugin does not have any let has_main_output = current_audio_io_layout.main_output_channels.is_some();
// audio IO, so we'll add a zero channel output to work around this if that is the let aux_output_start_idx = if has_main_output { 1 } else { 0 };
// case
let aux_output_start_idx = 1;
let aux_output_idx = (index - aux_output_start_idx).max(0) as usize; let aux_output_idx = (index - aux_output_start_idx).max(0) as usize;
if index == 0 { if index == 0 && has_main_output {
info.bus_type = vst3_sys::vst::BusTypes::kMain as i32; info.bus_type = vst3_sys::vst::BusTypes::kMain as i32;
// NOTE: See above, this becomes a 0 channel output if the plugin doesn't have a // NOTE: See above, this becomes a 0 channel output if the plugin doesn't have a
// main output // main output
@ -340,10 +339,11 @@ impl<P: Vst3Plugin> IComponent for Wrapper<P> {
if t == vst3_sys::vst::MediaTypes::kAudio as i32 if t == vst3_sys::vst::MediaTypes::kAudio as i32
&& d == vst3_sys::vst::BusDirections::kOutput as i32 => && d == vst3_sys::vst::BusDirections::kOutput as i32 =>
{ {
// HACK: Bitwig will not call the process function at all if the plugin does not have any let main_busses = if current_audio_io_layout.main_output_channels.is_some() {
// audio IO, so we'll add a zero channel output to work around this if that is the 1
// case } else {
let main_busses = 1; 0
};
let aux_busses = current_audio_io_layout.aux_output_ports.len() as i32; let aux_busses = current_audio_io_layout.aux_output_ports.len() as i32;
if (0..main_busses + aux_busses).contains(&index) { if (0..main_busses + aux_busses).contains(&index) {
@ -795,10 +795,11 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
} else { } else {
0 0
} + layout.aux_input_ports.len(); } + layout.aux_input_ports.len();
// HACK: Bitwig will not call the process function at all if the plugin does not let num_layout_outs = if layout.main_output_channels.is_some() {
// have any audio IO, so we'll add a zero channel output to work around this 1
// if that is the case } else {
let num_layout_outs = 1 + layout.aux_input_ports.len(); 0
} + layout.aux_output_ports.len();
if num_ins as usize != num_layout_ins || num_outs as usize != num_layout_outs { if num_ins as usize != num_layout_ins || num_outs as usize != num_layout_outs {
return false; return false;
} }
@ -820,8 +821,8 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
} }
} }
// See above, there is always a main output let has_main_output = layout.main_output_channels.is_some();
let aux_output_start_idx = 1; let aux_output_start_idx = if has_main_output { 0 } else { 1 };
if (*outputs).count_ones() if (*outputs).count_ones()
!= layout != layout
.main_output_channels .main_output_channels
@ -892,12 +893,10 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
return kInvalidArgument; return kInvalidArgument;
} }
} else if dir == vst3_sys::vst::BusDirections::kOutput as i32 { } else if dir == vst3_sys::vst::BusDirections::kOutput as i32 {
// HACK: Bitwig will not call the process function at all if the plugin does not have any let has_main_output = current_audio_io_layout.main_output_channels.is_some();
// audio IO, so we'll add a zero channel output to work around this if that is the let aux_output_start_idx = if has_main_output { 1 } else { 0 };
// case
let aux_output_start_idx = 1;
let aux_output_idx = (index - aux_output_start_idx).max(0) as usize; let aux_output_idx = (index - aux_output_start_idx).max(0) as usize;
if index == 0 { if index == 0 && has_main_output {
current_audio_io_layout.main_output_channels.unwrap().get() current_audio_io_layout.main_output_channels.unwrap().get()
} else if aux_output_idx < current_audio_io_layout.aux_output_ports.len() { } else if aux_output_idx < current_audio_io_layout.aux_output_ports.len() {
current_audio_io_layout.aux_output_ports[aux_output_idx].get() current_audio_io_layout.aux_output_ports[aux_output_idx].get()
@ -1026,11 +1025,11 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
let current_audio_io_layout = self.inner.current_audio_io_layout.load(); let current_audio_io_layout = self.inner.current_audio_io_layout.load();
let has_main_input = current_audio_io_layout.main_input_channels.is_some(); let has_main_input = current_audio_io_layout.main_input_channels.is_some();
let has_main_output = current_audio_io_layout.main_output_channels.is_some(); let has_main_output = current_audio_io_layout.main_output_channels.is_some();
let aux_input_start_idx = if has_main_input { 1 } else { 0 };
let aux_output_start_idx = if has_main_output { 1 } else { 0 };
if !data.outputs.is_null() { if !data.outputs.is_null() {
// HACK: Bitwig requires VST3 plugins to always have a main output. We'll however for output_idx in aux_output_start_idx..data.num_outputs as usize {
// still use this variable here to maintain consistency between the backends. let host_output = data.outputs.add(output_idx);
for output_idx in 1..data.num_outputs as isize {
let host_output = data.outputs.offset(output_idx);
if !(*host_output).buffers.is_null() { if !(*host_output).buffers.is_null() {
for channel_idx in 0..(*host_output).num_channels as isize { for channel_idx in 0..(*host_output).num_channels as isize {
ptr::write_bytes( ptr::write_bytes(
@ -1367,18 +1366,14 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
// the `aux` parameter on the `process()` function. // the `aux` parameter on the `process()` function.
let mut aux_input_storage = self.inner.aux_input_storage.borrow_mut(); let mut aux_input_storage = self.inner.aux_input_storage.borrow_mut();
let mut aux_input_buffers = self.inner.aux_input_buffers.borrow_mut(); let mut aux_input_buffers = self.inner.aux_input_buffers.borrow_mut();
for (auxiliary_input_idx, (storage, buffer)) in aux_input_storage for (aux_input_idx, (storage, buffer)) in aux_input_storage
.iter_mut() .iter_mut()
.zip(aux_input_buffers.iter_mut()) .zip(aux_input_buffers.iter_mut())
.enumerate() .enumerate()
{ {
let host_input_idx = if has_main_input { let host_input_idx = aux_input_start_idx + aux_input_idx;
auxiliary_input_idx as isize + 1 let host_input = data.inputs.add(host_input_idx);
} else { if host_input_idx >= data.num_inputs as usize
auxiliary_input_idx as isize
};
let host_input = data.inputs.offset(host_input_idx);
if host_input_idx >= data.num_inputs as isize
|| data.inputs.is_null() || data.inputs.is_null()
|| (*host_input).buffers.is_null() || (*host_input).buffers.is_null()
// Would only happen if the user configured zero channels for the // Would only happen if the user configured zero channels for the
@ -1386,7 +1381,7 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
|| storage.is_empty() || storage.is_empty()
|| (*host_input).num_channels != buffer.channels() as i32 || (*host_input).num_channels != buffer.channels() as i32
{ {
nih_debug_assert!(host_input_idx < data.num_inputs as isize); nih_debug_assert!(host_input_idx < data.num_inputs as usize);
nih_debug_assert!(!data.inputs.is_null()); nih_debug_assert!(!data.inputs.is_null());
nih_debug_assert!(!(*host_input).buffers.is_null()); nih_debug_assert!(!(*host_input).buffers.is_null());
nih_debug_assert!(!storage.is_empty()); nih_debug_assert!(!storage.is_empty());
@ -1429,17 +1424,15 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
// And the same thing for auxiliary output buffers // And the same thing for auxiliary output buffers
let mut aux_output_buffers = self.inner.aux_output_buffers.borrow_mut(); let mut aux_output_buffers = self.inner.aux_output_buffers.borrow_mut();
for (auxiliary_output_idx, buffer) in aux_output_buffers.iter_mut().enumerate() { for (aux_output_idx, buffer) in aux_output_buffers.iter_mut().enumerate() {
// HACK: Bitwig requires VST3 plugins to always have a main output. We'll however still let host_output_idx = aux_output_start_idx + aux_output_idx;
// use this variable here to maintain consistency between the backends. let host_output = data.outputs.add(host_output_idx);
let host_output_idx = auxiliary_output_idx as isize + 1; if host_output_idx >= data.num_outputs as usize
let host_output = data.outputs.offset(host_output_idx);
if host_output_idx >= data.num_outputs as isize
|| data.outputs.is_null() || data.outputs.is_null()
|| (*host_output).buffers.is_null() || (*host_output).buffers.is_null()
|| buffer.channels() == 0 || buffer.channels() == 0
{ {
nih_debug_assert!(host_output_idx < data.num_outputs as isize); nih_debug_assert!(host_output_idx < data.num_outputs as usize);
nih_debug_assert!(!data.outputs.is_null()); nih_debug_assert!(!data.outputs.is_null());
nih_debug_assert!(!(*host_output).buffers.is_null()); nih_debug_assert!(!(*host_output).buffers.is_null());