Download Jar. Libraryless. Click here for Pure Java version (1558L/10K).
1 | !7 |
2 | |
3 | import javax.sound.sampled.*; |
4 | |
5 | static JPanel colorPanel; |
6 | |
7 | p { |
8 | swing { |
9 | tt(); |
10 | colorPanel = singleColorPanelWithSize(); |
11 | showControls(jFullCenter(colorPanel)); |
12 | } |
13 | AudioFormat format = new AudioFormat(44100, 16, 1, true, true); // signed, big-endian |
14 | //TargetDataLine line = AudioSystem.getTargetDataLine(format); |
15 | DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); |
16 | TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); |
17 | line.open(format); |
18 | |
19 | byte[] data = new byte[256]; |
20 | short[] buf = new short[l(data)/2]; |
21 | line.start(); |
22 | |
23 | try { |
24 | while licensed { |
25 | int n = line.read(data, 0, l(data)); |
26 | //printWithMSTime("Bytes: " + n); |
27 | bytesToShorts_signedBigEndian(data, buf); |
28 | int min = min(buf), max = max(buf); |
29 | final double loudness = min(max(abs(min), abs(max))/32767.0, 1); |
30 | //print("min: " + min + ", max: " + max + ", loudness: " + formatDouble(loudness, 2)); |
31 | awt { |
32 | colorPanel.setBackground(blendColor(Color.white, Color.black, loudness)); |
33 | } |
34 | } |
35 | } finally { |
36 | line.close(); |
37 | } |
38 | } |
Began life as a copy of #1007999
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): alesojohvdrz, aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008000 |
Snippet name: | Audio Voltmeter with singleColorPanel (works without Substance) |
Eternal ID of this version: | #1008000/21 |
Text MD5: | 5041034c3fe040f581cc4aac4c94e894 |
Transpilation MD5: | c4a38f984cac0773208b90b9ecaee586 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-18 20:38:27 |
Source code size: | 1131 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 572 / 1193 |
Version history: | 20 change(s) |
Referenced in: | [show references] |