Download Jar. Libraryless. Click here for Pure Java version (7588L/51K).
!7 static JButton btn; static Flag flag; // stop flag static AudioFormat format; static double bufferSeconds = 0.1; static int bufferSize = iround(bufferSeconds*44100*2); p-tt { print("Buffer size: " + bufferSize); format = javaSound_monoCDQuality°; swing { showControls(jcenteredline(btn = jbutton("Start", f btn))); } start(); sleepIfMain(); } svoid btn { if (flag == null || flag.isUp()) start(); else stop(); } svoid start ctex { setText(btn, "Stop"); flag = new Flag; final OutputStream out = new MonoSamplesForwarder(f handleAudio); //MonoSamplesForwarder.debug = true; captureAudioFromLine3_bufSize = bufferSize; thread { captureAudioFromLine3(format, out, flag); print("Done"); } } svoid stop { setText(btn, "Start"); flag.raise(); } svoid handleAudio(float[] f) { double abs = audio_absoluteVolume(f); consoleStatus(toPercent(abs) + "%"); /*print("Have " + l(f) + " floats. Volume=" + audio_rmsVolume(f) + ", abs volume=" + abs);*/ //if (l(f) >= 8) print(struct(subArray(f, 0, 8))); }
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: | 860 / 1812 | 
| Version history: | 14 change(s) | 
| Referenced in: | [show references] |