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.

82 lines
2.0KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. WatchPoint.h - Synthesis State Watcher
  4. Copyright (C) 2015-2015 Mark McCurry
  5. Author: Mark McCurry
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #pragma once
  12. struct WatchManager;
  13. namespace rtosc {class ThreadLink;}
  14. struct WatchPoint
  15. {
  16. bool active;
  17. int samples_left;
  18. WatchManager *reference;
  19. char identity[128];
  20. WatchPoint(WatchManager *ref, const char *prefix, const char *id);
  21. bool is_active(void);
  22. };
  23. #define MAX_WATCH 16
  24. #define MAX_WATCH_PATH 128
  25. #define MAX_SAMPLE 128
  26. struct WatchManager
  27. {
  28. typedef rtosc::ThreadLink thrlnk;
  29. thrlnk *write_back;
  30. bool new_active;
  31. char active_list[MAX_WATCH][MAX_WATCH_PATH];
  32. float data_list[MAX_SAMPLE][MAX_WATCH];
  33. int sample_list[MAX_WATCH];
  34. bool deactivate[MAX_WATCH];
  35. //External API
  36. WatchManager(thrlnk *link=0);
  37. void add_watch(const char *);
  38. void del_watch(const char *);
  39. void tick(void);
  40. //Watch Point Query API
  41. bool active(const char *) const;
  42. int samples(const char *) const;
  43. //Watch Point Response API
  44. void satisfy(const char *, float);
  45. void satisfy(const char *, float*, int);
  46. };
  47. struct FloatWatchPoint:public WatchPoint
  48. {
  49. FloatWatchPoint(WatchManager *ref, const char *prefix, const char *id);
  50. inline void operator()(float f)
  51. {
  52. if(is_active() && reference) {
  53. reference->satisfy(identity, f);
  54. active = false;
  55. }
  56. }
  57. };
  58. //basically the same as the float watch point, only it consumes tuples
  59. struct VecWatchPoint : public WatchPoint
  60. {
  61. VecWatchPoint(WatchManager *ref, const char *prefix, const char *id);
  62. inline void operator()(float *f, int n)
  63. {
  64. if(is_active() && reference) {
  65. reference->satisfy(identity, f, n);
  66. active = false;
  67. }
  68. }
  69. };