!7 import static x30_pkg.x30_util.VF1; sclass BlipOnNoise > DynPrintLog { float threshold = 40f; int forcedDelay = 2000; transient VF1 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); } }