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.

64 lines
1.3KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Fl_Osc_Roller.cpp - OSC Powered Roller
  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_Roller.H"
  11. #include <cstdlib>
  12. #include <cstring>
  13. #include <cmath>
  14. #include <cassert>
  15. #include <sstream>
  16. static void callback_fn_roller(Fl_Widget *w, void *)
  17. {
  18. ((Fl_Osc_Roller*)w)->cb();
  19. }
  20. Fl_Osc_Roller::Fl_Osc_Roller(int X, int Y, int W, int H, const char *label)
  21. :Fl_Roller(X,Y,W,H, label), Fl_Osc_Widget(this)
  22. {
  23. Fl_Roller::callback(callback_fn_roller);
  24. bounds(0.0, 127.0f);
  25. }
  26. void Fl_Osc_Roller::init(const char *path)
  27. {
  28. name = path;
  29. oscRegister(path);
  30. };
  31. Fl_Osc_Roller::~Fl_Osc_Roller(void)
  32. {}
  33. void Fl_Osc_Roller::callback(Fl_Callback *cb, void *p)
  34. {
  35. cb_data.first = cb;
  36. cb_data.second = p;
  37. }
  38. void Fl_Osc_Roller::OSC_value(char v)
  39. {
  40. value(v);
  41. }
  42. void Fl_Osc_Roller::update(void)
  43. {
  44. oscWrite(name);
  45. }
  46. void Fl_Osc_Roller::cb(void)
  47. {
  48. oscWrite(name, "i", (int)value());
  49. if(cb_data.first)
  50. cb_data.first(this, cb_data.second);
  51. }