From c115d129c7aa91bbc9e8a69ae4d7bb2591acf479 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Wed, 24 Jun 2026 20:50:40 +0200 Subject: [PATCH] fix: Assert in input peak calculation Fixes #405 --- src/core/afv/audio/input.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/afv/audio/input.cpp b/src/core/afv/audio/input.cpp index eb8f82ac8..97998e059 100644 --- a/src/core/afv/audio/input.cpp +++ b/src/core/afv/audio/input.cpp @@ -170,8 +170,11 @@ namespace swift::core::afv::audio if (value < std::numeric_limits::min()) value = std::numeric_limits::min(); sample = static_cast(value); - qint16 sampleInput = qAbs(sample); - m_maxSampleInput = qMax(sampleInput, m_maxSampleInput); // qAbs entfernt! + // qAbs(qint16::min()) would assert because +32768 cannot be represented + // as a qint16. For peak detection, saturate this edge case to qint16::max(). + const qint16 sampleInput = + sample != std::numeric_limits::min() ? qAbs(sample) : std::numeric_limits::max(); + m_maxSampleInput = qMax(sampleInput, m_maxSampleInput); } int length {};