Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Want to play a sound at the end of my program... Having problem...

$
0
0
  1. import ddf.minim.spi.*;
  2. import ddf.minim.signals.*;
  3. import ddf.minim.*;
  4. import ddf.minim.analysis.*;
  5. import ddf.minim.ugens.*;
  6. import ddf.minim.effects.*;
  7.  
  8. Minim minim;
  9. AudioSample alert;
  10. int duration;
  11.  
  12. boolean halt, stopping;
  13.  
  14. void setup() {
  15.   size(310, 220);
  16.   fill(50);
  17.   textSize(30);
  18.   text("PABLO", 105, 50);
  19.   textSize(20);
  20.   text("Press 'H' to halt Program", 25, 100);
  21.  
  22.   // Sound Output Setup
  23.   minim = new Minim(this);
  24.   alert = minim.loadSample("G:/Documents divers/Sounds/Huge Metal Door Slam.mp3");
  25.   duration = alert.length();
  26. }
  27.  
  28. void draw() {
  29.   if (halt) {
  30.     alert.trigger();
  31.     halt = false;
  32.     stopping = true;
  33.     duration += millis();
  34.   }
  35.   if (stopping && millis() > duration) {
  36.     exit();
  37.   }
  38. }
  39.  
  40. void keyPressed() {
  41.   if (key == 'h') {
  42.     halt = true;
  43.   }
  44. }


Viewing all articles
Browse latest Browse all 1768

Trending Articles