From 155440b13cf76f43b8d353fa45e9dadac740ee3e Mon Sep 17 00:00:00 2001 From: saker Date: Thu, 4 Jul 2024 04:32:43 -0400 Subject: [PATCH] Fix types --- .../AudioFileProcessorWaveView.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp index 03889a59a6a..2345c02a628 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp @@ -45,7 +45,7 @@ void AudioFileProcessorWaveView::updateSampleRange() { if (m_sample->sampleSize() > 1) { - const f_cnt_t marging = (m_sample->endFrame() - m_sample->startFrame()) * 0.1; + const auto marging = (m_sample->endFrame() - m_sample->startFrame()) * 0.1; setFrom(m_sample->startFrame() - marging); setTo(m_sample->endFrame() + marging); } @@ -53,7 +53,7 @@ void AudioFileProcessorWaveView::updateSampleRange() void AudioFileProcessorWaveView::setTo(f_cnt_t to) { - m_to = std::min(to, static_cast(m_sample->sampleSize())); + m_to = std::min(to, static_cast(m_sample->sampleSize())); } void AudioFileProcessorWaveView::setFrom(f_cnt_t from) @@ -375,17 +375,13 @@ void AudioFileProcessorWaveView::zoom(const bool out) void AudioFileProcessorWaveView::slide(int px) { - const double fact = qAbs(double(px) / width()); - f_cnt_t step = range() * fact; - if (px > 0) - { - step = -step; - } - - f_cnt_t step_from = qBound(0, m_from + step, m_sample->sampleSize()) - m_from; - f_cnt_t step_to = qBound(m_from + 1, m_to + step, m_sample->sampleSize()) - m_to; + const auto fact = std::abs(static_cast(px) / width()); + auto step = static_cast(range() * fact); + if (px > 0) { step = -step; } - step = qAbs(step_from) < qAbs(step_to) ? step_from : step_to; + const auto stepFrom = std::clamp(m_from + step, 0, m_sample->sampleSize()) - static_cast(m_from); + const auto stepTo = std::clamp(m_to + step, m_from + 1, m_sample->sampleSize()) - static_cast(m_to); + step = std::abs(stepFrom) < std::abs(stepTo) ? stepFrom : stepTo; setFrom(m_from + step); setTo(m_to + step);