Using real time audio output

edited May 2017 in Library Questions

Hi guys, I have made a sketch that receives data my laptops microphone to make a visual react, but I would like the visual to react to real time audio output so I wouldnt be loading in a file

import processing.sound.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
BeatDetect beat;

PShape s1;
PShape s2;
PShape s3;
PShape s4;
PShape s12;

Amplitude amp;
AudioIn in;


void setup() {
  frameRate(60);
  size(1280, 800);
  s1 = loadShape("rnelogo.svg");
  s2 = loadShape("rnelogo.svg");
  s3 = loadShape("rnelogo.svg");
  s4 = loadShape("rnelogo.svg");
  s12 = loadShape("rnelogo.svg");

  amp = new Amplitude(this);
  in = new AudioIn(this, 0);
  in.start();
  amp.input(in);
  beat = new BeatDetect();

}

void draw() {
  background(240);

  translate(width/2 - s1.width/2, height/2 - s1.height/2);

  s1();
  s12();
  s2();
  s3();
  s4();
 if (amp.analyze()*100>28) {
   translate(-width/10, -height/10);
   scale(2.0); 
   currentS12 = (currentS12 * .99) + ((amp.analyze() * 1000) * .01);
   shape(s12);
}};

float currentS1 = 0;
void s1() {
  s1.disableStyle();  // Ignore the colors in the SVG
 noFill();    // Set the SVG fill to blue
  strokeWeight(amp.analyze()*100);  
  if (amp.analyze()*100 > 0.2) {  
    stroke(243,215,158);

    currentS1 = (currentS1 * .7) + ((amp.analyze() * 1000) * .3);
    strokeWeight(currentS1);

    //strokeWeight(amp.analyze()*1000);

  }
  shape(s1);
}
float currentS12 = 0;
void s12() {
  s1.disableStyle();  // Ignore the colors in the SVG
 noFill();    // Set the SVG fill to blue
  strokeWeight(amp.analyze()*100);  
  if (amp.analyze()*100 > 0.3) {  
    stroke(238,228,210);

    currentS12 = (currentS12 * .9) + ((amp.analyze() * 1000) * .1);
    strokeWeight(amp.analyze()*800);
  }
  shape(s12);
  println(amp.analyze()*100);
}

float currentS2 = 0;
void s2() {
  s2.disableStyle();  // Ignore the colors in the SVG
  noFill();    // Set the SVG fill to blue
  strokeWeight(amp.analyze()*100);  
  if (amp.analyze()*100 > 0.1) {  
    stroke(149,117,52);

    currentS2 = (currentS2 * .8) + ((amp.analyze() * 750) * .2);
    strokeWeight(currentS2);
  }
  shape(s2);
}

float currentS3 = 0;
void s3() {
  s3.disableStyle();  // Ignore the colors in the SVG
 noFill();    // Set the SVG fill to blue
  strokeWeight(amp.analyze()*100);  
  if (amp.analyze()*100 > 0.1) {  
    stroke(94,73,31);

    currentS3 = (currentS3 * .9) + ((amp.analyze() * 400) * .1);
    strokeWeight(currentS3);
  }
  shape(s3);
}

void s4() {
  s4.disableStyle();  // Ignore the colors in the SVG
  fill(255);    // Set the SVG fill to black
  stroke(255);
  strokeWeight(2);
  shape(s4);
}

Answers

Sign In or Register to comment.