Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Jul 4, 2024
1 parent fb994ad commit 155440b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions plugins/AudioFileProcessor/AudioFileProcessorWaveView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ 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);
}
}

void AudioFileProcessorWaveView::setTo(f_cnt_t to)
{
m_to = std::min(to, static_cast<lmms::f_cnt_t>(m_sample->sampleSize()));
m_to = std::min(to, static_cast<f_cnt_t>(m_sample->sampleSize()));
}

void AudioFileProcessorWaveView::setFrom(f_cnt_t from)
Expand Down Expand Up @@ -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<size_t>(0, m_from + step, m_sample->sampleSize()) - m_from;
f_cnt_t step_to = qBound<size_t>(m_from + 1, m_to + step, m_sample->sampleSize()) - m_to;
const auto fact = std::abs(static_cast<double>(px) / width());
auto step = static_cast<int>(range() * fact);
if (px > 0) { step = -step; }

step = qAbs(step_from) < qAbs(step_to) ? step_from : step_to;
const auto stepFrom = std::clamp<int>(m_from + step, 0, m_sample->sampleSize()) - static_cast<int>(m_from);
const auto stepTo = std::clamp<int>(m_to + step, m_from + 1, m_sample->sampleSize()) - static_cast<int>(m_to);
step = std::abs(stepFrom) < std::abs(stepTo) ? stepFrom : stepTo;

setFrom(m_from + step);
setTo(m_to + step);
Expand Down

0 comments on commit 155440b

Please sign in to comment.