commit bba382726f4f4111105fc170d50c9fc0d5d49443
parent 678bea0719705881ed4467ab26cdfbc6b3e25a34
Author: Matt Demanett <matt@demanett.net>
Date: Sun, 20 May 2018 21:38:40 -0500
Additator: fix nomrmalization (gain knob) to make output level reasonable. #14
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/Additator.cpp b/src/Additator.cpp
@@ -111,9 +111,11 @@ void Additator::step() {
total += as[i];
}
}
- total /= _amplitudeNormalization;
+ float norm = std::max(_partials / (float)_oscillator.partialCount(), 0.1f);
+ norm = 1.0f + (_amplitudeNormalization - 1.0f) * norm;
+ norm = std::max(total / norm, 0.7f);
for (int i = 1, n = _oscillator.partialCount(); i <= n; ++i) {
- as[i] /= total;
+ as[i] /= norm;
_oscillator.setPartialAmplitude(i, as[i], i <= envelopes);
}
}