MCPcopy Create free account
hub / github.com/BillyDM/Firewheel / compute_values

Method compute_values

crates/firewheel-nodes/src/spatial_basic.rs:164–196  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

162 self.volume = Volume::Decibels(decibels);
163 }
164
165 fn compute_values(&self) -> ComputedValues {
166 let x2_z2 = (self.offset.x * self.offset.x) + (self.offset.z * self.offset.z);
167 let xz_distance = x2_z2.sqrt();
168 let distance = (x2_z2 + (self.offset.y * self.offset.y)).sqrt();
169
170 let pan = if xz_distance > 0.0 {
171 (self.offset.x / xz_distance) * self.panning_threshold.clamp(0.0, 1.0)
172 } else {
173 0.0
174 };
175 let (pan_gain_l, pan_gain_r) = FadeCurve::EqualPower3dB.compute_gains_neg1_to_1(pan);
176
177 let mut volume_gain = self.volume.amp();
178 if volume_gain > 0.99999 && volume_gain < 1.00001 {
179 volume_gain = 1.0;
180 }
181
182 let mut gain_l = pan_gain_l * volume_gain;
183 let mut gain_r = pan_gain_r * volume_gain;
184
185 if gain_l <= self.min_gain {
186 gain_l = 0.0;
187 }
188 if gain_r <= self.min_gain {
189 gain_r = 0.0;
190 }
191
192 ComputedValues {
193 distance,
194 gain_l,
195 gain_r,
196 }
197 }
198}
199

Callers 2

construct_processorMethod · 0.45
eventsMethod · 0.45

Calls 3

clampMethod · 0.80
ampMethod · 0.80

Tested by

no test coverage detected