Skip to content

Commit f704a1b

Browse files
b-maorottier
authored andcommitted
refactor: clean dummy ConvolverRendererInner
1 parent 2fe4278 commit f704a1b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/node/constant_source.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ use super::{AudioNode, AudioScheduledSourceNode, ChannelConfig};
1111
// dictionary ConstantSourceOptions {
1212
// float offset = 1;
1313
// };
14+
// https://webaudio.github.io/web-audio-api/#ConstantSourceOptions
15+
//
1416
// @note - Does not extend AudioNodeOptions because AudioNodeOptions are
15-
// useless for source nodes as they instruct how to upmix the inputs.
16-
// This is a common source of confusion, see e.g. https://github.com/mdn/content/pull/18472
17-
>>>>>>> 83a0107 (refactor: renaming variables)
17+
// useless for source nodes, because they instruct how to upmix the inputs.
18+
// This is a common source of confusion, see e.g. mdn/content#18472
1819
#[derive(Clone, Debug)]
1920
pub struct ConstantSourceOptions {
2021
/// Initial parameter value of the constant signal

src/node/convolver.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::RENDER_QUANTUM_SIZE;
1212
use super::{AudioNode, ChannelConfig, ChannelConfigOptions, ChannelInterpretation};
1313

1414
/// Scale buffer by an equal-power normalization
15-
fn normalization(buffer: &AudioBuffer) -> f32 {
15+
// see - <https://webaudio.github.io/web-audio-api/#dom-convolvernode-normalize>
16+
fn normalize_buffer(buffer: &AudioBuffer) -> f32 {
1617
let gain_calibration = 0.00125;
1718
let gain_calibration_sample_rate = 44100.;
1819
let min_power = 0.000125;
@@ -198,7 +199,7 @@ impl ConvolverNode {
198199

199200
// normalize before padding because the length of the buffer affects the scale
200201
let scale = if self.normalize() {
201-
normalization(&buffer)
202+
normalize_buffer(&buffer)
202203
} else {
203204
1.
204205
};
@@ -346,9 +347,13 @@ impl ConvolverRendererInner {
346347

347348
// dummy convolver used to init renderer
348349
fn tombstone() -> Self {
349-
// just use arbitrary common sample rate
350-
let padded_buffer = AudioBuffer::from(vec![vec![0.; 0]; 1], 48000.);
351-
Self::new(padded_buffer)
350+
Self {
351+
num_ir_blocks: Default::default(),
352+
h: Default::default(),
353+
fdl: Default::default(),
354+
out: Default::default(),
355+
fft2: Fft::new(0),
356+
}
352357
}
353358

354359
fn process(&mut self, input: &[f32], output: &mut [f32]) {

0 commit comments

Comments
 (0)