Advertisement
Guest User

Untitled

a guest
May 8th, 2009
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.69 KB | None | 0 0
  1.  
  2. // constants
  3. int all_keys = 128 - 24; // strip octave 0 and octave 10
  4. int channels = 16;
  5. int key_width = 7;
  6. int key_height = 20;
  7. int ch_height = 36;
  8. int text_height = 8;
  9. int play_info_section_width = 200;
  10.  
  11. color color_background = #000008;
  12. color color_white_key = #AaAaAa;
  13. color color_basic_stroke = #000000;
  14. color color_black_key = #000000;
  15. color color_black_key_edge = #FfFfFf;
  16. color color_bright = #FfFfE0;
  17. color color_usual = #3060C0;
  18. color color_dark = #1830C0;
  19. color color_hidden = #000030;
  20.  
  21. color color_ch_base = color_bright;
  22. color color_ch_colored = color_usual;
  23. color color_ch_dark = color_dark;
  24. color color_ch_hidden = color_hidden;
  25. color color_ch_text_colored = color_ch_colored;
  26. color color_ch_text_base = color_ch_base;
  27. color color_ch_text_dark = color_ch_dark;
  28. color color_ch_text_hidden = color_ch_hidden;
  29.  
  30. PFont font_title;
  31. PFont font16;
  32. PFont font8;
  33.  
  34. String [] ch_types = {
  35. "MIDI", "MIDI", "MIDI", "MIDI", "MIDI", "MIDI", "MIDI", "MIDI",
  36. "MIDI", "MIDI", "MIDI", "MIDI", "MIDI", "MIDI", "MIDI", "MIDI" };
  37.  
  38. void setup ()
  39. {
  40. font_title = loadFont ("PalatinoLinotype-BoldItalic-16.vlw");
  41. font16 = loadFont ("Tahoma-16.vlw");
  42. font8= loadFont ("Tahoma-8.vlw");
  43. size (800, ch_height * channels);
  44. background (color_background);
  45.  
  46. for (int i = 0; i < channels; i++) {
  47. setupChannelInfo (i);
  48. }
  49. for (int i = 0; i < channels; i++) {
  50. setupKeyboard (i);
  51. }
  52.  
  53. pushMatrix ();
  54. translate (400, 0);
  55. setupPlayInfoSection ();
  56. popMatrix ();
  57.  
  58. pushMatrix ();
  59. translate (400, 160);
  60. setupSpectrumAnalyzer ();
  61. }
  62.  
  63. void setupSpectrumAnalyzer ()
  64. {
  65. stroke (color_usual);
  66. line (0, 0, 380, 0);
  67. textFont (font8);
  68. fill (color_dark);
  69. text ("SPECTRUM ANALYZER", 300, text_height * 2 - 2);
  70. stroke (color_hidden);
  71. fill (color_hidden);
  72. rect (50, text_height * 2, 320, 100);
  73. }
  74.  
  75. void setupPlayInfoSection ()
  76. {
  77. setupTitleArea ();
  78. setupDriverInfo ();
  79. setupPlayStatus ();
  80. setupSongStatus ();
  81. }
  82.  
  83. void setupTitleArea ()
  84. {
  85. // title area
  86. textFont (font_title);
  87. fill (color_ch_text_colored);
  88. text ("MLDSP", 0, 16);
  89. stroke (color_ch_colored);
  90. line (0, 18, 60, 18);
  91. textFont (font8);
  92. fill (color_ch_text_dark);
  93. text ("music visualizer and file selector", 70, text_height);
  94. fill (color_ch_text_colored);
  95. text ("ver 0.01 / for moonlight 2.0 (C)2009 atsushieno", 70, text_height * 2);
  96. stroke (color_ch_dark);
  97. line (70, 18, 310, 18);
  98. }
  99.  
  100. void setupDriverInfo ()
  101. {
  102. textFont (font8);
  103. fill (color_ch_text_dark);
  104. text ("DRIVER \u25B6", 0, text_height * 4);
  105. fill (color_ch_text_colored);
  106. text ("SMF plugin", 50, text_height * 4);
  107. text ("0.01", 100, text_height * 4);
  108. text ("(C)2009 atsushieno", 130, text_height * 4);
  109. }
  110.  
  111. void setupPlayStatus ()
  112. {
  113. stroke (color_ch_hidden);
  114. fill (color_background);
  115. rect (40, text_height * 9, 150, text_height);
  116. rect (190, text_height * 9, 20, text_height);
  117. textFont (font8);
  118. fill (color_ch_text_colored);
  119. text ("[>PLAY", 40, text_height * 11);
  120. fill (color_ch_text_hidden);
  121. text ("||PAUSE", 80, text_height * 11);
  122. text ("[]STOP", 120, text_height * 11);
  123. text ("\\\\FADE", 160, text_height * 11);
  124. text (">>FF", 40, text_height * 12);
  125. text ("<<REW", 80, text_height * 12);
  126. text ("<]LOAD", 120, text_height * 12);
  127. }
  128.  
  129. void setupSongStatus ()
  130. {
  131. // labels
  132. fill (color_ch_colored);
  133. rect (230, text_height * 5, 4, text_height * 2);
  134. text ("PASSED", 240, text_height * 6);
  135. text (" TIME", 240, text_height * 7);
  136. rect (230, text_height * 8, 4, text_height * 2);
  137. text ("TICK", 240, text_height * 9);
  138. text (" COUNT", 240, text_height * 10);
  139. rect (230, text_height * 11, 4, text_height * 2);
  140. text ("TIMER", 240, text_height * 12);
  141. text (" CYCLE", 240, text_height * 13);
  142. rect (230, text_height * 14, 4, text_height * 2);
  143. text ("LOOP", 240, text_height * 15);
  144. text (" COUNT", 240, text_height * 16);
  145. rect (230, text_height * 17, 4, text_height * 2);
  146. text ("VOLUME", 240, text_height * 18);
  147. text (" RATIO", 240, text_height * 19);
  148. // values
  149. textFont (font16);
  150. text ("00:00:00", 300, text_height * 7);
  151. text ("00000000", 300, text_height * 10);
  152. text ("00000200", 300, text_height * 13);
  153. text ("00000000", 300, text_height * 16);
  154. text ("100%", 300, text_height * 19);
  155. }
  156.  
  157. void setupChannelInfo (int channel)
  158. {
  159. float yText1 = getChannelYPos (channel) + text_height;
  160. float yText2 = getChannelYPos (channel) + text_height * 2;
  161. // channel type and number
  162. fill (color_ch_text_colored);
  163. textFont (font16);
  164. textSize (16.0);
  165. text (nf (channel + 1, 2), 35, yText2);
  166. textFont (font8);
  167. fill (color_ch_text_colored);
  168. text (ch_types [channel], 0.0, yText1);
  169. fill (color_ch_text_base);
  170. text ("TRACK.", 0.0, yText2);
  171. // key-on meter
  172. fill (color_ch_colored);
  173. rect (80, getChannelYPos (channel), 20, text_height);
  174. fill (color_ch_colored);
  175. rect (100, getChannelYPos (channel), 6 * (16 - channel), text_height);
  176. // portament, LFO
  177. stroke (color_ch_colored);
  178. line (340, getChannelYPos (channel) + 2, 360, getChannelYPos (channel) + text_height - 2);
  179. fill (color_ch_text_colored);
  180. text (nf (1000, 5), 364, getChannelYPos (channel) + text_height);
  181. // channel parameters
  182. fill (color_ch_text_base);
  183. text ("KN:o" + nf (5, 1) + "c", 80, yText2);
  184. text ("TN:" + nf (1, 3), 130, yText2);
  185. text ("VEL:" + nf (110, 3), 180, yText2);
  186. text ("GT:" + nf (8, 3), 230, yText2);
  187. text ("DT:" + nf (-8, 3), 280, yText2);
  188. text ("M:--------", 340, yText2);
  189. }
  190.  
  191. void setupKeyboard (int channel)
  192. {
  193. int octaves = all_keys / 12;
  194. for (int octave = 0; octave < octaves; octave++) {
  195. drawOctave (channel, octave);
  196. }
  197. }
  198.  
  199. float getChannelYPos (int channel)
  200. {
  201. return channel * ch_height;
  202. }
  203.  
  204. void drawOctave (int channel, int octave)
  205. {
  206. float x = octave * key_width * 7;
  207. float y = getChannelYPos (channel) + ch_height - key_height;
  208. for (int k = 0; k < 7; k++) {
  209. // white keys
  210. strokeJoin (ROUND);
  211. strokeWeight (1.0);
  212. stroke (color_basic_stroke);
  213. fill (color_white_key);
  214. rect (x + k * key_width, y, key_width, key_height);
  215. }
  216. for (int k = 0; k < 7; k++) {
  217. // black keys
  218. if (k != 2 && k != 6) {
  219. strokeJoin (BEVEL);
  220. strokeWeight (1.0);
  221. stroke (color_basic_stroke);
  222. fill (color_black_key);
  223. float blackKeyStartX = x + (k + 0.8) * key_width;
  224. float blackKeyWidth = key_width * 0.4;
  225. float blackKeyHeight = key_height / 2.0;
  226. rect (blackKeyStartX, y + 1, blackKeyWidth, blackKeyHeight);
  227. float bottom = y + blackKeyHeight + 1;
  228. stroke (color_black_key_edge);
  229. line (blackKeyStartX + 1, bottom, blackKeyStartX + blackKeyWidth - 1, bottom);
  230. }
  231. }
  232. }
  233.  
  234.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement