Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1009767 // captureAudioFromLine3 - captures to OutputStream

JavaX fragment (include)

1  
static int captureAudioFromLine3_bufSize = 65536;
2  
3  
// uses default line
4  
static void captureAudioFromLine3(AudioFormat format, OutputStream out, Flag stop) ctex {
5  
  AudioLine line = first(allTargetDataLines());
6  
  assertNotNull("Need audio input line!", line);
7  
  DataLine dataLine = cast line.open();
8  
  captureAudioFromLine3(dataLine, format, out, stop);
9  
}
10  
11  
static void captureAudioFromLine3(DataLine line, AudioFormat format, OutputStream out, Flag stop) ctex {
12  
  if (!line instanceof TargetDataLine) fail(getClassName(line));
13  
  TargetDataLine tdl = cast line;
14  
  tdl.open(format);
15  
  tdl.start();
16  
  int n;
17  
  byte[] buf = new byte[captureAudioFromLine3_bufSize];
18  
  while (licensed() && !stop.isUp() && (n = tdl.read(buf, 0, l(buf))) > 0) {
19  
    out.write(buf, 0, n);
20  
  }
21  
  tdl.close();
22  
}

Author comment

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: #1009767
Snippet name: captureAudioFromLine3 - captures to OutputStream
Eternal ID of this version: #1009767/4
Text MD5: 7f64673f77c09230e7d6df4debc2cafd
Author: stefan
Category: javax / audio
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-16 16:48:36
Source code size: 806 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 428 / 460
Version history: 3 change(s)
Referenced in: [show references]