Change Graphic Size with Sound Input
in
Core Library Questions
•
1 year ago
I hope i can explain myself correctly, i would like the graphics to change their size thru to the sound input.
I hope someone can help me on this.
What i have so far...
import ddf.minim.*;
Minim minim;
AudioInput in;
int numBlobs = 3;
int[] blocoPx = {
0, 120, 90
};
int[] blocoPy = {
0, 120, 45
};
int[] blocoDx = {
1, 1, 1
};
int[] blocoDy = {
1, 1, 1
};
PGraphics pg;
int[][] vy, vx;
void setup() {
size(900, 700);
pg = createGraphics(200, 112, P2D);
vy = new int[numBlobs][pg.height];
vx = new int[numBlobs][pg.width];
minim = new Minim(this);
minim.debugOn();
in = minim.getLineIn(Minim.STEREO, 600);
}
void draw() {
for (int i=0; i<numBlobs; ++i) {
blocoPx[i]+=blocoDx[i];
blocoPy[i]+=blocoDy[i];
if (blocoPx[i] < 0) {
blocoDx[i] = 1;
}
if (blocoPx[i] > pg.width) {
blocoDx[i] = -1;
}
if (blocoPy[i] < 0) {
blocoDy[i] = 1;
}
if (blocoPy[i] > pg.height) {
blocoDy[i]=-1;
}
for (int x = 0; x < pg.width; x++) {
vx[i][x] = int(sq(blocoPx[i]-x));
}
for (int y = 0; y < pg.height; y++) {
vy[i][y] = int(sq(blocoPy[i]-y));
}
}
pg.beginDraw();
pg.loadPixels();
for (int y = 0; y < pg.height; y++) {
for (int x = 0; x < pg.width; x++) {
int m = 1;
for (int i = 0; i < numBlobs; i++) {
m += 200000/(vy[i][y] + vx[i][x]+1);
}
pg.pixels[x+y*pg.width] = color(0, m+x, (x+m+y)/2);
}
}
pg.updatePixels();
pg.endDraw();
image (pg, 0, 0, width, height) ;
float av = map (in.mix.level(),0., 0.6, 1, 20) ;
}
thank you in advance
1