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 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Osc_DataModel.h - OSC Data View
  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. #pragma once
  11. #include "Fl_Osc_Widget.H"
  12. #include <functional>
  13. #include <vector>
  14. #include <rtosc/rtosc.h>
  15. class Osc_DataModel:public Fl_Osc_Widget
  16. {
  17. public:
  18. Osc_DataModel(Fl_Osc_Interface *osc_)
  19. :Fl_Osc_Widget("", osc_)
  20. {
  21. assert(osc);
  22. }
  23. typedef std::string value_t;
  24. value_t value;
  25. std::function<void(value_t)> callback;
  26. void doUpdate(std::string url)
  27. {
  28. if(!ext.empty())
  29. osc->removeLink(this);
  30. ext = url;
  31. value = "";
  32. oscRegister(ext.c_str());
  33. }
  34. //Raw messages
  35. virtual void OSC_raw(const char *msg)
  36. {
  37. std::string args = rtosc_argument_string(msg);
  38. if(args == "s") {
  39. value = rtosc_argument(msg, 0).s;
  40. if(callback)
  41. callback(value);
  42. }
  43. }
  44. };