File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -49,20 +49,20 @@ void WaveFormChunk::updateWave(Signal* signal)
49
49
// qDebug() << "There is a signal";
50
50
m_nbTotalSample = signal->sampleCount ();
51
51
52
- int mid = qRound ( height () / 2 . );
52
+ int mid = qFloor (( height ()- 1 ) * 0.5 );
53
53
54
54
if (m_nbIndex < width ()) // less index than pixel -> draw lines between each index
55
55
{
56
56
QPainterPath path;
57
57
58
58
qreal nbPixelPerIndex = qreal (width ()) / m_nbIndex;
59
59
60
- qint32 value = signal->getSample (m_startIndex);
60
+ qint32 value = - signal->getSample (m_startIndex);
61
61
path.moveTo (0 , qRound (value / qreal (INT32_MAX) * mid + mid));
62
62
63
63
for (int i = 1 ; i < m_nbIndex + 1 ; i++)
64
64
{
65
- qint32 value = signal->getSample (m_startIndex + i);
65
+ value = - signal->getSample (m_startIndex + i);
66
66
path.lineTo (i * nbPixelPerIndex, qRound (value / qreal (INT32_MAX) * mid + mid));
67
67
}
68
68
@@ -82,7 +82,7 @@ void WaveFormChunk::updateWave(Signal* signal)
82
82
83
83
for (int k = 0 ; k < nbIndexInThisPixel + 1 ; k++)
84
84
{
85
- qint32 y = signal->getSample (m_startIndex + prevIndex + k);
85
+ qint32 y = - signal->getSample (m_startIndex + prevIndex + k);
86
86
if (y < min) min = y;
87
87
if (y > max) max = y;
88
88
}
Original file line number Diff line number Diff line change @@ -120,7 +120,6 @@ void WaveFormView::paintEvent(QPaintEvent *_event)
120
120
121
121
void WaveFormView::wheelEvent (QWheelEvent *_event)
122
122
{
123
-
124
123
// zoom
125
124
int angle = _event->angleDelta ().y ();
126
125
qreal factor = 1.0 + (angle > 0.0 ? 0.1 : -0.1 );
@@ -148,17 +147,16 @@ void WaveFormView::setSampleOffset(int _startIndex)
148
147
149
148
m_sampleOffset = qMax (0 , _startIndex);
150
149
151
- int chunkStartIndex = m_chunkList.first ()->startIndex ();
152
-
153
- if (m_sampleOffset - chunkStartIndex >= 2 * m_samplePerChunk)
150
+ while (m_sampleOffset - m_chunkList.first ()->startIndex () >= 2 * m_samplePerChunk)
154
151
{
155
152
WaveFormChunk* chunk = m_chunkList.first ();
156
153
m_chunkList.pop_front ();
157
154
chunk->setIndexRange (m_chunkList.last ()->startIndex () + m_samplePerChunk, m_samplePerChunk);
158
155
chunk->updateWave (m_signal);
159
156
m_chunkList.push_back (chunk);
160
157
}
161
- else if (m_sampleOffset - chunkStartIndex < 0 )
158
+
159
+ while (m_sampleOffset - m_chunkList.first ()->startIndex () < 0 )
162
160
{
163
161
WaveFormChunk* chunk = m_chunkList.last ();
164
162
m_chunkList.pop_back ();
@@ -204,6 +202,6 @@ void WaveFormView::updateZoom(int _localOffset)
204
202
m_sampleOffset = 0 ;
205
203
}
206
204
207
- m_sampleOffset = qMax ( 0 , qRound (_localOffset + (m_sampleOffset - _localOffset) * qreal (m_nbSampleViewed) / oldSampleViewed));
205
+ setSampleOffset ( qRound (_localOffset + (m_sampleOffset - _localOffset) * qreal (m_nbSampleViewed) / oldSampleViewed));
208
206
emit zoomChanged ();
209
207
}
You can’t perform that action at this time.
0 commit comments