Making things move with sound

I made a few processing sketches that use minim to generate graphics using sound.

1st sketch – diagonals

import ddf.minim.*;
Minim minim;
AudioInput in;

float xPos;
float yPos;
float xEnd;
float yEnd;
float ran;
float numl;
int num ;

float[] lines = new float[num];

float wide;

void setup() {
size(1200, 800, P3D);
num = int(numl);
float ran = random(1);
frameRate(60);
smooth();
minim = new Minim(this);
in = minim.getLineIn();
wide = random(4,10);
}

void draw() {

background(0);
numl =- (10/in.left.get(1000)+in.right.get(1000));
xPos = 0;
yPos = random(0, 800);
xEnd = 1200;
yEnd = random(0, 800);
for (float i = 0; i < numl; i++) {
line(xPos, yPos, random(50), xEnd, yEnd,random(100,-100));

}

strokeWeight(wide);
float ran = random(10.);
if(ran <= 2) stroke(#40FFA6);
else if(ran > 0 && ran < 3) stroke(#00AFD6);
else if(ran > 4 && ran < 6) stroke(#D28BE0);
else if(ran > 6 && ran < 8) stroke(#FF8800);
else if(ran > 8 && ran < 10) stroke(#FFEE51);
}
}

 

2nd sketch – sphere

import ddf.minim.*;
Minim minim;
AudioInput in;
int radius = 250;
float [] xPos = new float [360];
float [] yPos = new float [360];

void setup() {
size(800, 800);
smooth();
minim = new Minim(this);
in = minim.getLineIn();

for (int i = 0; i < 360; i++) {
int deg = i * 1;
float angle = radians(deg);
xPos[i] = cos(angle) * radius;
yPos[i] = sin(angle) * radius;
}
}
void draw() {
background(0);
translate(width/2, height/2);
stroke(random(10, 255));

for (int i = 0; i < in.bufferSize() – 1; i++) {
float lm = lerp(310, 350+ 50*in.left.get(i), random(0, 0.5));
float rm = lerp(310, 350+ 50*in.right.get(i), random(0, 0.5));

strokeWeight(abs(4*in.left.get(i)));
stroke(random(255), random(255), random(255));
int random1= (int)random(359);
int random2= (int)random(359); line(xPos[random1], yPos[random1], 1000* in.left.get(i), 200* in.right.get(i));
}
}

Leave a Comment.