Hello everyone! I am new in Processing and I could use some help. I have this code that makes use of the Minim library and visualizes a given sound file:
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;
int r = 200;
float rad = 700;
void setup()
{
size(500, 300);
minim = new Minim(this);
player = minim.loadFile("song.mp3");
meta = player.getMetaData();
beat = new BeatDetect();
player.loop();
background(-1);
noCursor();
}
void draw()
{
float t = map(mouseX, 0, width, 0, 1);
beat.detect(player.mix);
fill(#1A1F18, 20);
noStroke();
rect(0, 0, width, height);
translate(width/2, height/2);
noFill();
fill(0, 10);
if (beat.isOnset()) rad = rad*0.0001;
else rad = 1.70;
ellipse(0, 0, 0, 0);
stroke(-1, 500);
int bsize = player.bufferSize();
for (int i = 0; i < bsize - 1; i+=500)
beginShape();
noFill();
stroke(0, 50);
for (int i = 0; i < bsize; i+=130)
{
float x2 = (r + player.left.get(i)*1000)*cos(i*2*PI/bsize);
float y2 = (r + player.left.get(i)*1000)*sin(i*2*PI/bsize);
vertex(x2/2, y2/2);
pushStyle();
stroke(-1);
strokeWeight(2);
point(x2, y2/2);
popStyle();
}
endShape();
}
I would like to ask how can the code be changed so that the visualization will actually respond to the user’s microphone in real time (instead of the mp3 file). I found some examples that use the AudioInput In but I messed up (as I am not sure what to change).
Thank you in advance