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)

static int captureAudioFromLine3_bufSize = 65536;

// uses default line
static void captureAudioFromLine3(AudioFormat format, OutputStream out, Flag stop) ctex {
  AudioLine line = first(allTargetDataLines());
  assertNotNull("Need audio input line!", line);
  DataLine dataLine = cast line.open();
  captureAudioFromLine3(dataLine, format, out, stop);
}

static void captureAudioFromLine3(DataLine line, AudioFormat format, OutputStream out, Flag stop) ctex {
  if (!line instanceof TargetDataLine) fail(getClassName(line));
  TargetDataLine tdl = cast line;
  tdl.open(format);
  tdl.start();
  int n;
  byte[] buf = new byte[captureAudioFromLine3_bufSize];
  while (licensed() && !stop.isUp() && (n = tdl.read(buf, 0, l(buf))) > 0) {
    out.write(buf, 0, n);
  }
  tdl.close();
}

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: 502 / 533
Version history: 3 change(s)
Referenced in: [show references]