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.

25 lines
651B

  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. CallbackRepeater::CallbackRepeater(int interval, cb_t cb_)
  12. :last(time(0)), dt(interval), cb(cb_)
  13. {}
  14. void CallbackRepeater::tick(void)
  15. {
  16. auto now = time(0);
  17. if(now-last > dt && dt >= 0) {
  18. cb();
  19. last = now;
  20. }
  21. }