// create audio nodes
        let analyser = audioContext.createAnalyser();
        analyser.fftSize = 512;
        analyser.smoothingTimeConstant = 0.0;
        analyser.minDecibels = -58;

        // connect nodes
        navigator.mediaDevices.getUserMedia({audio: true})
          .then(stream => {
            var microphone = audioContext.createMediaStreamSource(stream);
            microphone.connect(analyser);
          })
          .catch(err => { alert("Microphone is required."); });

        // buf