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.

VuPartMeter.h 1.4KB

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