more engines
This commit is contained in:
@ -233,6 +233,23 @@ export class DubSiren implements SynthEngine<DubSirenParams> {
|
||||
lfoPhaseR = (lfoPhaseR + lfoIncrement) % TAU;
|
||||
}
|
||||
|
||||
// Peak normalization with headroom
|
||||
let peakL = 0;
|
||||
let peakR = 0;
|
||||
for (let i = 0; i < numSamples; i++) {
|
||||
peakL = Math.max(peakL, Math.abs(leftBuffer[i]));
|
||||
peakR = Math.max(peakR, Math.abs(rightBuffer[i]));
|
||||
}
|
||||
const peak = Math.max(peakL, peakR);
|
||||
|
||||
if (peak > 0.001) {
|
||||
const normalizeGain = 0.85 / peak;
|
||||
for (let i = 0; i < numSamples; i++) {
|
||||
leftBuffer[i] *= normalizeGain;
|
||||
rightBuffer[i] *= normalizeGain;
|
||||
}
|
||||
}
|
||||
|
||||
return [leftBuffer, rightBuffer];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user