teekayeh

Music Visualizer 2

Oct 30th, 2019
6,240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. // Project 02
  2.  
  3. // Note: You Will need the Minim Sound Library added to make this work.
  4.  
  5. float n4;
  6. float n6;
  7.  
  8. //MUSIC
  9. import ddf.minim.*;
  10. import ddf.minim.signals.*;
  11. Minim minim;
  12. AudioPlayer mySound;
  13.  
  14. //MAIN SETUP
  15. void setup () {
  16. fullScreen(P3D);
  17. noCursor();
  18. smooth();
  19. background (0);
  20. frameRate(24);
  21.  
  22. //MUSIC | Add mp3 to file and change name of "Murph.mp3" to your song name
  23. minim = new Minim(this);
  24. mySound = minim.loadFile("Murph.mp3");
  25. mySound.play();
  26. }
  27.  
  28. void draw () {
  29.  
  30. fill(0,50);
  31. noStroke();
  32. rect(0, 0, width, height);
  33. translate(width/2, height/2);
  34.  
  35. for (int i = 0; i < mySound.bufferSize() - 1; i++) {
  36.  
  37. float angle = sin(i+n4)* 10;
  38. float angle2 = sin(i+n6)* 300;
  39.  
  40. float x = sin(radians(i))*(angle2+30);
  41. float y = cos(radians(i))*(angle2+30);
  42.  
  43. float x3 = sin(radians(i))*(500/angle);
  44. float y3 = cos(radians(i))*(500/angle);
  45.  
  46. fill (#000000, 90); //yellow
  47. ellipse(x, y, mySound.left.get(i)*10, mySound.left.get(i)*10);
  48.  
  49. fill ( #ffffff, 60); //wt
  50. rect(x3, y3, mySound.left.get(i)*20, mySound.left.get(i)*10);
  51.  
  52. fill ( #ff9800 , 90); //orange
  53. rect(x, y, mySound.right.get(i)*10, mySound.left.get(i)*10);
  54.  
  55.  
  56. fill( #ffffff , 70); //wt
  57. rect(x3, y3, mySound.right.get(i)*10, mySound.right.get(i)*20);
  58. }
  59.  
  60. n4 += 0.008;
  61. n6 += 0.04;
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment