need help with strings -- making "karaoke"
in
Programming Questions
•
4 months ago
hi --
i'm quite new to processing, but have a university class where we have to use it for a project. i have collected lyrics from songs, divided these into six categories (emotions: energetic, happy, relaxed, melancholic, stressed + sleepy). the lyrics are in individual .txt files. using minim to import songs for background music.
i want to make an applet that lets you select an emotion, and get a new (randomly generated) song with random lines of lyrics from the array of songs with the chosen emotion.
i am in serious need of some help here; with several things:
1 // can i make a "front page" where you can click on happy, which then opens up a new "page" with the song?
2 // is there a quick way to load several strings at a time? have about 40 of them, as you can see below.
3 // how do i time the lyrics? they can (at least for now) be the same amount of time. using framerate now, which kind of works, but there's a long pause before it starts. don' know how to use mills(), but could that be something?
4 // is there a way that i can have a set of "presets" for each emotion -- like background color and image?
help with anything would be GREATLY appreciated -- thanks!
sorry about the mess, but this is what the script looks like now:
PFont lanefont, satellite, dashfont;
String[][] happy, melancholic, relaxed, sleepy, stressed, energized;
PImage beach, surf, boom, neon, floral, frame;
import ddf.minim.*;
AudioPlayer player;
Minim minim;
void setup () {
size (800, 800);
background (0);
smooth();
frameRate(0.15);
minim = new Minim(this);
player = minim.loadFile ("melancholic.mp3", 500); // melancholic
player.play();
lanefont = loadFont ("Lane-Narrow-48.vlw");
satellite = loadFont ("Satellite-Oblique-48.vlw");
dashfont = loadFont ("PrintDashed-48.vlw");
beach = loadImage ("beach.jpg"); // relaxed
surf = loadImage ("surf.jpg"); // happy
boom = loadImage ("boom.jpg"); // stressed
neon = loadImage ("neon.jpg"); // energized
floral = loadImage ("floral.jpg"); // melancholic
frame = loadImage ("frame.jpg"); // sleepy
}
void draw() {
String header [] = {"I M P R O V I S E D", "H A P P Y ", "M E L A N C H O L I C",
"R E L A X E D", "E N E R G I Z E D", "S T R E S S E D", "S L E E P Y"};
// background (241, 163, 189); // happy pink
background (145, 165, 145); // melancholic green
// background (255, 247, 0); // energized yellow
// background (0, 108, 255); // relaxed blue
// background (255, 5, 5); // stressed red
// background (116, 56, 222); // sleepy purple
tint (255, 10);
image (floral, 0, -100, 800, 1000);
stroke (241, 163, 189);
strokeCap (PROJECT);
strokeWeight (2.5);
line (28, 60, 230, 60);
textFont (lanefont, 35);
textAlign (CENTER);
fill(0);
text ("K A R A O K E", 129, 100);
textFont (dashfont, 25);
text (header[2], 129, 135);
stroke (0);
triangle (129, 182, 120, 165, 138, 165);
String t1[] = loadStrings ("1.txt");
String t2[] = loadStrings ("2.txt");
String t3[] = loadStrings ("3.txt");
String t4[] = loadStrings ("4.txt");
String t5[] = loadStrings ("5.txt");
String t6[] = loadStrings ("6.txt");
String t7[] = loadStrings ("7.txt");
// String t8[] = loadStrings ("8.txt");
// String t9[] = loadStrings ("9.txt");
String t10[] = loadStrings ("10.txt");
String t11[] = loadStrings ("11.txt");
String t12[] = loadStrings ("12.txt");
String t13[] = loadStrings ("13.txt");
String t14[] = loadStrings ("14.txt");
String t15[] = loadStrings ("15.txt");
String t16[] = loadStrings ("16.txt");
String t17[] = loadStrings ("17.txt");
String t18[] = loadStrings ("18.txt");
String t19[] = loadStrings ("19.txt");
String t20[] = loadStrings ("20.txt");
String t21[] = loadStrings ("21.txt");
String t22[] = loadStrings ("22.txt");
String t23[] = loadStrings ("23.txt");
String t24[] = loadStrings ("24.txt");
String t25[] = loadStrings ("25.txt");
String t26[] = loadStrings ("26.txt");
// String t27[] = loadStrings ("27.txt");
String t28[] = loadStrings ("28.txt");
String t29[] = loadStrings ("29.txt");
String t30[] = loadStrings ("30.txt");
String t31[] = loadStrings ("31.txt");
String t32[] = loadStrings ("32.txt");
String t33[] = loadStrings ("33.txt");
String t34[] = loadStrings ("34.txt");
String t35[] = loadStrings ("35.txt");
String t36[] = loadStrings ("36.txt");
String t37[] = loadStrings ("37.txt");
String[][] happy = {t2, t4, t5, t6, t19, t20, t21, t22, t23};
String[][] melancholic = {t26, t14, t13, t7, t1, t15, t2, t4, t5, t6, t19, t20, t21, t22, t23};
String[][] relaxed = {t10, t11, t24, t30, t31, t36, t37};
String[][] stressed = {t12};
String[][] energized = {t3, t4, t16, t17, t18, t28, t29, t33, t34, t35};
String[][] sleepy = {t25};
int xpos = width/2;
int ypos = height/2;
for (int i = 0; i < 2; i++) {
fill (255);
textFont (satellite, 30);
textAlign (CENTER, CENTER);
text (melancholic[int(random(melancholic.length))][int(random(10))], xpos, ypos);
ypos = ypos+50;
}
}
void stop() {
player.close();
minim.stop();
super.stop();
}
1