!7 cmodule AudioInputCorrelationTest > DynPrintLogAndEnabled { double windowSize = 1; // milliseconds transient short[] buffer; start { dm_addAudioListener(voidfunc(short[] data) enter { if (!enabled) ret; buffer = cloneArray(data); dm_q(r { if (q.size() > 2) ret with print("overload"); short[] buf = buffer; Float sampleRate = dm_audioInputSampleRate(); if (sampleRate == null) ret; int windowLength = msToSamples_int(windowSize, sampleRate); //printWithMilliseconds("Window length (" + sampleRate + "): " + windowLength); new L l; for (IntRange r : intRangeChunks(data, windowLength)) l.add(normalizedAutocorrelationOfAudioSamples(data, r)); double result = doubleAverage(l); print(iround(result) + ", max=" + iround(doubleMax(l)) + " " + takeFirst(5, l)); }); }); } }