Advertisement
brunnonevs

Untitled

Sep 18th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. import processing.sound.*;
  2. import processing.pdf.*;
  3.  
  4. PGraphicsPDF pdf;
  5. AudioIn in;
  6. Amplitude amp;
  7.  
  8. boolean recording;
  9. float b;
  10. float sum;
  11. float sFactor= 0.25;
  12. float rmsScaled;
  13. float z = (random(10));
  14.  
  15. void setup() {
  16. size(600, 1000);
  17. background(0);
  18. translate(width/2, height/2);
  19. loop();
  20.  
  21. surface.setResizable(true);
  22.  
  23. // Create the Input stream
  24. in = new AudioIn(this, 0);
  25. in.play();
  26. amp = new Amplitude(this);
  27. amp.input(in);
  28. frameRate(5);
  29.  
  30. pdf = (PGraphicsPDF) createGraphics(width, height, PDF, "pause-resume.pdf");
  31. }
  32.  
  33. void draw() {
  34. fill(0,241);
  35. stroke(255);
  36. sum = (amp.analyze() )* sFactor;
  37. rmsScaled = sum * (height/2) * mouseY;
  38. // println(rmsScaled);
  39. // println(frameCount);
  40. println(b);
  41.  
  42.  
  43. beginShape();
  44.  
  45. for(int i = 0; i < frameCount*2; i++){
  46. if(i%2==0){
  47. // b = random(0,(rmsScaled)/(100-i));
  48. b = int(random(0,rmsScaled*i/80000));
  49. float radius = i + b;
  50. float x = cos(radians(i * 3.6)) * radius;
  51. float y = sin(radians(i * 3.6)) * radius;
  52. curveVertex(width/2+x, height/2+y);
  53. }
  54. if(i%2==1){
  55. b = int(random(0,rmsScaled*i/80000));
  56. float radius = i - b;
  57. float x = cos(radians(i * 3.6)) * radius;
  58. float y = sin(radians(i * 3.6)) * radius;
  59. // curveVertex(width/2+x, height/2-y);
  60. curveVertex(width/2+x, height/2+y);
  61. }
  62. }
  63. endShape();
  64. }
  65.  
  66. void keyPressed() {
  67. if (keyCode == ENTER){
  68. saveFrame("image_####.jpg");
  69. }
  70. if (key == 'r') {
  71. if (recording) {
  72. endRecord();
  73. println("Recording stopped.");
  74. recording = false;
  75. } else {
  76. beginRecord(pdf);
  77. println("Recording started.");
  78. recording = true;
  79. }
  80. } else if (key == 'q') {
  81. if (recording) {
  82. endRecord();
  83. }
  84. exit();
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement