Sound in Processing

How do you stop a song that is playing? I know how to play a song in processing, but I was wondering how to make the current song stop playing.

Here is my code,

//Make movie variables
//Load every movie
//If todraw is a variable load that movie
int up = 80;
int right = 7;
int toDraw = 1;
// Step 1. Declare a Movie object.
Movie movie; 

import processing.sound.*;
SoundFile file;

void setup()
  file = new SoundFile(this, "music1.aiff");
  movie = new Movie(this, "");  
  size(636, 476);  
  println("Right and left increase and decrease the brightness of the flashlight.");
  println("Up and down increase and decrease the size of the flashlight.");
  println("Control removes the flashlight, alt makes a black hole, and shift resets everything.");
  println("And don't make anything a negative value.");
// Step 4. Read new frames from the movie.
void movieEvent(Movie movie) 
// Step 5. Display movie.
void draw() 
  for (int x = 0; x < movie.width; x++) 
    for (int y = 0; y < movie.height; y++) 
      // Calculate the 1D location from a 2D grid
      int loc = x + y * movie.width;      
      // Get the red, green, blue values from a pixel      
      float r = red  (movie.pixels[loc]);      
      float g = green(movie.pixels[loc]);      
      float b = blue (movie.pixels[loc]);      
      // Calculate an amount to change brightness based on proximity to the mouse      
      float d = dist(x, y, mouseX, mouseY);      
      float adjustbrightness = map(d, 0, up, right, 0);      
      r *= adjustbrightness;      
      g *= adjustbrightness;      
      b *= adjustbrightness;      
      // Constrain RGB to make sure they are within 0-255 color range      
      r = constrain(r, 0, 255);      
      g = constrain(g, 0, 255);      
      b = constrain(b, 0, 255);      
      // Make a new color and set pixel in the window      
      color c = color(r, g, b);      
      pixels[loc] = c;
void keyPressed()
  if (key == CODED)
    if (keyCode == UP)
    if (keyCode == DOWN)
    if (keyCode == RIGHT)
    if (keyCode == LEFT)
    if (keyCode == CONTROL)
      up=1900;, 1.0);
    if (keyCode == SHIFT)
    if (keyCode == ALT)

You can see that under if (keyCode == CONTROL) Everytime the control button is pressed, it plays that specific soundfile. However, the soundfile never stops playing so there are many versions of it playing at the same time. How do I prevent this?

This fix certainly isn’t efficient but it works

 file = new SoundFile(this, "music1.aiff");;


Does; loop the soundfile or only play it once? Would I use file.loop(); instead to loop the soundfile?

If i understand it correctly, then what he means, is When you press Control it stops the old sound, creates it again and Plays it, until the next Time you press Control. The only Problem is, that the sound would not Overlap, But also keep on going until you press again, and Start Over… You Would maybe want to add a method that Takes the length of the sound file and stops it after that many seconds