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

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

$
0
0
Hello,

I want to play a siren sound at the end of my program. When the playback has finished I want to exit the program with the commands: noLoop(); exit();
My siren gets triggered with the letter 'h' on keyboard. If I dont have the noloop and exit commands it works fine, but sadly it does not exit...
here is my code:
  1. import ddf.minim.spi.*;
    import ddf.minim.signals.*;
    import ddf.minim.*;
    import ddf.minim.analysis.*;
    import ddf.minim.ugens.*;
    import ddf.minim.effects.*;
    Minim minim;
    AudioSample alert;

    boolean hault;

    void setup() {
      size(310, 220);
      fill(50);
      textSize(30);
      text("PABLO", 105, 50);
      textSize(20);
      text("Press 'H' to hault Program", 25, 100);
     
      // Sound Output Setup
      minim = new Minim(this);
      alert = minim.loadSample("siren.mp3");
    }

    void draw() {
      if (hault == true) {
        alert.trigger();
        hault = false;
        noLoop();
        exit();
      }
    }

    void keyPressed() {
      if (key == 'h') {
        hault = true;
      }
You get the idea of what I want to do...
Please Help...

Thanks


Viewing all articles
Browse latest Browse all 1768

Trending Articles