This demo shows the default, raw values you can retrive from an AudioAnalyser, without changing any options. They include the
waveform (time domain) data
the frequency data and the
root-mean-square value derived from the waveform. For more information on each set of values, head to their individual demo pages.
AudioAnalyser(input, { passthru: true }).then((result) => {
analyser = result;
if (analyser.audio) /* if the audio needs to be played, e.g. not a mic source */
analyser.audio.play();
var frameCount = 0;
function draw() {
requestAnimationFrame(draw); frameCount++;
/* left pad each array with 0s. must convert Uint8Array to normal first. */
var waveform =
Array.from(analyser.waveform())
.map(x => String('000' + parseInt(x)).slice(-3))
.join(' ');
var frequencies =
Array.from(analyser.frequencies())
.map(x => String('000' + parseInt(x)).slice(-3))
.join(' ');
document.getElementById('waveform').innerHTML = waveform;
document.getElementById('frequencies').innerHTML = frequencies;
document.getElementById('rms').innerHTML = analyser.rms();
} draw();
}, (error) => {
document.getElementById('error').innerHTML = error;
});
This demo will play audio through to your speakers. Be careful when selecting microphone to avoid feedback!
Input values for this demo can be one of the following: