We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
can you fix your code please press ctrl + O make sure there is a space before and after your code
(noname, you can't quote people's code like that to correct it - the formatter converts things like * to italics and runs the lines together. leave it to the mods or the original poster)
my bad, is it ok now?, Dont use this often
Cross referencing to this link: http://stackoverflow.com/questions/23863091/find-volume-of-mic-input-using-minim-lib-in-processing/44038248#44038248
Kf