{
pub fn new() -> Box {
match (dir, index) {
(d, 0) if d == vst3_sys::vst::BusDirections::kInput as i32 => {
info.direction = vst3_sys::vst::BusDirections::kInput as i32;
- info.channel_count = self.current_bus_config.num_input_channels as i32;
+ info.channel_count =
+ self.current_bus_config.borrow().num_input_channels as i32;
u16strlcpy(&mut info.name, "Input");
kResultOk
}
(d, 0) if d == vst3_sys::vst::BusDirections::kOutput as i32 => {
info.direction = vst3_sys::vst::BusDirections::kOutput as i32;
- info.channel_count = self.current_bus_config.num_output_channels as i32;
+ info.channel_count =
+ self.current_bus_config.borrow().num_output_channels as i32;
u16strlcpy(&mut info.name, "Output");
kResultOk
@@ -371,27 +374,65 @@ impl {
}
unsafe fn normalized_param_to_plain(&self, id: u32, value_normalized: f64) -> f64 {
- todo!()
+ if id == *BYPASS_PARAM_HASH {
+ value_normalized
+ } else if let Some(param_id) = self.param_id_hashes.get(&id) {
+ let param_ptr = &self.param_map[param_id];
+ param_ptr.preview_unnormalized(value_normalized as f32) as f64
+ } else {
+ 0.5
+ }
}
unsafe fn plain_param_to_normalized(&self, id: u32, plain_value: f64) -> f64 {
- todo!()
+ if id == *BYPASS_PARAM_HASH {
+ plain_value.clamp(0.0, 1.0)
+ } else if let Some(param_id) = self.param_id_hashes.get(&id) {
+ let param_ptr = &self.param_map[param_id];
+ param_ptr.preview_normalized(plain_value as f32) as f64
+ } else {
+ 0.5
+ }
}
unsafe fn get_param_normalized(&self, id: u32) -> f64 {
- todo!()
+ if id == *BYPASS_PARAM_HASH {
+ if self.bypass_state.get() {
+ 1.0
+ } else {
+ 0.0
+ }
+ } else if let Some(param_id) = self.param_id_hashes.get(&id) {
+ let param_ptr = &self.param_map[param_id];
+ param_ptr.normalized_value() as f64
+ } else {
+ 0.5
+ }
}
unsafe fn set_param_normalized(&self, id: u32, value: f64) -> tresult {
- todo!()
+ if id == *BYPASS_PARAM_HASH {
+ self.bypass_state.set(value >= 0.5);
+
+ kResultOk
+ } else if let Some(param_id) = self.param_id_hashes.get(&id) {
+ let param_ptr = &self.param_map[param_id];
+ param_ptr.set_normalized_value(value as f32);
+
+ kResultOk
+ } else {
+ kInvalidArgument
+ }
}
- unsafe fn set_component_handler(&self, handler: *mut c_void) -> tresult {
- todo!()
+ unsafe fn set_component_handler(&self, _handler: *mut c_void) -> tresult {
+ // TODO: Use this when we add GUI support
+ kResultOk
}
- unsafe fn create_view(&self, name: vst3_sys::base::FIDString) -> *mut c_void {
- todo!()
+ unsafe fn create_view(&self, _name: vst3_sys::base::FIDString) -> *mut c_void {
+ // We currently don't support GUIs
+ std::ptr::null_mut()
}
}