/**
   * Constructs an audio input stream that reads its data from the target data line indicated. The
   * format of the stream is the same as that of the target data line, and the length is
   * AudioSystem#NOT_SPECIFIED.
   *
   * @param line the target data line from which this stream obtains its data.
   * @see AudioSystem#NOT_SPECIFIED
   */
  public AudioInputStream(TargetDataLine line) {

    TargetDataLineInputStream tstream = new TargetDataLineInputStream(line);
    format = line.getFormat();
    frameLength = AudioSystem.NOT_SPECIFIED;
    frameSize = format.getFrameSize();

    if (frameSize == AudioSystem.NOT_SPECIFIED || frameSize <= 0) {
      frameSize = 1;
    }
    this.stream = tstream;
    framePos = 0;
    markpos = 0;
  }
    public int read() throws IOException {

      byte[] b = new byte[1];

      int value = read(b, 0, 1);

      if (value == -1) {
        return -1;
      }

      value = (int) b[0];

      if (line.getFormat().getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) {
        value += 128;
      }

      return value;
    }
Exemple #3
0
 TargetDataLineMeter(TargetDataLine line) {
   super(new ByteArrayInputStream(new byte[0]), line.getFormat(), AudioSystem.NOT_SPECIFIED);
   this.line = line;
 }