!7 import static x30_pkg.x30_util.VF1; sclass NoticeLoudNoise > DynPrintLog { float threshold = 20f; transient VF1 audioListener; transient float lastVolume; transient Q q; void start { ownTimer(q = startQ()); audioListener = voidfunc(short[] data) { // Quickly calculate the volume final float vol = shortSamplesToPercentVolume(data); // Do everything else in our own thread q.add(r { //print("vol: " + vol); if (vol >= threshold && lastVolume < threshold) printWithTime("Got noise (" + iround(vol) + "%)"); lastVolume = vol; }); }; // Link to audio input module dm_addAudioListener(audioListener); } }