1
0

visualizer.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: visualizer.m
  4. Version: 1.4
  5. Type: maki
  6. Date: 07. Okt. 2007 - 19:56
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. Note: This script handles also the timer reflection
  12. -----------------------------------------------------
  13. ---------------------------------------------------*/
  14. #include <lib/std.mi>
  15. Function refreshVisSettings();
  16. Function setVis (int mode);
  17. Function ProcessMenuResult (int a);
  18. Global Group scriptGroup;
  19. Global Vis visualizer;
  20. Global Text tmr;
  21. Global PopUpMenu visMenu;
  22. Global PopUpMenu specmenu;
  23. Global PopUpMenu oscmenu;
  24. Global PopUpMenu pksmenu;
  25. Global PopUpMenu anamenu;
  26. Global PopUpMenu stylemenu;
  27. Global Int currentMode, a_falloffspeed, p_falloffspeed, a_coloring;
  28. Global Boolean show_peaks, isShade;
  29. Global layer trigger;
  30. Global Layout thislayout;
  31. Global Container main;
  32. System.onScriptLoaded()
  33. {
  34. scriptGroup = getScriptGroup();
  35. thislayout = scriptGroup.getParentLayout();
  36. main = thislayout.getContainer();
  37. visualizer = scriptGroup.findObject("visual");
  38. trigger = scriptGroup.findObject("main.vis.trigger");
  39. visualizer.setXmlParam("peaks", integerToString(show_peaks));
  40. visualizer.setXmlParam("peakfalloff", integerToString(p_falloffspeed));
  41. visualizer.setXmlParam("falloff", integerToString(a_falloffspeed));
  42. refreshVisSettings ();
  43. }
  44. refreshVisSettings ()
  45. {
  46. currentMode = getPrivateInt(getSkinName(), "Visualizer Mode", 1);
  47. show_peaks = getPrivateInt(getSkinName(), "Visualizer show Peaks", 1);
  48. a_falloffspeed = getPrivateInt(getSkinName(), "Visualizer analyzer falloff", 3);
  49. p_falloffspeed = getPrivateInt(getSkinName(), "Visualizer peaks falloff", 2);
  50. a_coloring = getPrivateInt(getSkinName(), "Visualizer analyzer coloring", 0);
  51. visualizer.setXmlParam("peaks", integerToString(show_peaks));
  52. visualizer.setXmlParam("peakfalloff", integerToString(p_falloffspeed));
  53. visualizer.setXmlParam("falloff", integerToString(a_falloffspeed));
  54. if (a_coloring == 0)
  55. {
  56. visualizer.setXmlParam("coloring", "Normal");
  57. }
  58. else if (a_coloring == 1)
  59. {
  60. visualizer.setXmlParam("coloring", "Normal");
  61. }
  62. else if (a_coloring == 2)
  63. {
  64. visualizer.setXmlParam("coloring", "Fire");
  65. }
  66. else if (a_coloring == 3)
  67. {
  68. visualizer.setXmlParam("coloring", "Line");
  69. }
  70. setVis (currentMode);
  71. }
  72. trigger.onLeftButtonDown (int x, int y)
  73. {
  74. if (isKeyDown(VK_ALT) && isKeyDown(VK_SHIFT) && isKeyDown(VK_CONTROL))
  75. {
  76. if (visualizer.getXmlParam("fliph") == "1")
  77. {
  78. visualizer.setXmlParam("fliph", "0");
  79. }
  80. else
  81. {
  82. visualizer.setXmlParam("fliph", "1");
  83. }
  84. return;
  85. }
  86. currentMode++;
  87. if (currentMode == 6)
  88. {
  89. currentMode = 0;
  90. }
  91. setVis (currentMode);
  92. complete;
  93. }
  94. trigger.onRightButtonUp (int x, int y)
  95. {
  96. visMenu = new PopUpMenu;
  97. specmenu = new PopUpMenu;
  98. oscmenu = new PopUpMenu;
  99. pksmenu = new PopUpMenu;
  100. anamenu = new PopUpMenu;
  101. stylemenu = new PopUpMenu;
  102. visMenu.addCommand("Presets:", 999, 0, 1);
  103. visMenu.addCommand("No Visualization", 100, currentMode == 0, 0);
  104. specmenu.addCommand("Thick Bands", 1, currentMode == 1, 0);
  105. specmenu.addCommand("Thin Bands", 2, currentMode == 2, 0);
  106. visMenu.addSubMenu(specmenu, "Spectrum Analyzer");
  107. oscmenu.addCommand("Solid", 3, currentMode == 3, 0);
  108. oscmenu.addCommand("Dots", 4, currentMode == 4, 0);
  109. oscmenu.addCommand("Lines", 5, currentMode == 5, 0);
  110. visMenu.addSubMenu(oscmenu, "Oscilloscope");
  111. visMenu.addSeparator();
  112. visMenu.addCommand("Options:", 102, 0, 1);
  113. visMenu.addCommand("Show Peaks", 101, show_peaks == 1, 0);
  114. pksmenu.addCommand("Slower", 200, p_falloffspeed == 0, 0);
  115. pksmenu.addCommand("Slow", 201, p_falloffspeed == 1, 0);
  116. pksmenu.addCommand("Moderate", 202, p_falloffspeed == 2, 0);
  117. pksmenu.addCommand("Fast", 203, p_falloffspeed == 3, 0);
  118. pksmenu.addCommand("Faster", 204, p_falloffspeed == 4, 0);
  119. visMenu.addSubMenu(pksmenu, "Peak Falloff Speed");
  120. anamenu.addCommand("Slower", 300, a_falloffspeed == 0, 0);
  121. anamenu.addCommand("Slow", 301, a_falloffspeed == 1, 0);
  122. anamenu.addCommand("Moderate", 302, a_falloffspeed == 2, 0);
  123. anamenu.addCommand("Fast", 303, a_falloffspeed == 3, 0);
  124. anamenu.addCommand("Faster", 304, a_falloffspeed == 4, 0);
  125. visMenu.addSubMenu(anamenu, "Analyzer Falloff Speed");
  126. stylemenu.addCommand("Normal", 400, a_coloring == 0, 0);
  127. stylemenu.addCommand("Fire", 402, a_coloring == 2, 0);
  128. stylemenu.addCommand("Line", 403, a_coloring == 3, 0);
  129. //visMenu.addSubMenu(stylemenu, "Analyzer Coloring");
  130. ProcessMenuResult (visMenu.popAtMouse());
  131. delete visMenu;
  132. delete specmenu;
  133. delete oscmenu;
  134. delete pksmenu;
  135. delete anamenu;
  136. delete stylemenu;
  137. complete;
  138. }
  139. ProcessMenuResult (int a)
  140. {
  141. if (a < 1) return;
  142. if (a > 0 && a <= 6 || a == 100)
  143. {
  144. if (a == 100) a = 0;
  145. setVis(a);
  146. }
  147. else if (a == 101)
  148. {
  149. show_peaks = (show_peaks - 1) * (-1);
  150. visualizer.setXmlParam("peaks", integerToString(show_peaks));
  151. setPrivateInt(getSkinName(), "Visualizer show Peaks", show_peaks);
  152. }
  153. else if (a >= 200 && a <= 204)
  154. {
  155. p_falloffspeed = a - 200;
  156. visualizer.setXmlParam("peakfalloff", integerToString(p_falloffspeed));
  157. setPrivateInt(getSkinName(), "Visualizer peaks falloff", p_falloffspeed);
  158. }
  159. else if (a >= 300 && a <= 304)
  160. {
  161. a_falloffspeed = a - 300;
  162. visualizer.setXmlParam("falloff", integerToString(a_falloffspeed));
  163. setPrivateInt(getSkinName(), "Visualizer analyzer falloff", a_falloffspeed);
  164. }
  165. else if (a >= 400 && a <= 403)
  166. {
  167. a_coloring = a - 400;
  168. if (a_coloring == 0)
  169. {
  170. visualizer.setXmlParam("coloring", "Normal");
  171. }
  172. else if (a_coloring == 1)
  173. {
  174. visualizer.setXmlParam("coloring", "Normal");
  175. }
  176. else if (a_coloring == 2)
  177. {
  178. visualizer.setXmlParam("coloring", "Fire");
  179. }
  180. else if (a_coloring == 3)
  181. {
  182. visualizer.setXmlParam("coloring", "Line");
  183. }
  184. setPrivateInt(getSkinName(), "Visualizer analyzer coloring", a_coloring);
  185. }
  186. }
  187. setVis (int mode)
  188. {
  189. setPrivateInt(getSkinName(), "Visualizer Mode", mode);
  190. if (mode == 0)
  191. {
  192. visualizer.setMode(0);
  193. }
  194. else if (mode == 1)
  195. {
  196. visualizer.setXmlParam("bandwidth", "wide");
  197. visualizer.setMode(1);
  198. }
  199. else if (mode == 2)
  200. {
  201. visualizer.setXmlParam("bandwidth", "thin");
  202. visualizer.setMode(1);
  203. }
  204. else if (mode == 3)
  205. {
  206. visualizer.setXmlParam("oscstyle", "solid");
  207. visualizer.setMode(2);
  208. }
  209. else if (mode == 4)
  210. {
  211. visualizer.setXmlParam("oscstyle", "dots");
  212. visualizer.setMode(2);
  213. }
  214. else if (mode == 5)
  215. {
  216. visualizer.setXmlParam("oscstyle", "lines");
  217. visualizer.setMode(2);
  218. }
  219. currentMode = mode;
  220. }
  221. // Sync Normal and Shade Layout
  222. main.onBeforeSwitchToLayout(Layout oldlayout, Layout newlayout)
  223. {
  224. if (newlayout != thislayout)
  225. {
  226. return;
  227. }
  228. refreshVisSettings();
  229. }