Fix sliding of waveform when drawing sample in reverse (#7063)
This commit is contained in:
@@ -719,7 +719,7 @@ void AudioFileProcessorWaveView::updateSampleRange()
|
||||
{
|
||||
const f_cnt_t marging = (m_sample->endFrame() - m_sample->startFrame()) * 0.1;
|
||||
m_from = qMax(0, m_sample->startFrame() - marging);
|
||||
m_to = qMin(m_sample->endFrame() + marging, m_sample->sampleSize());
|
||||
m_to = qMin<size_t>(m_sample->endFrame() + marging, m_sample->sampleSize());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,7 +1014,11 @@ void AudioFileProcessorWaveView::updateGraph()
|
||||
m_graph.fill( Qt::transparent );
|
||||
QPainter p( &m_graph );
|
||||
p.setPen( QColor( 255, 255, 255 ) );
|
||||
SampleWaveform::visualize(*m_sample, p, QRect(0, 0, m_graph.width(), m_graph.height()), m_from, m_to);
|
||||
|
||||
const auto rect = QRect{0, 0, m_graph.width(), m_graph.height()};
|
||||
const auto waveform = SampleWaveform::Parameters{
|
||||
m_sample->data() + m_from, static_cast<size_t>(m_to - m_from), m_sample->amplification(), m_sample->reversed()};
|
||||
SampleWaveform::visualize(waveform, p, rect);
|
||||
}
|
||||
|
||||
|
||||
@@ -1076,8 +1080,8 @@ void AudioFileProcessorWaveView::slide( int _px )
|
||||
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;
|
||||
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;
|
||||
|
||||
step = qAbs( step_from ) < qAbs( step_to ) ? step_from : step_to;
|
||||
|
||||
|
||||
@@ -89,9 +89,10 @@ void SlicerTWaveform::drawSeekerWaveform()
|
||||
QPainter brush(&m_seekerWaveform);
|
||||
brush.setPen(s_waveformColor);
|
||||
|
||||
SampleWaveform::visualize(m_slicerTParent->m_originalSample, brush,
|
||||
QRect(0, 0, m_seekerWaveform.width(), m_seekerWaveform.height()), 0,
|
||||
m_slicerTParent->m_originalSample.sampleSize());
|
||||
const auto& sample = m_slicerTParent->m_originalSample;
|
||||
const auto waveform = SampleWaveform::Parameters{sample.data(), sample.sampleSize(), sample.amplification(), sample.reversed()};
|
||||
const auto rect = QRect(0, 0, m_seekerWaveform.width(), m_seekerWaveform.height());
|
||||
SampleWaveform::visualize(waveform, brush, rect);
|
||||
|
||||
// increase brightness in inner color
|
||||
QBitmap innerMask = m_seekerWaveform.createMaskFromColor(s_waveformMaskColor, Qt::MaskMode::MaskOutColor);
|
||||
@@ -139,14 +140,16 @@ void SlicerTWaveform::drawEditorWaveform()
|
||||
if (m_slicerTParent->m_originalSample.sampleSize() <= 1) { return; }
|
||||
|
||||
QPainter brush(&m_editorWaveform);
|
||||
float startFrame = m_seekerStart * m_slicerTParent->m_originalSample.sampleSize();
|
||||
float endFrame = m_seekerEnd * m_slicerTParent->m_originalSample.sampleSize();
|
||||
size_t startFrame = m_seekerStart * m_slicerTParent->m_originalSample.sampleSize();
|
||||
size_t endFrame = m_seekerEnd * m_slicerTParent->m_originalSample.sampleSize();
|
||||
|
||||
brush.setPen(s_waveformColor);
|
||||
float zoomOffset = (m_editorHeight - m_zoomLevel * m_editorHeight) / 2;
|
||||
|
||||
SampleWaveform::visualize(m_slicerTParent->m_originalSample, brush,
|
||||
QRect(0, zoomOffset, m_editorWidth, m_zoomLevel * m_editorHeight), startFrame, endFrame);
|
||||
const auto& sample = m_slicerTParent->m_originalSample;
|
||||
const auto waveform = SampleWaveform::Parameters{sample.data() + startFrame, endFrame - startFrame, sample.amplification(), sample.reversed()};
|
||||
const auto rect = QRect(0, zoomOffset, m_editorWidth, m_zoomLevel * m_editorHeight);
|
||||
SampleWaveform::visualize(waveform, brush, rect);
|
||||
|
||||
// increase brightness in inner color
|
||||
QBitmap innerMask = m_editorWaveform.createMaskFromColor(s_waveformMaskColor, Qt::MaskMode::MaskOutColor);
|
||||
|
||||
Reference in New Issue
Block a user