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

34
LINES

< > BotCompany Repo | #1007018 // Show Input Audio Devices With Audio Level [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 3874K of libraries. Click here for Pure Java version (6079L/42K/154K).

!7

import javax.sound.sampled.*;

static TargetDataLine currentLine;

p-substance {
  final L<Mixer> devices = inputAudioDevices();
  L<S> deviceNames = map(func(Mixer m) {
    audioDeviceName(m) + " [" + n(m.getTargetLineInfo(), "line") + "]"
  }, devices);
  ButtonGroup buttons = showUnselectedRadioButtons("Input Audio Devices", deviceNames);
  JFrame frame = minFrameWidth(300, packFrame(buttons));
  final JLabel lblLevel = jcenteredBoldLabel("Level: ");
  addToWindowAndPack(frame, lblLevel);
  awtEvery(lblLevel, 100, r {
    S text = "Level: ";
    if (currentLine != null) try {
      text += currentLine.getLevel();
    } catch e {
      text += str(e);
      printStackTrace(e);
    }
    lblLevel.setText(text);
  });
  onRadioButtonChange(buttons, voidfunc(int i) {
    if (i < 0) ret;
    Mixer m = devices.get(i);
    Line.Info[] lines = m.getTargetLineInfo();
    print("Device " + i + ": " + audioDeviceName(m));
    print("Have " + n(lines, "line"));
    currentLine = (TargetDataLine) m.getLine(first(lines));
  });
}

Author comment

Began life as a copy of #1007014

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: #1007018
Snippet name: Show Input Audio Devices With Audio Level [dev.]
Eternal ID of this version: #1007018/8
Text MD5: e835487fc95cc9c8ff3fac26e726539a
Transpilation MD5: 95e2b9c95236dbe0eb64358e6bd75559
Author: stefan
Category: javax / audio
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-25 16:37:23
Source code size: 1071 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 419 / 495
Version history: 7 change(s)
Referenced in: [show references]