Uses 450K of libraries. Click here for Pure Java version (17487L/124K).
!7 import static x30_pkg.x30_util.VF1; module LiveVAD > DynPrintLog { volatile bool enabled = true; transient double windowSize = 1.0; // seconds transient Q q; transient new L<short[]> buffer; transient int bufferSize, neededSamples; transient VAD_1 vad; visualize { ret centerAndSouthWithMargins(super.visualize(), jrightalignedline(dm_fieldCheckBox('enabled))); } start { vad = filled_VAD_1(); neededSamples = iround(windowSize*44100); q = dm_startQ(); dm_addAudioListener(voidfunc(short[] data) { if (!enabled) ret; buffer.add(mixStereoShortArrayToMono(data)); bufferSize += l(data)/2; if (bufferSize >= neededSamples) { bufferSize -= neededSamples; final L<short[]> salvaged = cloneList(buffer); buffer.clear(); if (bufferSize > 0) { buffer.add(lastNShorts(bufferSize, last(salvaged))); replaceLastElement(salvaged, dropLastNShorts(bufferSize, last(salvaged))); } q.add(r { MultiShortArrayInputStream_resettable stream = new(salvaged); stream.bigEndian = true; Clip clip = spectro_clipFromMonoInputStream(stream); BWImage img = clipToFrequencyImage(clip); quickShowZoomedImage(img); print("VAD: " + callF(vad, img)); }); } }); } }
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: | 358 / 568 |
Version history: | 16 change(s) |
Referenced in: | #1019274 - Live Audio FFT [Dyn Module, shows last second] |