bugfix: make clipper symmetrical

This commit is contained in:
Liam Kerr 2026-08-02 20:09:45 +01:00
parent 77c4851119
commit 6ccb93615f

View file

@ -10,7 +10,16 @@ void Clipper::process(const float *in, float *out, uint32_t frames) {
void Clipper::processStereo(const float *inLeft, const float *inRight, void Clipper::processStereo(const float *inLeft, const float *inRight,
float *outLeft, float *outRight, uint32_t frames) { float *outLeft, float *outRight, uint32_t frames) {
for (uint32_t i = 0; i < frames; ++i) { for (uint32_t i = 0; i < frames; ++i) {
if (outLeft[i] > 0) {
outLeft[i] = inLeft[i] > clip_ ? clip_ : inLeft[i]; outLeft[i] = inLeft[i] > clip_ ? clip_ : inLeft[i];
} else {
outLeft[i] = inLeft[i] < -clip_ ? -clip_ : inLeft[i];
}
if (outRight[i] > 0) {
outRight[i] = inRight[i] > clip_ ? clip_ : inRight[i]; outRight[i] = inRight[i] > clip_ ? clip_ : inRight[i];
} else {
outRight[i] = inRight[i] < -clip_ ? -clip_ : inRight[i];
}
} }
} }