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.

68 lines
1.5KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Fl_Osc_Counter.cpp - OSC Powered Counter
  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 "Fl_Osc_Counter.H"
  11. static void callback_fn_counter(Fl_Widget *w, void *)
  12. {
  13. ((Fl_Osc_Counter*)w)->cb();
  14. }
  15. Fl_Osc_Counter::Fl_Osc_Counter(int x, int y, int w, int h, const char *label)
  16. :Fl_Counter(x,y,w,h,label), Fl_Osc_Widget(this), offset(0)
  17. {
  18. Fl_Counter::callback(callback_fn_counter);
  19. }
  20. void Fl_Osc_Counter::update(void)
  21. {
  22. oscWrite(ext);
  23. }
  24. void Fl_Osc_Counter::init(const char *path_, char type_, int display_off)
  25. {
  26. offset = display_off;
  27. oscRegister(path_);
  28. ext = path_;
  29. cb_type = type_;
  30. }
  31. void Fl_Osc_Counter::callback(Fl_Callback *cb, void *p)
  32. {
  33. cb_data.first = cb;
  34. cb_data.second = p;
  35. }
  36. void Fl_Osc_Counter::OSC_value(int v)
  37. {
  38. value(v+offset);
  39. }
  40. void Fl_Osc_Counter::OSC_value(char v)
  41. {
  42. value(v+offset);
  43. }
  44. void Fl_Osc_Counter::cb(void)
  45. {
  46. assert(osc);
  47. if(cb_type == 'c') {
  48. fprintf(stderr, "invalid `c' from counter %s%s, using `i'\n", loc.c_str(), ext.c_str());
  49. oscWrite(ext, "i", (int)(value()-offset));
  50. }
  51. else
  52. oscWrite(ext, "i", (int)(value()-offset));
  53. if(cb_data.first)
  54. cb_data.first(this, cb_data.second);
  55. }