Animation regularity

First off - just started experimenting with Juce.

I have a problem with rendering - maybe a more windows/mac generic problem but I wondered if anyone had some insight as to how to solve this.

I have a graphic that I am animating - scrolling, and the scroll I am getting is Jittery. The application is doing a fair bit in the background including some stuff at high-pri (audio real-time task) but CPU is around 30% - not hugely loaded.

I am investigating further, but I think my problem is that in the path from a notion of real time, to picking up a windows timer callback, to triggering the repaint, to doing the paint when it gets called I have too much timing jitter - and hence my scrolling is jittery.

I am sure I am not the only one to ever hit this problem. I am trawling for ideas on how to solve this. Can anyone suggest a good approach to making this scrolling smooth? The refresh interval I am aiming for is around 25x - 30x per second.

Thanks in anticipation


I don’t think there’s any way of making it perfectly smooth, because the message thread is always vulnerable to glitching, but it should be able to do 25-30 fps. Just tweaking the timing intervals might be all that’s needed, or perhaps triggering as many repaints as possible and letting the OS (hopefully) throttle them to one-per-frame.

in the scrolling waveform display i just posted in the useful tools forum, the animation doesn’t look smooth unless the timer interval is 1ms. Drawing that frequently takes a toll on the cpu, so the interval must be longer, and the display is plagued by the inconsistency of the messaging system. To solve the performance issue and smoothness, I would want to draw directly to the HDC from my own thread. I have to get more familiar with Juce’s internals to do this confidently, as it seems to be something of a hack in the context of juce. Alternatively, I’d bet using an OpenGL context instead of the software render would be better for smooth animation.