Guest User

Untitled

a guest
Jul 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import processing.sound.*;
  2.  
  3. FFT fft;
  4. AudioIn in;
  5. int bands = 512;
  6. float[] spectrum = new float[bands];
  7.  
  8. void setup() {
  9. fullScreen();
  10. //fullScreen();
  11. background(255);
  12. colorMode(HSB);
  13.  
  14. fft = new FFT(this, bands);
  15. in = new AudioIn(this, 1);
  16.  
  17. in.start();
  18. fft.input(in);
  19. //bands/=4;
  20. }
  21.  
  22. void draw()
  23. {
  24. int effect = 1020;
  25. background(255);
  26. translate(width/2, height/2);
  27. fft.analyze(spectrum);
  28. noStroke();
  29. int k = 10;
  30. //fill(random(0, 255),random(0, 255) ,random(0, 255));
  31. int m = width/7;
  32. for(int i = 0; i < bands; i++)
  33. {
  34. fill(255*i/bands, 250, 200);
  35. //line(width/2, height/2, (150*cos(TWO_PI*i/bands) * spectrum[i] + width/2) + 150*cos(TWO_PI*i/bands), (150*sin(TWO_PI*i/bands)*spectrum[i] + height/2) + 150*sin(TWO_PI*i/bands));
  36. triangle(0, 0, (effect*cos(TWO_PI*i/bands) * spectrum[i]) + m*cos(TWO_PI*i/bands), (effect*sin(TWO_PI*i/bands)*spectrum[i]) + m*sin(TWO_PI*i/bands), (effect*cos((TWO_PI*i+k)/bands) * spectrum[i]) + m*cos((TWO_PI*i+k)/bands), (effect*sin((TWO_PI*i+k)/bands)*spectrum[i]) + m*sin((TWO_PI*i+k)/bands));
  37. }
  38. }
Add Comment
Please, Sign In to add comment