eq.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: eq.m
  4. Version: 2.0
  5. Type: maki
  6. Date: 25. Jun. 2007 - 11:30
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. -----------------------------------------------------
  12. ---------------------------------------------------*/
  13. #include <lib/std.mi>
  14. #include <lib/winampconfig.mi>
  15. #define CENTER_VAR eqGroup
  16. #include <lib/com/centerlayer.m>
  17. #define ISOBANDS "31.5 Hz,63 Hz,125 Hz,250 Hz,500 Hz,1 KHz,2 KHz,4 KHz,8 KHz,16 KHz"
  18. #define WINAMPBANDS "70 Hz,180 Hz,320 Hz,600 Hz,1 KHz,3 KHz,6 KHz,12 KHz,14 KHz,16 KHz"
  19. Class Button Eqbutton;
  20. Member int EqButton.setTo;
  21. Global Group frameGroup, buttongroup;
  22. Global Slider slidercb, Balance;
  23. Global Text fadertext;
  24. Global Button CFIncrease, CFDecrease, eqon, eqauto;
  25. Global ToggleButton Crossfade;
  26. Global GuiObject CrossfadeActive, eqonActive, eqautoActive, SongTicker;
  27. Global Int CrossfadeActive_Y, eqonActive_Y, eqautoActive_Y;
  28. Global Eqbutton btnEQp12,btnEQ0,btnEQm12;
  29. Global layer frequencyLabel;
  30. System.onScriptLoaded()
  31. {
  32. buttongroup = getScriptGroup().findObject("player.cbuttons");
  33. WinampConfigGroup eqwcg = WinampConfig.getGroup("{72409F84-BAF1-4448-8211-D84A30A1591A}");
  34. int freqmode = eqwcg.getInt("frequencies"); // returns 0 for classical winamp levels, 1 for ISO levels
  35. frameGroup = getScriptGroup();
  36. _eqGroupInit(frameGroup.findObject("info.component.eq.content"), frameGroup, 1, 0);
  37. slidercb = frameGroup.findObject("sCrossfade");
  38. fadertext = frameGroup.findObject("CFDisplay");
  39. CFIncrease = frameGroup.findObject("CrossfadeIncrease");
  40. CFDecrease = frameGroup.findObject("CrossfadeDecrease");
  41. Crossfade = frameGroup.findObject("Crossfade");
  42. CrossfadeActive = frameGroup.findObject("CrossfadeActive");
  43. CrossfadeActive_Y = CrossfadeActive.getGuiY();
  44. eqon = frameGroup.findObject("eqonoff");
  45. eqonActive = frameGroup.findObject("eqonoffActive");
  46. eqonActive_Y = eqonActive.getGuiY();
  47. eqauto = frameGroup.findObject("eqauto");
  48. eqautoActive = frameGroup.findObject("eqautoActive");
  49. eqautoActive_Y = eqautoActive.getGuiY();
  50. btnEQp12 = frameGroup.findObject("EQ_p12");
  51. btnEQp12.setTo = 127;
  52. btnEQ0 = frameGroup.findObject("EQ_0");
  53. btnEQ0.setTo = 0;
  54. btnEQm12 = frameGroup.findObject("EQ_m12");
  55. btnEQm12.setTo = -127;
  56. Balance = frameGroup.findObject("Balance");
  57. SongTicker = buttongroup.getParentLayout().findObject("songticker");
  58. frequencyLabel = frameGroup.findObject("frequency.labels");
  59. system.onEqFreqChanged(freqmode);
  60. slidercb.onSetPosition(slidercb.getPosition());
  61. Crossfade.onToggle(Crossfade.getActivated());
  62. }
  63. Balance.onSetPosition(int newpos)
  64. {
  65. string t=translate("Balance")+":";
  66. if (newpos==127) t+= " " + translate("Center");
  67. if (newpos<127) t += " " + integerToString((100-(newpos/127)*100))+"% "+translate("Left");
  68. if (newpos>127) t += " " + integerToString(((newpos-127)/127)*100)+"% "+translate("Right");
  69. SongTicker.sendAction("showinfo", t, 0, 0, 0, 0);
  70. }
  71. slidercb.onSetPosition(int val)
  72. {
  73. String s = IntegerToString(val);
  74. fadertext.setText(s);
  75. }
  76. CFIncrease.onLeftClick()
  77. {
  78. slidercb.SetPosition(slidercb.getPosition()+1);
  79. }
  80. CFDecrease.onLeftClick()
  81. {
  82. slidercb.SetPosition(slidercb.getPosition()-1);
  83. }
  84. Crossfade.onToggle(boolean on)
  85. {
  86. if (!on)
  87. {
  88. fadertext.setAlpha(150);
  89. CFIncrease.setAlpha(150);
  90. CFDecrease.setXmlParam("ghost" , "1");
  91. CFDecrease.setAlpha(150);
  92. CFIncrease.setXmlParam("ghost" , "1");
  93. CrossfadeActive.hide();
  94. }
  95. else
  96. {
  97. fadertext.setAlpha(255);
  98. CFIncrease.setAlpha(255);
  99. CFDecrease.setAlpha(255);
  100. CFIncrease.setXmlParam("ghost" , "0");
  101. CFDecrease.setXmlParam("ghost" , "0");
  102. CrossfadeActive.show();
  103. }
  104. }
  105. Global Boolean cfDown, onDown, autoDown, manual_set;
  106. Crossfade.onLeftButtonDown (int x, int y)
  107. {
  108. cfDown = 1;
  109. CrossfadeActive.setXmlParam("y", integerToString(CrossfadeActive_Y+1));
  110. }
  111. Crossfade.onLeftButtonUp (int x, int y)
  112. {
  113. cfDown = 0;
  114. CrossfadeActive.setXmlParam("y", integerToString(CrossfadeActive_Y));
  115. }
  116. Crossfade.onleaveArea ()
  117. {
  118. CrossfadeActive.setXmlParam("y", integerToString(CrossfadeActive_Y));
  119. }
  120. Crossfade.onEnterArea ()
  121. {
  122. if (cfDown) CrossfadeActive.setXmlParam("y", integerToString(CrossfadeActive_Y+1));
  123. }
  124. eqon.onEnterArea ()
  125. {
  126. if (onDown) eqonActive.setXmlParam("y", integerToString(eqonActive_Y+1));
  127. }
  128. eqon.onLeftButtonDown (int x, int y)
  129. {
  130. onDown = 1;
  131. eqonActive.setXmlParam("y", integerToString(eqonActive_Y+1));
  132. }
  133. eqon.onLeftButtonUp (int x, int y)
  134. {
  135. onDown = 0;
  136. eqonActive.setXmlParam("y", integerToString(eqonActive_Y));
  137. }
  138. eqon.onleaveArea ()
  139. {
  140. eqonActive.setXmlParam("y", integerToString(eqonActive_Y));
  141. }
  142. eqauto.onLeftButtonDown (int x, int y)
  143. {
  144. autoDown = 1;
  145. eqautoActive.setXmlParam("y", integerToString(eqautoActive_Y+1));
  146. }
  147. eqauto.onLeftButtonUp (int x, int y)
  148. {
  149. autoDown = 0;
  150. eqautoActive.setXmlParam("y", integerToString(eqautoActive_Y));
  151. }
  152. eqauto.onleaveArea ()
  153. {
  154. eqautoActive.setXmlParam("y", integerToString(eqautoActive_Y));
  155. }
  156. eqauto.onEnterArea ()
  157. {
  158. if (autoDown) eqautoActive.setXmlParam("y", integerToString(eqautoActive_Y+1));
  159. }
  160. EqButton.onLeftClick()
  161. {
  162. manual_set = 1;
  163. for(int i=0; i<10; i++) setEqBand(i, EqButton.setTo);
  164. manual_set = 0;
  165. }
  166. System.onEqFreqChanged (boolean isoonoff)
  167. {
  168. if (isoonoff == 1)
  169. {
  170. frequencyLabel.setXmlParam("image", "equalizer.labels.iso");
  171. for(int i=0; i<10; i++) frameGroup.findObject("eq"+integerToString(i+1)).setXmlParam("tooltip", getToken(ISOBANDS,",",i));
  172. }
  173. else
  174. {
  175. frequencyLabel.setXmlParam("image", "equalizer.labels.winamp");
  176. for(int i=0; i<10; i++) frameGroup.findObject("eq"+integerToString(i+1)).setXmlParam("tooltip", getToken(WINAMPBANDS,",",i));
  177. }
  178. }
  179. system.onEqBandChanged(int band, int value)
  180. {
  181. if (manual_set) return;
  182. String t;
  183. Float f = value;
  184. f = f / 10.5;
  185. WinampConfigGroup eqwcg = WinampConfig.getGroup("{72409F84-BAF1-4448-8211-D84A30A1591A}");
  186. if (eqwcg.getInt("frequencies") == 1) {
  187. if (f >= 0) t = "EQ: " + translate(getToken(ISOBANDS,",",band)) + ": +" + floattostring(f, 1) + " "+ translate("dB");
  188. else t = "EQ: " + translate(getToken(ISOBANDS,",",band)) + ": " + floattostring(f, 1) + " "+ translate("dB");
  189. }
  190. else {
  191. if (f >= 0) t = "EQ: " + translate(getToken(WINAMPBANDS,",",band)) + ": +" + floattostring(f, 1) + " "+ translate("dB");
  192. else t = "EQ: " + translate(getToken(WINAMPBANDS,",",band)) + ": " + floattostring(f, 1) + " "+ translate("dB");
  193. }
  194. SongTicker.sendAction("showinfo", t, 0, 0, 0, 0);
  195. }
  196. system.onEqPreampChanged(int value)
  197. {
  198. slider s = getScriptGroup().findObject("preamp");
  199. value = s.getPosition(); // Somehow this function returns a range from [-127;125] with hotpos -3, so we take the slider instead
  200. String t = "EQ: " + translate("Preamp:") + " ";
  201. Float f = value;
  202. f = f / 10.5;
  203. if (f >= 0) t += "+"+floattostring(f, 1) + " "+ translate("dB");
  204. else t += floattostring(f, 1) + " "+ translate("dB");
  205. SongTicker.sendAction("showinfo", t, 0, 0, 0, 0);
  206. }