Skip to content

Instantly share code, notes, and snippets.

@respatialized
Created September 8, 2014 04:59
Show Gist options
  • Save respatialized/2283649606a2f59f0dc4 to your computer and use it in GitHub Desktop.
Save respatialized/2283649606a2f59f0dc4 to your computer and use it in GitHub Desktop.
soundgrid01
import codeanticode.syphon.*;
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioInput in;
SyphonServer server;
FFT fft;
int rows = 10;
int cols = 64;
void setup(){
background(205);
size(500,500,P3D);
frameRate(60);
smooth();
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 2048);
fft = new FFT(in.bufferSize(), in.sampleRate());
fft.logAverages(512,108);
println(fft.avgSize());
server = new SyphonServer(this, "Processing Syphon");
}
void draw(){
rect(0,0,width,height);
fft.forward(in.mix);
for (int x=0; x<cols;x++){
for (int y = 0; y<rows;y++){
int s = ((x*rows)+y)-1;
if (s<0){s=0;}
colorMode(HSB);
fill(10,0,fft.getAvg(s)*35);
noStroke();
rect((width/cols)*x,(height/rows)*y,(width/cols)*x+(width/cols),(height/rows)*y+(height/rows));
}
}
server.sendScreen();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment