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.

Fl_Osc_Output.cpp 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "Fl_Osc_Output.H"
  2. #include <cstdlib>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <cassert>
  6. #include <sstream>
  7. static void callback_fn_output(Fl_Widget *w, void *)
  8. {
  9. ((Fl_Osc_Output*)w)->cb();
  10. }
  11. Fl_Osc_Output::Fl_Osc_Output(int X, int Y, int W, int H, const char *label)
  12. :Fl_Value_Output(X,Y,W,H, label), Fl_Osc_Widget(this)
  13. {
  14. Fl_Value_Output::callback(callback_fn_output);
  15. }
  16. void Fl_Osc_Output::init(const char *path)
  17. {
  18. ext = path;
  19. oscRegister(path);
  20. };
  21. void Fl_Osc_Output::callback(Fl_Callback *cb, void *p)
  22. {
  23. cb_data.first = cb;
  24. cb_data.second = p;
  25. }
  26. void Fl_Osc_Output::OSC_value(char v)
  27. {
  28. newvalue_ = v;
  29. value(v);
  30. //Hide the fact that this widget is async
  31. if(cb_data.first)
  32. cb_data.first(this, cb_data.second);
  33. }
  34. void Fl_Osc_Output::OSC_value(float v)
  35. {
  36. newvalue_ = v;
  37. value(v);
  38. //Hide the fact that this widget is async
  39. if(cb_data.first)
  40. cb_data.first(this, cb_data.second);
  41. }
  42. void Fl_Osc_Output::update(void)
  43. {
  44. oscWrite(ext);
  45. }
  46. float Fl_Osc_Output::newvalue(void) const
  47. {
  48. return newvalue_;
  49. }
  50. void Fl_Osc_Output::cb(void)
  51. {
  52. oscWrite(ext);
  53. }