Abstract Lines

AbstractLinesIn this project, the length of the lines determine the frequency of the note played. The colors are random. Each line begins at the end point of the previous line. This was designed to be experienced, these are some examples of the end result. This project was made in Processing 3, source code below.

//Jacob Villa, 2018
import processing.sound.*;
TriOsc sound;
int x1,y1,x2,y2,counter;
int soundFreq;
int wave;
int number;
int run;
String[] hz;

void setup(){
size(1280,720);
background(0);
strokeWeight(30);
number = 50;
sound = new TriOsc(this);
sound.amp(0.3);
frameRate(15);
counter = 0;
run = 0;
hz = new String[number];
x1 = (int)random(width);
if(x1 < 15) x1 += 15; if(x1 > width-15)
x1 -= 15;
y1 = (int)random(height);
if(y1 < 15) y1 += 15; if(y1 > height-15)
y1 -= 15;
x2 = (int)random(width);
if(x2 < 15) x2 += 15; if(x2 > width-15)
x2 -= 15;
y2 = (int)random(height);
if(y2 < 15) y2 += 15; if(y2 > height-15)
y2 -= 15;
}

void draw(){
delay((int)random(100,300));
sound.stop();
stroke(random(255),random(255),random(255),127);
if(counter < number){
x1 = x2;
y1 = y2;
x2 = (int)random(width);
if(x2 < 15) x2 += 15; if(x2 > width-15)
x2 -= 15;
y2 = (int)random(height);
if(y2 < 15) y2 += 15; if(y2 > height-15)
y2 -= 15;
soundFreq = constrain((int)dist(x1,y1,x2,y2),120,2200);
sound.freq(soundFreq);
hz[counter] = “line “+str(counter)+”: “+str(soundFreq)+”hz”;
sound.play();
line(x1,y1,x2,y2);
}else{
counter = 0;
save(str(run)+”_image”);
saveStrings(str(run)+”_hz.txt”, hz);
delay(500);
background(0);
run++;

// limits the number of runs
//  if(run == 10){
//      exit();
//  }
}
counter ++;
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s