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.

Osc_DataModel.h 923B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include "Fl_Osc_Widget.H"
  3. #include <functional>
  4. #include <vector>
  5. #include <rtosc/rtosc.h>
  6. class Osc_DataModel:public Fl_Osc_Widget
  7. {
  8. public:
  9. Osc_DataModel(Fl_Osc_Interface *osc_)
  10. :Fl_Osc_Widget("", osc_)
  11. {
  12. assert(osc);
  13. }
  14. typedef std::string value_t;
  15. value_t value;
  16. std::function<void(value_t)> callback;
  17. void doUpdate(std::string url)
  18. {
  19. if(!ext.empty())
  20. osc->removeLink(this);
  21. ext = url;
  22. value = "";
  23. oscRegister(ext.c_str());
  24. }
  25. //Raw messages
  26. virtual void OSC_raw(const char *msg)
  27. {
  28. std::string args = rtosc_argument_string(msg);
  29. if(args == "s") {
  30. value = rtosc_argument(msg, 0).s;
  31. if(callback)
  32. callback(value);
  33. }
  34. }
  35. };