public void write(byte[] buffer) {
    if (dataLine == null)
      return;
    int bsize = buffer.length;
    if (!fullSpeed) {
      while (dataLine.available() < bsize)
        try {
          Thread.sleep(1);
        } catch (Exception e) {
        }
    } else if (dataLine.available() < bsize) {
      return;
    }
    if (!soundOn) {
      // Kill sound!!!
      for (int i = 0; i < buffer.length; i++) {
        buffer[i] = 0;
      }
    }
    dataLine.write(buffer, 0, bsize);
  }