protected void setupSound()
    {
      // We have to read in the sound file.
      try {
        audioStream = getAudioStream();
        if (audioStream instanceof AudioInputStream) {
          audioInputStream = (AudioInputStream) audioStream;
        }
        else {
          audioInputStream = AudioSystem.getAudioInputStream(audioStream);
        }
      }
      catch (Exception e) {
        e.printStackTrace();
      }
      /*
        From the AudioInputStream, i.e. from the sound file,
        we fetch information about the format of the audio data.
        This information includes the sampling frequency, the number of channels
        and the size of the samples.
        This information is needed to ask JavaSound for a suitable output line
        for this audio file.
      */
      audioFormat = audioInputStream.getFormat();
      /*
        Asking for a line is a rather tricky thing.
        We have to construct an Info object that specifies the desired properties
        for the line.
        First, we have to say which kind of line we want. The possibilities are:
        SourceDataLine (for playback), Clip (for repeated playback) and
        TargetDataLine (for recording).
        Here, we want to do normal playback, so we ask for a SourceDataLine.
        Then, we have to pass an AudioFormat object, so that the Line knows which
        format the data passed to it will have.
        Furthermore, we can give JavaSound a hint about how big the internal
        buffer for the line should be. This isn't used here, signaling that we
        don't care about the exact size. JavaSound will use some default value
        for the buffer size.
      */
      info = new DataLine.Info(SourceDataLine.class, audioFormat);
      // If the audioFormat is not directly supported
      if (!AudioSystem.isLineSupported(info)) {
        AudioFormat sourceFormat = audioFormat;
        AudioFormat targetFormat = new AudioFormat(
              AudioFormat.Encoding.PCM_SIGNED,
              sourceFormat.getSampleRate(),
              16,
              sourceFormat.getChannels(),
              sourceFormat.getChannels() * 2,
              sourceFormat.getSampleRate(),
              false);
        audioInputStream = AudioSystem.getAudioInputStream(targetFormat, audioInputStream);
        audioFormat = audioInputStream.getFormat();
        info = new DataLine.Info(SourceDataLine.class, audioFormat);
      }
      // We have to open the line for it to be ready to receive audio data.
      try {
        line = (SourceDataLine) AudioSystem.getLine(info);
        // We have to open the line for it to be ready to receive audio data.
        line.open(audioFormat);
      }
      catch (LineUnavailableException e) {
        e.printStackTrace();
      }
      catch (Exception e) {
        e.printStackTrace();
      }
      // setup copying buffer
      buffer = new byte[128000];
      written = 0;
      read = 0;
    }