Working on an interactive installation for class need help with code.
in
Contributed Library Questions
•
1 years ago
Hi all,
I'm fairly new to processing, I am currently taking a class at my school and for my final I am planning on doing a sound based installation that uses a mic to react to peoples voices and records the loudest tone from each interaction storing it in a projected radial grid of dots that builds over a 24 hr period. The final processing sketch will require something that reacts to peoples voices, is able to detect the loudest sound and save it (in an arrayList i think) and plot that data on a graphic mapped to the current time. I'm trying to break down those tasks into a series of sketches and then hopefully add them together in the end. So far I have a basic sketch that reacts to sound and I built another basic sketch that draws a dot based on the current time. I'm trying to figure out how to store a value (like the last position of the mouse X) and use it to draw a dot.
Here is a link to a pdf that shows what my goal is for the installation to look like.
Here is the code i made for the basic sound interaction just so you get an idea of the visuals im after.
I'm using ControlP5 and Minim libraries so you'll need those.
/*
Aldis Ozolins
Mediatecture Fall 2011
Shape test #1
*/
import controlP5.*;
ControlP5 controlP5;
import ddf.minim.*;
import fullscreen.*;
FullScreen fs;
Minim minim;
AudioInput in;
float ellipseR = 0;
void setup() {
size(800, 800);
smooth();
colorMode(HSB);
controlP5 = new ControlP5(this);
controlP5.addSlider("ellipseR",0.1,1.2,100,100,260,100,14);
frameRate(30);
// Create the fullscreen object
fs = new FullScreen(this);
// enter fullscreen mode
fs.enter();
//Initialize values
minim = new Minim(this);
// get a line in from Minim, default bit depth is 16
in = minim.getLineIn(Minim.STEREO, 512);
ellipseMode(CENTER);
}
void draw() {
fill(0, 50);
rect(0,0,width,height);
noStroke();
fill(0);
pushMatrix();
float c1 = map(Minim.STEREO, 0, 512, 250, 350);
translate(width/2, height/2);
for (int f=0; f<72; f++) {
//translate(10, 10);
rotate(ellipseR);
pushMatrix();
for (int i=0; i<in.bufferSize(); i++) {
if (i<in.right.get(i)*150) {
// rotate(i);
fill(100, 100, 255);
scale(1.08);
translate(10, 10);
ellipse(0, 0, 5, 5);
}
}
popMatrix();
}
popMatrix();
}
void stop() {
in.close();
minim.stop();
super.stop();
}
And here is the code i wrote to draw a dot when the mouse is clicked based on the current time.
void setup() {
size(800, 800);
smooth();
}
void draw() {
background(0);
translate(width/2, height/2);
println( hour() + ":" + minute() + ":" + second());
}
void mousePressed() {
background(0);
int[] circLine = new int[20];
fill(map(mouseX, 0, width, 0, 255));
int s = second();
float counter = map(s, 0, 60, 0, 20);
ellipse(counter*20, 0, 20, 20);
}
I'm not really sure where to start in terms of grabbing and storing a value from an input that can be used to create another graphic. Can anyone show me what bits of code i need to start putting this together?
1