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.

30 lines
677B

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. CallbackRepeater.cpp - Timed Callback Container
  4. Copyright (C) 2016 Mark McCurry
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. */
  10. #include "CallbackRepeater.h"
  11. namespace zyncarla {
  12. CallbackRepeater::CallbackRepeater(int interval, cb_t cb_)
  13. :last(time(0)), dt(interval), cb(cb_)
  14. {}
  15. void CallbackRepeater::tick(void)
  16. {
  17. auto now = time(0);
  18. if(now-last > dt && dt >= 0) {
  19. cb();
  20. last = now;
  21. }
  22. }
  23. }