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.

57 lines
1.1KB

  1. #include "Fl_Osc_Counter.H"
  2. static void callback_fn_counter(Fl_Widget *w, void *)
  3. {
  4. ((Fl_Osc_Counter*)w)->cb();
  5. }
  6. Fl_Osc_Counter::Fl_Osc_Counter(int x, int y, int w, int h, const char *label)
  7. :Fl_Counter(x,y,w,h,label), Fl_Osc_Widget(this), offset(0)
  8. {
  9. Fl_Counter::callback(callback_fn_counter);
  10. }
  11. void Fl_Osc_Counter::update(void)
  12. {
  13. oscWrite(ext);
  14. }
  15. void Fl_Osc_Counter::init(const char *path_, char type_, int display_off)
  16. {
  17. offset = display_off;
  18. oscRegister(path_);
  19. ext = path_;
  20. cb_type = type_;
  21. }
  22. void Fl_Osc_Counter::callback(Fl_Callback *cb, void *p)
  23. {
  24. cb_data.first = cb;
  25. cb_data.second = p;
  26. }
  27. void Fl_Osc_Counter::OSC_value(int v)
  28. {
  29. value(v+offset);
  30. }
  31. void Fl_Osc_Counter::OSC_value(char v)
  32. {
  33. value(v+offset);
  34. }
  35. void Fl_Osc_Counter::cb(void)
  36. {
  37. assert(osc);
  38. if(cb_type == 'c') {
  39. fprintf(stderr, "invalid `c' from counter %s%s, using `i'\n", loc.c_str(), ext.c_str());
  40. oscWrite(ext, "i", (int)(value()-offset));
  41. }
  42. else
  43. oscWrite(ext, "i", (int)(value()-offset));
  44. if(cb_data.first)
  45. cb_data.first(this, cb_data.second);
  46. }