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.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Fl_Osc_Output.cpp - OSC Based Value Output
  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. #include "Fl_Osc_Output.H"
  11. #include <cstdlib>
  12. #include <cstring>
  13. #include <cmath>
  14. #include <cassert>
  15. #include <sstream>
  16. static void callback_fn_output(Fl_Widget *w, void *)
  17. {
  18. ((Fl_Osc_Output*)w)->cb();
  19. }
  20. Fl_Osc_Output::Fl_Osc_Output(int X, int Y, int W, int H, const char *label)
  21. :Fl_Value_Output(X,Y,W,H, label), Fl_Osc_Widget(this)
  22. {
  23. Fl_Value_Output::callback(callback_fn_output);
  24. }
  25. void Fl_Osc_Output::init(const char *path)
  26. {
  27. ext = path;
  28. oscRegister(path);
  29. };
  30. void Fl_Osc_Output::callback(Fl_Callback *cb, void *p)
  31. {
  32. cb_data.first = cb;
  33. cb_data.second = p;
  34. }
  35. void Fl_Osc_Output::OSC_value(char v)
  36. {
  37. newvalue_ = v;
  38. value(v);
  39. //Hide the fact that this widget is async
  40. if(cb_data.first)
  41. cb_data.first(this, cb_data.second);
  42. }
  43. void Fl_Osc_Output::OSC_value(float v)
  44. {
  45. newvalue_ = v;
  46. value(v);
  47. //Hide the fact that this widget is async
  48. if(cb_data.first)
  49. cb_data.first(this, cb_data.second);
  50. }
  51. void Fl_Osc_Output::update(void)
  52. {
  53. oscWrite(ext);
  54. }
  55. float Fl_Osc_Output::newvalue(void) const
  56. {
  57. return newvalue_;
  58. }
  59. void Fl_Osc_Output::cb(void)
  60. {
  61. oscWrite(ext);
  62. }