Processing – Final Project
After all these lesson it was time to close it up with a final project for MSA. I decided to take different parts of the things we learned in this lesson and mash them up together to make into one final piece. I wrote down some of the ideas i wanted to do and i ended up with the idea of making a pulse wave that follows a song i picked. There were some errors in the code sometimes or things didnt work as i wanted them to work but in the end it was worth it and the result is what i wanted it to be!
So i started up by making the usual skeleton of the program. Firstly i saved it and then i made a ”data” folder to input the image i wanted to use as a background and the song that i wanted to play along with my animation. After that i started working on a pulsating sphere that would be in the middle of the window that is beating in the rhythm of the song! I typed in the code of the color and how the sphere would look like and where it will be placed. Next i wanted to add some moving lines on the back of the sphere like a graph but they would be constantly moving. Changed their color so you could see them and be different from the background. I made 4 WHILE statements, each one for each line and the only thing i changed is the time on each one of them so they would move differently from each other. The next i wanted to do is how the circle in the middle will beat to the song. So i started experimenting with different kind of numbers for the growth and shrinking of the circle to find a nice beating motion. Then by just changing the modulo ”%” of the code i could change on how fast or slow the beat of the sphere would be. At last i wrote down the code to add the music file in my project and voila done! Enjoy this little video with how i made my project and the end result and ill place the code underneath it!
THE CODE:
int csize = 50;
int grow = 0;
int n = 0;
float time = 0;
PImage img;
import processing.sound.*;
SoundFile file; //this inputs our music into processing
void setup() {
size(500, 400);
smooth();
fill(59, 198, 187);
file = new SoundFile(this, “pyramids.mp3”); //sound file for the music loaded from data
file.play();
}
void draw() {
background( img=loadImage(“pyramid.jpg”));
stroke(255);
strokeWeight(2);
float x = 0;
while (x < width) {
point(x, height * noise(x / 50, time));
x = x + 1;
}
time = time + 0.02;
float y = 0;
while (y < width) {
point(y, height * noise(y / 100, time));
y = y + 2;
}
time = time + 0.02;
float k = 0;
while (k < width) {
point(k, height * noise(k / 150, time));
k = k + 3;
}
float u = 0;
while (u < width) {
point(u, height * noise(u / 200, time));
u = u + 4;
}
time = time + 0.02;
if(n % 30 == 0) {
grow = 5;
}
if(csize > 80) {
csize = 80;
grow = -2;
}
if(csize < 50) {
csize = 50;
grow = 0;
}
ellipse(250, 200, csize, csize);
csize = csize + grow;
n = n + 1;
}