# FR: ComponentAnimator: 60Hz instead of 50Hz

**URL:** <https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105>\
**Category:** Feature Requests\
**Created:** [February 21, 2024, 11:34pm UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105 "2024-02-21T23:34:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fuo](https://avatars.discourse-cdn.com/v4/letter/f/ba8739/32.png) [@fuo](https://forum.juce.com/u/fuo)\
**Post date:** [February 21, 2024, 11:34pm UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/1 "2024-02-21T23:34:00Z")

</div>

ComponentAnimator does currently use a 50Hz timer:

juce\_ComponentAnimator.cpp:

```auto
    if (! isTimerRunning())
    {
        lastTime = Time::getMillisecondCounter();
        startTimerHz (50);
    }

```

60Hz would probably be a more sensible value as AFAIK this is standard pretty much everywhere now: long gone are the days of PAL/SECAM for computer screens 😉

50Hz animations can look choppy at times on a 60Hz screen.  
Changing that value to 60Hz does seem like a simple fix with few possible side effects.

Being able to set that value would be even better, and why not even give the option to use the new VBlankAttachment class?

---

<div class="post-metadata">

**Author:** ![AdamVenn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamvenn/32/17023_2.png) [@AdamVenn](https://forum.juce.com/u/AdamVenn)\
**Post date:** [February 22, 2024, 12:25am UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/2 "2024-02-22T00:25:49Z")

</div>

Might be able to grab some code from AnimatedAppComponent, which seems to do those things already.

Don’t know if that class would be suitable for yours uses for now.

---

<div class="post-metadata">

**Author:** ![fuo](https://avatars.discourse-cdn.com/v4/letter/f/ba8739/32.png) [@fuo](https://forum.juce.com/u/fuo)\
**Post date:** [February 22, 2024, 2:37am UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/3 "2024-02-22T02:37:30Z")

</div>

ComponentAnimator has some handy features that I am happy to rely on.  
For now I just modify that value in juce\_ComponentAnimator.cpp every time I update JUCE…

---

<div class="post-metadata">

**Author:** ![kcoul](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kcoul](https://forum.juce.com/u/kcoul)\
**Post date:** [February 22, 2024, 2:48am UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/4 "2024-02-22T02:48:15Z")

</div>

The refactor I wrote for this (but never put into PR form as I got sidetracked) was simply to allow the caller to specify the refresh rate as a CTOR argument. I think that’s the way to go, possibly including a default value (of 60Hz indeed).

---

<div class="post-metadata">

**Author:** ![stephenk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephenk/32/15198_2.png) [@stephenk](https://forum.juce.com/u/stephenk)\
**Post date:** [February 22, 2024, 7:31am UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/5 "2024-02-22T07:31:32Z")

</div>

> [@kcoul](#):
>
> was simply to allow the caller to specify the refresh rate as a CTOR argument.

Since the recommended way to use it, for simple stuff, is to use the `Desktop::getAnimator()`, it would have to default to 60hz.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 22, 2024, 7:57am UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/6 "2024-02-22T07:57:02Z")

</div>

Speaking of choppy, you might not use a timer at all but resort to VBlankAttachment and make sure to calculate your model against the actual painting time and not a jittery message manager.

---

<div class="post-metadata">

**Author:** ![kcoul](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kcoul](https://forum.juce.com/u/kcoul)\
**Post date:** [February 22, 2024, 6:38pm UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/7 "2024-02-22T18:38:43Z")

</div>

Yeah that’s sort of what I was getting at. I had problems with this component when testing the new Direct2D support on Windows, for example.

---

<div class="post-metadata">

**Author:** ![fuo](https://avatars.discourse-cdn.com/v4/letter/f/ba8739/32.png) [@fuo](https://forum.juce.com/u/fuo)\
**Post date:** [February 22, 2024, 9:34pm UTC](https://forum.juce.com/t/fr-componentanimator-60hz-instead-of-50hz/60105/8 "2024-02-22T21:34:53Z")

</div>

That is what is done in ComponentAnimator: the progress is calculated in the timer callback.  
Components are resized there, and eventually painted later on.  
This cannot be as smooth as calculating progress directly in paint(), but cannot be avoided here.
