Download Jar. Libraryless. Click here for Pure Java version (7588L/51K).
1 | !7 |
2 | |
3 | static JButton btn; |
4 | static Flag flag; // stop flag |
5 | |
6 | static AudioFormat format; |
7 | |
8 | static double bufferSeconds = 0.1; |
9 | static int bufferSize = iround(bufferSeconds*44100*2); |
10 | |
11 | p-tt {
|
12 | print("Buffer size: " + bufferSize);
|
13 | format = javaSound_monoCDQuality°; |
14 | swing {
|
15 | showControls(jcenteredline(btn = jbutton("Start", f btn)));
|
16 | } |
17 | start(); |
18 | sleepIfMain(); |
19 | } |
20 | |
21 | svoid btn {
|
22 | if (flag == null || flag.isUp()) start(); else stop(); |
23 | } |
24 | |
25 | svoid start ctex {
|
26 | setText(btn, "Stop"); |
27 | flag = new Flag; |
28 | |
29 | final OutputStream out = new MonoSamplesForwarder(f handleAudio); |
30 | //MonoSamplesForwarder.debug = true; |
31 | captureAudioFromLine3_bufSize = bufferSize; |
32 | |
33 | thread {
|
34 | captureAudioFromLine3(format, out, flag); |
35 | print("Done");
|
36 | } |
37 | } |
38 | |
39 | svoid stop {
|
40 | setText(btn, "Start"); |
41 | flag.raise(); |
42 | } |
43 | |
44 | svoid handleAudio(float[] f) {
|
45 | double abs = audio_absoluteVolume(f); |
46 | consoleStatus(toPercent(abs) + "%"); |
47 | /*print("Have " + l(f) + " floats. Volume=" + audio_rmsVolume(f)
|
48 | + ", abs volume=" + abs);*/ |
49 | //if (l(f) >= 8) print(struct(subArray(f, 0, 8))); |
50 | } |
Began life as a copy of #1009769
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, imzmzdywqqli, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1009777 |
| Snippet name: | Live Audio Meter [JavaSound, Absolute Volume, OK] |
| Eternal ID of this version: | #1009777/15 |
| Text MD5: | be510e1ac7d89b6caab46dcd2b735c57 |
| Transpilation MD5: | 00733d438b83adcad64be8bb05970796 |
| Author: | stefan |
| Category: | javax / audio |
| Type: | JavaX source code (desktop) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-05-26 14:29:40 |
| Source code size: | 1113 bytes / 50 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 862 / 1818 |
| Version history: | 14 change(s) |
| Referenced in: | [show references] |