Hi guys. I got some trouble in progress.
import ddf.minim.*;
import processing.video.*;
Movie myMovie;
Minim minim;
AudioPlayer s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, bg1, bg2, bg3, bg4;
PImage bg;
PFont font;
int num = 500;
char t[] = new char[num];
int key_num = 0;
int text_w_gap = 40;
int text_h_gap = 70;
int ypos = 450;
int xpos = 510;
int val;
int notetime = 795;
//730 notetime for bg1 - single note
//235 notetime for bg1 fast tempo
//580 notetime for bg2 lick
//1300 notetime for bg3
// for play
int startTime;
int iForPlaySong=0;
boolean playSong=false;
void setup() {
fullScreen();
//size(1440, 900);
bg = loadImage("paper.jpg");
font = createFont("Albertsthal Typewriter.ttf", 14);
textFont(font, 64);
fill(40);
minim = new Minim(this);
s1 = minim.loadFile("1.mp3");
s2 = minim.loadFile("2.mp3");
s3 = minim.loadFile("3.mp3");
s4 = minim.loadFile("4.mp3");
s5 = minim.loadFile("5.mp3");
s6 = minim.loadFile("6.mp3");
s7 = minim.loadFile("7.mp3");
s8 = minim.loadFile("8.mp3");
s9 = minim.loadFile("9.mp3");
s10 = minim.loadFile("10.mp3");
s11 = minim.loadFile("11.mp3");
s12 = minim.loadFile("12.mp3");
s13 = minim.loadFile("13.mp3");
s14 = minim.loadFile("14.mp3");
bg1 = minim.loadFile("bg1.mp3");
bg2 = minim.loadFile("bg2.mp3");
bg3 = minim.loadFile("bg3.mp3");
bg4 = minim.loadFile("bg4.mp3");
}
void draw() {
background(bg);
text("Like I said", 300, 110);
text("Say what you wanna say", 300, 210);
if (playSong) {
if ( millis()>startTime+notetime) {
if (iForPlaySong < key_num) {
println("play " + t[iForPlaySong]);
playNote(t[iForPlaySong]);
iForPlaySong++;
startTime=millis();
}
}
} else
{
for (int i=0; i<key_num; i++) {
text(t[i],
(xpos+(i*text_w_gap))%width,
ypos+( (int(xpos+(i*text_w_gap))) / width * text_h_gap));
}
if (key_num >= num) {
key_num = 0;
}
}
}
void keyPressed() {
if (key==8) {
key_num--;
} else if (key==RETURN||key==ENTER) {
println("Here 11111111111111111111111");
playSong=true;
bg2.play(); // for the bgm --------------------------------------- here
startTime=0;
} else {
t[key_num] = key;
key_num++;
}
println("pressed " + int(key) + " " + keyCode);
}
void playNote(char val) {
if (val=='q') {
s1.play();
if (s1.position() > notetime )
{
s1.rewind();
}
}
if (val=='w') {
s2.play();
if (s2.position() > notetime )
{
s2.rewind();
}
}
if (val=='e') {
s3.play();
if (s3.position() > notetime )
{
s3.rewind();
}
}
if (val=='r') {
s4.play();
if (s4.position() > notetime )
{
s4.rewind();
}
}
if (val=='t') {
s5.play();
if (s5.position() > notetime )
{
s5.rewind();
}
}
if (val=='a') {
s6.play();
if (s6.position() > notetime )
{
s6.rewind();
}
}
if (val=='s') {
s7.play();
if (s7.position() > notetime )
{
s7.rewind();
}
}
if (val=='d') {
s8.play();
if (s8.position() > notetime )
{
s8.rewind();
}
}
if (val=='f') {
s9.play();
if (s9.position() > notetime )
{
s9.rewind();
}
}
if (val=='g') {
s10.play();
if (s10.position() > notetime )
{
s10.rewind();
}
}
if (val=='z') {
s11.play();
if (s11.position() > notetime )
{
s11.rewind();
}
}
if (val=='x') {
s12.play();
if (s12.position() > notetime )
{
s12.rewind();
}
}
if (val=='c') {
s13.play();
if (s13.position() > notetime )
{
s13.rewind();
}
}
if (val=='v') {
s14.play();
if (s14.position() > notetime )
{
s14.rewind();
}
}
// ---------------------------------- LEFT SIDE --------------------------------
if (val=='y') {
s1.play();
if (s1.position() > notetime )
{
s1.rewind();
}
}
if (val=='u') {
s2.play();
if (s2.position() > notetime )
{
s2.rewind();
}
}
if (val=='i') {
s3.play();
if (s3.position() > notetime )
{
s3.rewind();
}
}
if (val=='o') {
s4.play();
if (s4.position() > notetime )
{
s4.rewind();
}
}
if (val=='p') {
s5.play();
if (s5.position() > notetime )
{
s5.rewind();
}
}
if (val=='h') {
s6.play();
if (s6.position() > notetime )
{
s6.rewind();
}
}
if (val=='j') {
s7.play();
if (s7.position() > notetime )
{
s7.rewind();
}
}
if (val=='k') {
s8.play();
if (s8.position() > notetime )
{
s8.rewind();
}
}
if (val=='l') {
s9.play();
if (s9.position() > notetime )
{
s9.rewind();
}
}
if (val=='b') {
s10.play();
if (s10.position() > notetime )
{
s10.rewind();
}
}
if (val=='n') {
s11.play();
if (s11.position() > notetime )
{
s11.rewind();
}
}
if (val=='m') {
s12.play();
if (s12.position() > notetime )
{
s12.rewind();
}
}
if (val=='.') {
s13.play();
if (s13.position() > notetime )
{
s13.rewind();
}
}
if (val=='?') {
s14.play();
if (s14.position() > notetime )
{
s14.rewind();
}
}
}
This is the code.
I want to make 2 things change.
- Make it play the sound not only when I hit the enterkey, also make sound when I hit the key.
2.When I done the interaction, how can I make it run again like 1 minute later?
I got some more problem now, but I want to solve this first. :(
Thanks for watching.