Полагаю что проблема в
createMediaElementSource Я проверил код ниже в Mojave,всё работает
<button id="btn">
Start
</button>
<div id="wrapper"></div>
<br />
<canvas id="canvas" style="background:black;width:512px;height:255px;"></canvas>
document.getElementById("btn").addEventListener("click", function() {
var canvas = document.getElementById('canvas');
var canvasCtx = canvas.getContext("2d");
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
var player = document.getElementById('audio_player');
var analyser = audioContext.createAnalyser();
var data = new Uint8Array(analyser.frequencyBinCount);
function render() {
analyser.getByteFrequencyData(data);
canvasCtx.clearRect(0, 0, canvas.width, canvas.height);
for (var i = 0, l = data.length; i < l; i++) {
canvasCtx.fillStyle = "#ffffff";
canvasCtx.fillRect(i, -(canvas.height/255) * data[i], 1, canvas.height);
}
requestAnimationFrame(render);
}
requestAnimationFrame(render);
var audio = new Audio();
audio.loop = true;
audio.autoplay = false;
audio.crossOrigin = "anonymous";
audio.addEventListener('error', function(e) {
console.log(e);
});
audio.src = "https://greggman.github.io/doodles/sounds/DOCTOR VOX - Level Up.mp3";
//audio.play();
audio.controls = true;
document.getElementById("wrapper").append(audio);
audio.addEventListener('canplay', function() {
var audioSourceNode = audioContext.createMediaElementSource(audio);
audioSourceNode.connect(analyser);
analyser.connect(audioContext.destination);
});
});