public void play(InputStream source, AudioFormat format)
  {

    // Use a short, 100ms (1/10th sec) buffer for real-time
    // change to the sound stream
    int bufferSize = format.getFrameSize()
        * Math.round(format.getSampleRate() / 10);
    byte[] buffer = new byte[bufferSize];

    // Create a line to play to
    SourceDataLine line;
    try
    {
      DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
      line = (SourceDataLine) AudioSystem.getLine(info);
      line.open(format, bufferSize);
    } catch (LineUnavailableException ex)
    {
      ex.printStackTrace();
      return;
    }

    // Start the line
    line.start();

    // Copy data to the line
    try
    {
      int numBytesRead = 0;
      while (numBytesRead != -1)
      {
        numBytesRead = source.read(buffer, 0, buffer.length);
        if (numBytesRead != -1)
        {
          line.write(buffer, 0, numBytesRead);
        }
      }
    } catch (IOException ex)
    {
      ex.printStackTrace();
    }

    // Wait until all data is played, then close the line
    line.drain();
    line.close();

  }