Hi to all,
I wrote a audio wave display widget with a timeline that show the actual position in the audio samples. When playing back the timeline moves on the right.
I would do that when the playline reachs the middle it stops and the widget is scrolled on the left. I have a look at the ensureVisible code but I can no underdstand it very well.
Here the code I wrote:
Code:
if (newSoundPosition - m_lastDrawnPosition > getWaveWidgetParent()->getWaveGraphModel()->getSamplesPerPixel()) { if (zoomFactor > 1.0)// if zoomIn { if (widgetPos < center) { waveDisplay->updatePlayHead(m_lastDrawnPosition, newSoundPosition); } else { uint fdiff = widgetPos - center; fstart = m_lastFrameStart + fdiff; graphModel->setFrameStart(fstart); m_lastFrameStart = fstart; } } else // when zoom factor = 1.0 always update the 'playline' { waveDisplay->updatePlayHead(m_lastDrawnPosition, newSoundPosition); } m_lastDrawnPosition = newSoundPosition; }
Basically if the zoom factor ==1 the playline position is always updated as all wave form is displayed. Instead if the zoom factor > 1 is where I would shift the position of the widget keeping the position of the playline in the middle, but the result is not so good.
I can see the playline trembling around a position and I can not achieve what I need.
Any ideas?
Regards
