(&mut self, info: &ProcInfo, events: &mut ProcEvents, _extra: &mut ProcExtra)
| 272 | self.gain_l.reset_to_target(); |
| 273 | self.gain_r.reset_to_target(); |
| 274 | self.distance_attenuator.reset(); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | impl AudioNodeProcessor for Processor { |
| 279 | fn events(&mut self, info: &ProcInfo, events: &mut ProcEvents, _extra: &mut ProcExtra) { |
| 280 | let mut updated = false; |
| 281 | for mut patch in events.drain_patches::<SpatialBasicNode>() { |
| 282 | match &mut patch { |
| 283 | SpatialBasicNodePatch::Offset(offset) |
| 284 | if !(offset.x.is_finite() && offset.y.is_finite() && offset.z.is_finite()) => |
| 285 | { |
| 286 | *offset = Vec3::default(); |
| 287 | } |
| 288 | SpatialBasicNodePatch::PanningThreshold(threshold) => { |
| 289 | *threshold = threshold.clamp(0.0, 1.0); |
| 290 | } |
| 291 | SpatialBasicNodePatch::SmoothSeconds(seconds) => { |
| 292 | self.gain_l.set_smooth_seconds(*seconds, info.sample_rate); |
| 293 | self.gain_r.set_smooth_seconds(*seconds, info.sample_rate); |
| 294 | self.distance_attenuator |
| 295 | .set_smooth_seconds(*seconds, info.sample_rate); |
| 296 | } |
| 297 | SpatialBasicNodePatch::MinGain(g) => { |
| 298 | *g = g.clamp(0.0, 1.0); |
| 299 | } |
| 300 | SpatialBasicNodePatch::CoeffUpdateFactor(f) => { |
| 301 | self.distance_attenuator.set_coeff_update_factor(*f); |
| 302 | } |
| 303 | _ => {} |
| 304 | } |
| 305 | |
| 306 | self.params.apply(patch); |
| 307 | updated = true; |
| 308 | } |
| 309 | |
| 310 | if updated { |
| 311 | let computed_values = self.params.compute_values(); |
| 312 | |
| 313 | self.gain_l.set_value(computed_values.gain_l); |
| 314 | self.gain_r.set_value(computed_values.gain_r); |
| 315 | |
| 316 | self.distance_attenuator.compute_values( |
| 317 | computed_values.distance, |
| 318 | &self.params.distance_attenuation, |
| 319 | self.params.muffle_cutoff_hz, |
| 320 | self.params.min_gain, |
| 321 | ); |
| 322 | |
| 323 | if self.prev_input_settled { |
| 324 | // The previous block's input settled at zero, so no need to smooth. |
| 325 | self.reset(); |
| 326 | } |
nothing calls this directly
no test coverage detected