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_Choice.cpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "Fl_Osc_Choice.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. static void callback_fn_choice(Fl_Widget *w, void *)
  10. {
  11. ((Fl_Osc_Choice*)w)->cb();
  12. }
  13. Fl_Osc_Choice::Fl_Osc_Choice(int X, int Y, int W, int H, const char *label)
  14. :Fl_Choice(X,Y,W,H, label), Fl_Osc_Widget(this), cb_data(NULL, NULL)
  15. {
  16. min = 0;
  17. Fl_Choice::callback(callback_fn_choice, NULL);
  18. }
  19. void Fl_Osc_Choice::init(std::string path_, int base)
  20. {
  21. min = base;
  22. ext = path_;
  23. Fl_Osc_Pane *pane = fetch_osc_pane(this);
  24. assert(pane);
  25. assert(pane->osc);
  26. osc = pane->osc;
  27. oscRegister(path_.c_str());
  28. };
  29. Fl_Osc_Choice::~Fl_Osc_Choice(void)
  30. {}
  31. void Fl_Osc_Choice::callback(Fl_Callback *cb, void *p)
  32. {
  33. cb_data.first = cb;
  34. cb_data.second = p;
  35. }
  36. void Fl_Osc_Choice::OSC_value(int v)
  37. {
  38. if(v-min == value())
  39. return;
  40. value(v-min);
  41. if(cb_data.first)
  42. cb_data.first(this, cb_data.second);
  43. }
  44. void Fl_Osc_Choice::OSC_value(char v)
  45. {
  46. OSC_value((int)v);
  47. }
  48. void Fl_Osc_Choice::cb(void)
  49. {
  50. assert(osc);
  51. oscWrite(ext, "i", value()+min);
  52. if(cb_data.first)
  53. cb_data.first(this, cb_data.second);
  54. }
  55. void Fl_Osc_Choice::update(void)
  56. {
  57. assert(osc);
  58. oscWrite(ext);
  59. }