Uses 450K of libraries. Click here for Pure Java version (17487L/124K).
1 | !7 |
2 | |
3 | import static x30_pkg.x30_util.VF1; |
4 | |
5 | module LiveVAD > DynPrintLog { |
6 | volatile bool enabled = true; |
7 | transient double windowSize = 1.0; // seconds |
8 | transient Q q; |
9 | transient new L<short[]> buffer; |
10 | transient int bufferSize, neededSamples; |
11 | transient VAD_1 vad; |
12 | |
13 | visualize { |
14 | ret centerAndSouthWithMargins(super.visualize(), |
15 | jrightalignedline(dm_fieldCheckBox('enabled))); |
16 | } |
17 | |
18 | start { |
19 | vad = filled_VAD_1(); |
20 | neededSamples = iround(windowSize*44100); |
21 | |
22 | q = dm_startQ(); |
23 | dm_addAudioListener(voidfunc(short[] data) { |
24 | if (!enabled) ret; |
25 | buffer.add(mixStereoShortArrayToMono(data)); |
26 | bufferSize += l(data)/2; |
27 | |
28 | if (bufferSize >= neededSamples) { |
29 | bufferSize -= neededSamples; |
30 | final L<short[]> salvaged = cloneList(buffer); |
31 | buffer.clear(); |
32 | if (bufferSize > 0) { |
33 | buffer.add(lastNShorts(bufferSize, last(salvaged))); |
34 | replaceLastElement(salvaged, dropLastNShorts(bufferSize, last(salvaged))); |
35 | } |
36 | q.add(r { |
37 | MultiShortArrayInputStream_resettable stream = new(salvaged); |
38 | stream.bigEndian = true; |
39 | Clip clip = spectro_clipFromMonoInputStream(stream); |
40 | BWImage img = clipToFrequencyImage(clip); |
41 | quickShowZoomedImage(img); |
42 | print("VAD: " + callF(vad, img)); |
43 | }); |
44 | } |
45 | }); |
46 | } |
47 | } |
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019263 |
Snippet name: | Live VAD [Dyn Module, dev.] |
Eternal ID of this version: | #1019263/17 |
Text MD5: | 1706a7efe10e4021bce27be4e44f533e |
Transpilation MD5: | f491dba5674383656d97566c58e8dbda |
Author: | stefan |
Category: | javax / audio recognition |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-28 21:05:17 |
Source code size: | 1417 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 357 / 566 |
Version history: | 16 change(s) |
Referenced in: | [show references] |