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:

Qt Code:
  1. if (newSoundPosition - m_lastDrawnPosition > getWaveWidgetParent()->getWaveGraphModel()->getSamplesPerPixel())
  2. {
  3. if (zoomFactor > 1.0)// if zoomIn
  4. {
  5. if (widgetPos < center)
  6. {
  7. waveDisplay->updatePlayHead(m_lastDrawnPosition, newSoundPosition);
  8. }
  9. else
  10. {
  11. uint fdiff = widgetPos - center;
  12. fstart = m_lastFrameStart + fdiff;
  13. graphModel->setFrameStart(fstart);
  14. m_lastFrameStart = fstart;
  15. }
  16. }
  17. else // when zoom factor = 1.0 always update the 'playline'
  18. {
  19. waveDisplay->updatePlayHead(m_lastDrawnPosition, newSoundPosition);
  20. }
  21.  
  22. m_lastDrawnPosition = newSoundPosition;
  23. }
To copy to clipboard, switch view to plain text mode 

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