Skip to content

Commit 9ef9f4f

Browse files
committed
perf(engine): process the amp chain per-block
Both engine paths looped chain.process(sample) one sample at a time, even though AmplifierChain::process_block and the Stage::process_block trait method already existed. Call process_block instead so per-stage work (bypass branch, stage-list walk) happens once per block rather than once per sample, and so stages with batched process_block overrides are actually exercised. Measured on the analog chain: ~31% faster at 1x oversampling, converging to parity as oversampling rises and real DSP work dominates loop overhead.
1 parent a8cc930 commit 9ef9f4f

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

rustortion-core/src/audio/engine.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ impl Engine {
202202
}
203203

204204
fn process_without_upsampling(&mut self, output: &mut [f32]) -> Result<()> {
205-
let chain = self.chain.as_mut();
206-
for s in output.iter_mut() {
207-
*s = chain.process(*s);
208-
}
205+
self.chain.as_mut().process_block(output);
209206

210207
Ok(())
211208
}
@@ -215,10 +212,7 @@ impl Engine {
215212

216213
let upsampled = self.samplers.upsample()?;
217214

218-
let chain = self.chain.as_mut();
219-
for s in upsampled.iter_mut() {
220-
*s = chain.process(*s);
221-
}
215+
self.chain.as_mut().process_block(upsampled);
222216

223217
let downsampled = self.samplers.downsample()?;
224218

0 commit comments

Comments
 (0)