sinterface Capturer { void stop(); byte[] getPCM(); AudioFormat format(); } static Capturer captureAudioFromLine2(DataLine line, final AudioFormat format) ctex { if (!line instanceof TargetDataLine) fail(getClassName(line)); final TargetDataLine tdl = cast line; tdl.open(format); tdl.start(); ret new Capturer { volatile bool stopped; new ByteArrayOutputStream baos; public void stop() { stopped = true; } { thread "Audio Capture" { try { int total = 0, n; byte[] buf = new byte[1024]; while (!stopped && licensed() && (n = tdl.read(buf, 0, l(buf))) > 0) { total += n; baos.write(buf, 0, n); //print("Bytes read from line: " + total); } } finally { tdl.close(); } } } public byte[] getPCM() { ret baos.toByteArray(); } public AudioFormat format() { ret format; } }; }
Began life as a copy of #1007026
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007032 |
Snippet name: | captureAudioFromLine2 |
Eternal ID of this version: | #1007032/7 |
Text MD5: | b8d0ee5797a90281e128f4c1122cd486 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-26 00:28:02 |
Source code size: | 1023 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 575 / 564 |
Version history: | 6 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |