import processing.pdf.*; //import pdf exporter from libraries
import ddf.minim.*; //import minim module from librariesPShape g; //declare icon
PFont f,e; //declare fonts
Minim minim; //declare minim
AudioPlayer groove; //declare song
StringList songs,icons; //list of songs and icons
void setup()
{
beginRecord(PDF, “Songana.pdf”); //start record PDF by frame
background(255); //white background
size(601, 850); //setup size
minim = new Minim(this); //initiate minim
songs = new StringList(); //initiate songs list
songs.append(“Erutan-Goddess.mp3”); //load 1st song
songs.append(“Summer Salt – Sweet To Me.mp3”); //load 2nd song
songs.append(“Big Bang – If You.mp3”); //load 3rd song
songs.append(“nosound.mp3”); //load default song
String song = songs.get(3); //start default song
groove = minim.loadFile(song, 200); //play song
icons = new StringList(); //initiate icons list
icons.append(“noicon-01-01.svg”); //load default icon
icons.append(“Erutan-01.svg”); //load 1st icon
icons.append(“Sweet-01.svg”); //load 2nd icon
icons.append(“Goddes-01.svg”); //load 3rd icon
g = loadShape(icons.get(0)); //assign default icon
f = createFont(“Parchment”,12,true); //assign 1st font to variable
e = createFont(“Arial”,12,true); //assign 2nd font to variable
//song option interface
fill(0);
textSize(20);
textFont(e,20);
text(“1. Erutan – Song of The Goddess”,150,300);
text(“2. Summer Salt – Sweet To Me”,150,350);
text(“3. Big Bang – If You”,150,400);
rect(200,500,200,50);
textAlign(CENTER);
textSize(15);
text(“Click OK and Press Song Number”,width/2,480);
text(“Click Play in Processing to restart the application”,width/2,580);
textSize(100);
textFont(f,100);
text(“Songana”,width/2,200);
textSize(15);
textFont(e,15);
text(“www.siatmassey.wordpress.com”,width/2,800);
fill(255);
textSize(30);
textFont(e,30);
text(“OK”,width/2,535);
}
void draw(){
//imagery from buffer size and sides level
for(int i = 0; i < groove.bufferSize() – 1 ; i++) { //the stroke weight will be determined by the total buffer size of the song. //the higher the buffer size, the bigger the stroke would be. strokeWeight(groove.bufferSize()/(50*(i+1))); //ellipsed is used and the size of the width is based on the buffer size //at the left side, while the size of the height is based on the right size. ellipse(300.5,200+i,groove.left.level()*1000,groove.right.level()*1500); } shape(g,0,0); //start icon } //OK button void mousePressed(){ if (mouseX>200){
if (mouseX<400){ if (mouseY>500){
if (mouseY<550){
noStroke();
fill(255,255,255);
rect(0,0,width,height);
}}}}
}
//number of key for songs
void keyPressed() {
if (key == ‘1’) {
String a = “Erutan”; //artist
String b = “Song Of The Goddess”; //song
fill(0,random(100,155),random(100,155));
textSize(80);
textFont(f,80);
textAlign(CENTER);
text(a,width/2,800);
textSize(20);
textFont(e,20);
text(b,width/2,840);
stroke(0,random(100,155),random(100,155));
strokeWeight(3);
line(0,790,180,790);
line(420,790,width,790);
String song = songs.get(0);
groove = minim.loadFile(song, 200);
groove.loop(); //loop song
noFill();
stroke(0,random(100,155),random(100,155),128);
g = loadShape(icons.get(1)); //load 1st icon
}
if (key == ‘2’) {
String a = “Summer Salt”; //artist
String b = “Sweet To Me”; //song
fill(0,random(100,155),random(200,255));
textSize(80);
textFont(f,80);
textAlign(CENTER);
text(a,width/2,800);
textSize(20);
textFont(e,20);
text(b,width/2,840);
stroke(0,random(100,155),random(200,255));
strokeWeight(3);
line(0,790,120,790);
line(480,790,width,790);
String song = songs.get(1);
groove = minim.loadFile(song, 200);
groove.loop(); //loop song
noFill();
stroke(0,random(100,155),random(200,255),128);
g = loadShape(icons.get(2)); //load 2nd icon
}
if (key == ‘3’) {
String a = “Big Bang”; //artist
String b = “If You”; //song
fill(random(200,255),50,random(50,100));
textSize(80);
textFont(f,80);
textAlign(CENTER);
text(a,width/2,800);
textSize(20);
textFont(e,20);
text(b,width/2,840);
stroke(random(200,255),50,random(50,100));
strokeWeight(3);
line(0,790,130,790);
line(470,790,width,790);
String song = songs.get(2);
groove = minim.loadFile(song, 200);
groove.loop(); //loop song
noFill();
stroke(random(200,255),50,random(50,100),128);
g = loadShape(icons.get(3)); //load 3rd icon
}
//export PDF by pressing q
if (key == ‘q’) {
endRecord();
exit();
}
} |