Uses 206K of libraries. Click here for Pure Java version (14860L/105K).
!7 import static x30_pkg.x30_util.VF1; sclass BlipOnNoise > DynPrintLog { float threshold = 40f; int forcedDelay = 2000; transient VF1<short[]> audioListener; transient float lastVolume; transient Q q; transient long delayUntil; void start { ownTimer(q = startQ()); audioListener = voidfunc(short[] data) { temp enter(); // Quickly calculate the volume final float vol = shortSamplesToPercentVolume(data); // Do everything else in our own thread q.add(r { //print("vol: " + vol); if (now() > delayUntil && vol >= threshold && lastVolume < threshold) { delayUntil = now()+forcedDelay; blip(); printWithTime("Got noise (" + iround(vol) + "%)"); } lastVolume = vol; }); }; // Link to audio input module dm_addAudioListener(audioListener); } }
Began life as a copy of #1017157
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: | #1017158 |
Snippet name: | Blip On Noise [Dyn Module] |
Eternal ID of this version: | #1017158/15 |
Text MD5: | 21828ed7ab40b2c7f681829eb3f0e952 |
Transpilation MD5: | 6d5edff4115ced3aa6c1bf907539a620 |
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-10-07 15:16:43 |
Source code size: | 936 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 337 / 587 |
Version history: | 14 change(s) |
Referenced in: | #1017159 - Listen On Noise [using Google speech recognizer] #1018602 - Quick Audio Record [while holding button] |