Libraryless. Click here for Pure Java version (14642L/101K).
1 | !7 |
2 | |
3 | import static x30_pkg.x30_util.VF1; |
4 | |
5 | sclass NoticeLoudNoise > DynPrintLog { |
6 | float threshold = 20f; |
7 | |
8 | transient VF1<short[]> audioListener; |
9 | transient float lastVolume; |
10 | transient Q q; |
11 | |
12 | void start { |
13 | ownTimer(q = startQ()); |
14 | audioListener = voidfunc(short[] data) { |
15 | // Quickly calculate the volume |
16 | final float vol = shortSamplesToPercentVolume(data); |
17 | |
18 | // Do everything else in our own thread |
19 | q.add(r { |
20 | //print("vol: " + vol); |
21 | if (vol >= threshold && lastVolume < threshold) |
22 | printWithTime("Got noise (" + iround(vol) + "%)"); |
23 | lastVolume = vol; |
24 | }); |
25 | }; |
26 | |
27 | // Link to audio input module |
28 | dm_addAudioListener(audioListener); |
29 | } |
30 | } |
Began life as a copy of #1016700
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017157 |
Snippet name: | Notice Loud Noise [Dyn Module] |
Eternal ID of this version: | #1017157/10 |
Text MD5: | 91f9d0e9b3f3d3f2be6173c6b389096a |
Transpilation MD5: | fb4fcc2c888e4fffbf0403ee7bacd6df |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-13 13:40:05 |
Source code size: | 757 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 419 / 551 |
Version history: | 9 change(s) |
Referenced in: | [show references] |