Advertisement
Guest User

Processing shiet

a guest
Dec 14th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. import ddf.minim.*;
  2. import ddf.minim.analysis.*;
  3. import ddf.minim.effects.*;
  4. import ddf.minim.signals.*;
  5. import ddf.minim.spi.*;
  6. import ddf.minim.ugens.*;
  7.  
  8. Minim minim;
  9. AudioPlayer song;
  10. BeatDetect beat;
  11. BeatListener bl;
  12.  
  13. float kickSize, snareSize, hatSize;
  14. int counter = 0;
  15. class BeatListener implements AudioListener
  16. {
  17. private BeatDetect beat;
  18. private AudioPlayer source;
  19.  
  20. BeatListener(BeatDetect beat, AudioPlayer source)
  21. {
  22. this.source = source;
  23. this.source.addListener(this);
  24. this.beat = beat;
  25. }
  26.  
  27. void samples(float[] samps)
  28. {
  29. beat.detect(source.mix);
  30. }
  31.  
  32. void samples(float[] sampsL, float[] sampsR)
  33. {
  34. beat.detect(source.mix);
  35. }
  36. }
  37.  
  38. float detail = 0.6; // amount of detail in the noise (0-1)
  39. float increment = 0.002; // how quickly to move through noise (0-1)
  40. float yIncrement = 0.5; // how much to change b/w individual waves (0-1)
  41. float timeIncrement = 0.01; // speed of change over time (0-1)
  42. float timeOffset = 0; // incremented each frame to shift the nois
  43.  
  44. //int rndOpac = int(random(0, 100));
  45. int rndOpac = 100;
  46. color[] colors = {
  47. color(3, 23, 39, rndOpac),
  48. color(18, 104, 114, rndOpac),
  49. color(11, 135, 125, rndOpac),
  50. color(24, 194, 156, rndOpac),
  51. color(136, 249, 212, rndOpac),
  52.  
  53. color(123, 42, 59, rndOpac),
  54. color(229, 118, 97, rndOpac),
  55. color(248, 197, 140, rndOpac),
  56. color(248, 231, 162, rndOpac),
  57. color(134, 221, 178, rndOpac),
  58.  
  59. color(229, 70, 97, rndOpac),
  60. color(255, 166, 68, rndOpac),
  61. color(153, 138, 47, rndOpac),
  62. color(44, 89, 79, rndOpac),
  63. color(0, 45, 64, rndOpac),
  64.  
  65. color(44, 62, 80, rndOpac),
  66. color(252, 67, 73, rndOpac),
  67. color(215, 218, 219, rndOpac),
  68. color(109, 188, 219, rndOpac),
  69. color(255, 255, 255, rndOpac),
  70.  
  71. color(46, 17, 45, rndOpac),
  72. color(29, 0, 50, rndOpac)
  73.  
  74. };
  75.  
  76.  
  77. void setup() {
  78. size(800, 800);
  79. noStroke();
  80.  
  81. minim = new Minim(this);
  82. song = minim.loadFile("Omnivore.mp3", 1024);
  83. song.play();
  84. beat = new BeatDetect(song.bufferSize(), song.sampleRate());
  85. beat.setSensitivity(300);
  86. kickSize = snareSize = hatSize = 16;
  87. bl = new BeatListener(beat, song);
  88. }
  89.  
  90. void bubblyshit() {
  91. background(255);
  92.  
  93. //Draw Circles Moving Left
  94. for (int i=0; i<100; i++) {
  95.  
  96. fill (0);
  97. int randRadius = int(random(0, 15));
  98. float xpoints = random(0, width);
  99. float ypoints = random(0, height);
  100. noStroke();
  101. ellipse(random(width), random(height), randRadius, randRadius);
  102. }
  103.  
  104. //Draw Circles Moving Right
  105. for (int i=0; i<100; i++) {
  106.  
  107. fill (255, 34, 20);
  108. int randRadius = int(random(0, 15));
  109. float xpoints = random(0, width);
  110. float ypoints = random(0, height);
  111. noStroke();
  112. ellipse(random(width), random(height), randRadius, randRadius);
  113. }
  114. }
  115.  
  116. void bubblyshit0() {
  117. background(255);
  118.  
  119. //Draw Circles Moving Left
  120. for (int i=0; i<100; i++) {
  121.  
  122. fill (0, 0, 255);
  123. int randRadius = int(random(0, 15));
  124. float xpoints = random(0, width);
  125. float ypoints = random(0, height);
  126. noStroke();
  127. ellipse(random(width), random(height), randRadius, randRadius);
  128. }
  129.  
  130. //Draw Circles Moving Right
  131. for (int i=0; i<100; i++) {
  132.  
  133. fill (0, 0, 255);
  134. int randRadius = int(random(0, 15));
  135. float xpoints = random(0, width);
  136. float ypoints = random(0, height);
  137. noStroke();
  138. ellipse(random(width), random(height), randRadius, randRadius);
  139. }
  140. }
  141. void bubblyshit1() {
  142. background(255);
  143.  
  144. //Draw Circles Moving Left
  145. for (int i=0; i<100; i++) {
  146.  
  147. fill (0,255, 0);
  148. int randRadius = int(random(0, 15));
  149. float xpoints = random(0, width);
  150. float ypoints = random(0, height);
  151. noStroke();
  152. ellipse(random(width), random(height), randRadius, randRadius);
  153. }
  154.  
  155. //Draw Circles Moving Right
  156. for (int i=0; i<100; i++) {
  157.  
  158. fill (0, 255, 0);
  159. int randRadius = int(random(0, 15));
  160. float xpoints = random(0, width);
  161. float ypoints = random(0, height);
  162. noStroke();
  163. ellipse(random(width), random(height), randRadius, randRadius);
  164. }
  165. }
  166.  
  167. void draw() {
  168. if ( beat.isKick() ) counter = (counter +1)%3;
  169. System.out.println(counter);
  170. //%int = #of sketches
  171. switch (counter){
  172. case 0: bubblyshit();
  173. case 1: bubblyshit0();
  174. case 2: bubblyshit1();
  175. }
  176. delay(3000);
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement