static void captureAudioFromLine(DataLine line, AudioFormat audioFormat) ctex { if (!line instanceof TargetDataLine) fail(getClassName(line)); TargetDataLine tdl = cast line; tdl.open(audioFormat); tdl.start(); int total = 0, n; int seconds = 2; int bytesPerSecond = iround(format.getSampleSizeInBits()*format.getChannels()*format.getSampleRate()/8); print("Bytes per second: " + bytesPerSecond); int bytesWanted = seconds*bytesPerSecond; byte[] buf = new byte[1024]; while (total < bytesWanted && (n = tdl.read(buf, 0, min(l(buf), bytesWanted-total))) > 0) { total += n; print("Bytes read from line: " + total + ". min: " + min(buf) + ". max: " + max(buf)); } tdl.close(); }