Basic audio analyser. Returns FFT analysis. Use peakLevel if you want the sound level, or basic if you also want the waveform.

const onData = (freq, analyser) => {
// Demo: Print out each sound frequency (Hz) and amount of energy in that band
for (let i=0;i<freq.length;i++) {
const f = analyser.getFrequencyAtIndex(0);
console.log(`${i}. frequency: ${f} amount: ${freq[i]}`);
}
}
freq(onData, {fftSize:512});

Note: Browers won't allow microphone access unless the call has come from a user-interaction, eg pointerup event handler.