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.

75 lines
1.3KB

  1. #include "Fl_Osc_DialF.H"
  2. #include "Fl_Osc_Interface.h"
  3. #include "Fl_Osc_Pane.H"
  4. #include <cstdlib>
  5. #include <cstring>
  6. #include <cmath>
  7. #include <cassert>
  8. #include <sstream>
  9. template<typename A, typename B>
  10. B string_cast(const A &a)
  11. {
  12. std::stringstream s;
  13. s.precision(3);
  14. B b;
  15. s << " " << a << " ";
  16. s >> b;
  17. return b;
  18. }
  19. static void callback_fn_dialf(Fl_Widget *w, void *)
  20. {
  21. ((Fl_Osc_DialF*)w)->cb();
  22. }
  23. Fl_Osc_DialF::Fl_Osc_DialF(int X, int Y, int W, int H, const char *label)
  24. :WidgetPDial(X,Y,W,H, label), Fl_Osc_Widget()
  25. {
  26. //bounds(0.0, 127.0f);
  27. WidgetPDial::callback(callback_fn_dialf);
  28. }
  29. void Fl_Osc_DialF::init(const char *path)
  30. {
  31. Fl_Osc_Pane *pane = fetch_osc_pane(this);
  32. assert(pane);
  33. osc = pane->osc;
  34. ext = path;
  35. loc = pane->base;
  36. oscRegister(path);
  37. };
  38. Fl_Osc_DialF::~Fl_Osc_DialF(void)
  39. {}
  40. void Fl_Osc_DialF::callback(Fl_Callback *cb, void *p)
  41. {
  42. cb_data.first = cb;
  43. cb_data.second = p;
  44. }
  45. void Fl_Osc_DialF::OSC_value(float v)
  46. {
  47. value(v);
  48. }
  49. void Fl_Osc_DialF::update(void)
  50. {
  51. oscWrite(ext);
  52. }
  53. void Fl_Osc_DialF::cb(void)
  54. {
  55. assert(osc);
  56. oscWrite(ext, "f", (float)value());
  57. if(cb_data.first)
  58. cb_data.first(this, cb_data.second);
  59. // label_str = string_cast<float,string>(val);
  60. // label(" ");
  61. // label(label_str.c_str());
  62. }