Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. AnimatedAppComponent::AnimatedAppComponent()
  16. : lastUpdateTime (Time::getCurrentTime()), totalUpdates (0)
  17. {
  18. setOpaque (true);
  19. }
  20. void AnimatedAppComponent::setFramesPerSecond (int framesPerSecond)
  21. {
  22. jassert (framesPerSecond > 0 && framesPerSecond < 1000);
  23. startTimerHz (framesPerSecond);
  24. }
  25. int AnimatedAppComponent::getMillisecondsSinceLastUpdate() const noexcept
  26. {
  27. return (int) (Time::getCurrentTime() - lastUpdateTime).inMilliseconds();
  28. }
  29. void AnimatedAppComponent::timerCallback()
  30. {
  31. ++totalUpdates;
  32. update();
  33. repaint();
  34. lastUpdateTime = Time::getCurrentTime();
  35. }
  36. } // namespace juce