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.

49 lines
1.1KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Fl_Osc_Numeric_Input.cpp - OSC Based Numeric Input
  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 <stdlib.h>
  11. #include "Fl_Osc_Numeric_Input.H"
  12. Fl_Osc_Numeric_Input::Fl_Osc_Numeric_Input(int X, int Y, int W, int H, const char *label)
  13. :Fl_Input(X,Y,W,H, label), Fl_Osc_Widget(this)
  14. {
  15. callback(numeric_callback);
  16. }
  17. Fl_Osc_Numeric_Input::~Fl_Osc_Numeric_Input(void)
  18. {}
  19. void Fl_Osc_Numeric_Input::init(const char *path)
  20. {
  21. ext = path;
  22. oscRegister(path);
  23. }
  24. void Fl_Osc_Numeric_Input::OSC_value(float f)
  25. {
  26. OSC_value((int)f);
  27. }
  28. void Fl_Osc_Numeric_Input::OSC_value(int i)
  29. {
  30. char buf[128];
  31. snprintf(buf, 128, "%d", i);
  32. value(buf);
  33. }
  34. void Fl_Osc_Numeric_Input::numeric_callback(Fl_Widget *w)
  35. {
  36. auto &ww = *(Fl_Osc_Numeric_Input *)w;
  37. int x = atoi(ww.value());
  38. if(x)
  39. ww.oscWrite(ww.ext, "i", x);
  40. }