Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.sound.*;
- import processing.pdf.*;
- PGraphicsPDF pdf;
- AudioIn in;
- Amplitude amp;
- boolean recording;
- float b;
- float sum;
- float sFactor= 0.25;
- float rmsScaled;
- float z = (random(10));
- void setup() {
- size(600, 1000);
- background(0);
- translate(width/2, height/2);
- loop();
- surface.setResizable(true);
- // Create the Input stream
- in = new AudioIn(this, 0);
- in.play();
- amp = new Amplitude(this);
- amp.input(in);
- frameRate(5);
- pdf = (PGraphicsPDF) createGraphics(width, height, PDF, "pause-resume.pdf");
- }
- void draw() {
- fill(0,241);
- stroke(255);
- sum = (amp.analyze() )* sFactor;
- rmsScaled = sum * (height/2) * mouseY;
- // println(rmsScaled);
- // println(frameCount);
- println(b);
- beginShape();
- for(int i = 0; i < frameCount*2; i++){
- if(i%2==0){
- // b = random(0,(rmsScaled)/(100-i));
- b = int(random(0,rmsScaled*i/80000));
- float radius = i + b;
- float x = cos(radians(i * 3.6)) * radius;
- float y = sin(radians(i * 3.6)) * radius;
- curveVertex(width/2+x, height/2+y);
- }
- if(i%2==1){
- b = int(random(0,rmsScaled*i/80000));
- float radius = i - b;
- float x = cos(radians(i * 3.6)) * radius;
- float y = sin(radians(i * 3.6)) * radius;
- // curveVertex(width/2+x, height/2-y);
- curveVertex(width/2+x, height/2+y);
- }
- }
- endShape();
- }
- void keyPressed() {
- if (keyCode == ENTER){
- saveFrame("image_####.jpg");
- }
- if (key == 'r') {
- if (recording) {
- endRecord();
- println("Recording stopped.");
- recording = false;
- } else {
- beginRecord(pdf);
- println("Recording started.");
- recording = true;
- }
- } else if (key == 'q') {
- if (recording) {
- endRecord();
- }
- exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement