Hi im new to processing and i have made this program (Its a timer/alarm)
here is the code (probably doesnt work because of the sound thing but to make it work remember to have the sound and put a file next to the code called ding.wav)
import processing.sound.*;
SoundFile file;
String audioName = "ding.wav";
String path;
String SS="S:";
String MM="M:";
String HH="H:";
int exit = 0;
int sound = 0;
int S = 0;
int M = 0;
int H = -1;
int SE = 1;
int ME = 0;
int HE = 0;
float NIn;
void setup(){
size (400, 212);
path = sketchPath(audioName);
file = new SoundFile(this, path);
NIn = 0;
}
void draw(){
background(255,100,122);
if (NIn == 1){
} else {
if (keyPressed){
if (key == 't'){
SE=61;
ME=61;
HE=2147483647;
}
}
}
if (SE==60){
SE=1;
}
if (ME==60){
ME=0;
}
if (HE==60){
HE=0;
}
if (keyPressed) {
if (key == 's' || key == 's') {
SE+=1;
delay(250);
}
}
if (keyPressed) {
if (key == 'm' || key == 'm') {
ME+=1;
delay(250);
}
}
if (keyPressed) {
if (key == 'h' || key == 'h') {
HE+=1;
delay(250);
}
}
if (keyPressed) {
if (key == ' ') {
NIn+=1;
H+=1;
}
}
//5 min. = 300000
if (H==HE){
if (M==ME){
if (S==SE){
sound+=1;
exit+=1;
}
}
}
if (keyPressed){
if (key == ' '||key == ' '){
Exit();
}
}
if (sound==1){
file.play();
file.play();
}
if (S==60){
S=0;
M+=NIn;
}
if (M==60){
M=0;
H+=NIn;
}
if (NIn==1){
S+=NIn;
delay(1000);
}
{
smooth();
if (NIn==1){
textSize(64);
text(S,0,84);
text(M,0,148);
text(H,0,212);}
textSize(20);
text(SS,0,20);
text(MM,45,20);
text(HH,90,20);
text(SE,17,20);
text(ME,67,20);
text(HE,112,20);}
}
void Exit(){
if (exit==1){
exit();}
}
And i really want some constructive criticisme
ps.
s to set how many seconds in the alarm
m to set how many minuets in the alarm
h to set how many hoursin the alarm
t to switch to timer
space to start when your done
hold space to close alarm when its done.