eq.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include <lib/std.mi>
  2. #include <lib/winampconfig.mi>
  3. Global Group frameGroup, use;
  4. Global Button btnEQp12,btnEQ0,btnEQm12;
  5. Global Layer eqBand;
  6. Global Boolean manual_set;
  7. Global Layout normal;
  8. #define ISOBANDS "31.5 Hz,63 Hz,125 Hz,250 Hz,500 Hz,1 KHz,2 KHz,4 KHz,8 KHz,16 KHz"
  9. #define WINAMPBANDS "70 Hz,180 Hz,320 Hz,600 Hz,1 KHz,3 KHz,6 KHz,12 KHz,14 KHz,16 KHz"
  10. System.onScriptLoaded() {
  11. WinampConfigGroup eqwcg = WinampConfig.getGroup("{72409F84-BAF1-4448-8211-D84A30A1591A}");
  12. int freqmode = eqwcg.getInt("frequencies"); // returns 0 for classical winamp levels, 1 for ISO levels
  13. frameGroup = getScriptGroup();
  14. normal = frameGroup.getParentLayout();
  15. btnEQp12 = frameGroup.findObject("EQ_p12");
  16. btnEQ0 = frameGroup.findObject("EQ_0");
  17. btnEQm12 = frameGroup.findObject("EQ_m12");
  18. eqBand = frameGroup.findObject("equalizer.band.label");
  19. system.onEqFreqChanged(freqmode);
  20. }
  21. btnEQp12.onLeftClick() {
  22. manual_set = 1;
  23. for(int i=0; i<10; i++) setEqBand(i, 127);
  24. manual_set = 0;
  25. }
  26. btnEQ0.onLeftClick() {
  27. manual_set = 1;
  28. for(int i=0; i<10; i++) setEqBand(i, 0);
  29. manual_set = 0;
  30. }
  31. btnEQm12.onLeftClick() {
  32. manual_set = 1;
  33. for(int i=0; i<10; i++) setEqBand(i, -127);
  34. manual_set = 0;
  35. }
  36. System.onEqFreqChanged (boolean isoonoff)
  37. {
  38. if (isoonoff == 1)
  39. {
  40. eqBand.setXmlParam("image", "drawer.eq.label.iso");
  41. for(int i=0; i<10; i++) frameGroup.findObject("eq"+integerToString(i+1)).setXmlParam("tooltip", getToken(ISOBANDS,",",i));
  42. }
  43. else
  44. {
  45. eqBand.setXmlParam("image", "drawer.eq.label.winamp");
  46. for(int i=0; i<10; i++) frameGroup.findObject("eq"+integerToString(i+1)).setXmlParam("tooltip", getToken(WINAMPBANDS,",",i));
  47. }
  48. }
  49. system.onEqBandChanged(int band, int value)
  50. {
  51. if (manual_set) return;
  52. String t;
  53. Float f = value;
  54. f = f / 10.5;
  55. WinampConfigGroup eqwcg = WinampConfig.getGroup("{72409F84-BAF1-4448-8211-D84A30A1591A}");
  56. if (eqwcg.getInt("frequencies") == 1) {
  57. if (f >= 0) t = "EQ: " + translate(getToken(ISOBANDS,",",band)) + ": +" + floattostring(f, 1) + " "+ translate("dB");
  58. else t = "EQ: " + translate(getToken(ISOBANDS,",",band)) + ": " + floattostring(f, 1) + " "+ translate("dB");
  59. }
  60. else {
  61. if (f >= 0) t = "EQ: " + translate(getToken(WINAMPBANDS,",",band)) + ": +" + floattostring(f, 1) + " "+ translate("dB");
  62. else t = "EQ: " + translate(getToken(WINAMPBANDS,",",band)) + ": " + floattostring(f, 1) + " "+ translate("dB");
  63. }
  64. normal.sendAction("showinfo", t, 0,0,0,0);
  65. }
  66. system.onEqPreampChanged(int value)
  67. {
  68. slider s = getScriptGroup().findObject("preamp");
  69. value = s.getPosition(); // Somehow this function returns a range from [-127;125] with hotpos -3, so we take the slider instead
  70. String t = "EQ: " + translate("Preamp:") + " ";
  71. Float f = value;
  72. f = f / 10.5;
  73. if (f >= -3) t += "+"+floattostring(f, 1) + " "+ translate("dB");
  74. else t += floattostring(f, 1) + " "+ translate("dB");
  75. normal.sendAction("showinfo", t, 0,0,0,0);
  76. }