!7 sclass AudioInput > DynPrintLog { int bufSize = 40960; transient AudioLoop loop; void start { ownTimer(loop = new AudioLoop(bufSize)); } } sclass AudioLoop extends Thread implements AutoCloseable { TargetDataLine line; new Flag stopFlag; byte[] buf; *(int bufSize) { line = javaSound_recordLine(javaSound_cdQuality(), bufSize); buf = new byte[bufSize]; } public void start { line.start°; super.start°; } void stopRecording { // "stop()" was taken if (stopFlag.isUp()) ret; stopFlag.raise°; line.close°; print("Audio input loop stopped."); } public void close { stopRecording(); } public void run° { print("Audio input loop started. Buffer size=" + l(buf) + " (" + iround(l(buf)/44100.0/4*1000) + " ms)"); while (licensed() && !stopFlag.isUp()) { int n = line.read(buf, 0, l(buf)); if (n < l(buf)) print("Weird: Got less than a buffer: " + n + "/" + l(buf)); handleData(subArray(buf, 0, n)); } } svoid handleData(byte[] data) { print("Got audio data " + l(data)); } }