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.

65 lines
1.8KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. VuPartMeter.h - OSC Controlled VU Meter
  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 "VuMeter.h"
  11. #define MIN_DB (-48)
  12. class VuPartMeter: public VuMeter
  13. {
  14. public:
  15. VuPartMeter(int x,int y, int w, int h, const char *label=0)
  16. :VuMeter(x,y,w,h,label), db(0.0f)
  17. {}
  18. void draw(void)
  19. {
  20. const int X = x(), Y = y(), W = w(), H = h();
  21. //XXX perhaps re-enable this later on
  22. //if (!active_r()){
  23. // int fakedb=master->fakepeakpart[npart];
  24. // fl_rectf(X,Y,W,H,140,140,140);
  25. // if (fakedb>0){
  26. // fakedb=(int)(fakedb/255.0*H)+4;
  27. // fl_rectf(X+2,Y+H-fakedb,W-4,fakedb,0,0,0);
  28. // }
  29. // return;
  30. //}
  31. //draw the vu lines
  32. const int idb = db*(H-2);
  33. fl_rectf(X,Y+H-idb,W,idb,0,200,255);
  34. fl_rectf(X,Y,W,H-idb,0,0,0);
  35. //draw the scales
  36. const float tmp=H*1.0/MIN_DB;
  37. for (int i = 1; i < 1 - MIN_DB; i++) {
  38. const int ty = H+(int) (tmp*i);
  39. if(i%5 == 0) fl_rectf(X, Y+H-ty, W, 1,0, 160, 200);
  40. if(i%10 == 0) fl_rectf(X, Y+H-ty, W, 1,0, 230, 240);
  41. }
  42. }
  43. void update(float x)
  44. {
  45. const float _db = limit((MIN_DB-rap2dB(x))/MIN_DB);
  46. if(db != _db) {
  47. db = _db;
  48. damage(FL_DAMAGE_USER1);
  49. }
  50. }
  51. private:
  52. float db;
  53. };