Javascript 吼叫者&x2B;ctx分析仪问题
我正在尝试将音频分析器节点连接到我的howler设置 问题是我得到了一个由“128”填充的数组,这意味着没有声音,但声音正在播放 这是我的密码:Javascript 吼叫者&x2B;ctx分析仪问题,javascript,audiocontext,howler.js,Javascript,Audiocontext,Howler.js,我正在尝试将音频分析器节点连接到我的howler设置 问题是我得到了一个由“128”填充的数组,这意味着没有声音,但声音正在播放 这是我的密码: var Sound = new Howl({ src: 'https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3', html5: true, format: ['mp3']
var Sound = new Howl({
src: 'https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3',
html5: true,
format: ['mp3']
});
Sound.play();
// Create analyzer
var analyser = Howler.ctx.createAnalyser();
// Connect master gain to analyzer
Howler.masterGain.connect(analyser);
// Connect analyzer to destination
analyser.connect(Howler.ctx.destination);
// Creating output array (according to documentation https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API)
analyser.fftSize = 2048;
var bufferLength = analyser.frequencyBinCount;
var dataArray = new Uint8Array(bufferLength);
// Get the Data array
analyser.getByteTimeDomainData(dataArray);
// Display array on time each 3 sec (just to debug)
setInterval(function(){
analyser.getByteTimeDomainData(dataArray);
console.dir(dataArray);
}, 3000);
以下是我的项目的一个小插曲:
我的实现基于以下来源:
在这个岗位上
已修复
因为之前,我使用radio stream测试我的播放器,所以我在Howl对象中将html5选项设置为true
删除此选项后,允许howler使用web音频API,从而修复了我的问题:
工作版本:
var Sound = new Howl({
src: 'https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3',
format: ['mp3']
});
Sound.play();
// Create analyzer
var analyser = Howler.ctx.createAnalyser();
// Connect master gain to analyzer
Howler.masterGain.connect(analyser);
// Connect analyzer to destination
analyser.connect(Howler.ctx.destination);
// Creating output array (according to documentation https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API)
analyser.fftSize = 2048;
var bufferLength = analyser.frequencyBinCount;
var dataArray = new Uint8Array(bufferLength);
// Get the Data array
analyser.getByteTimeDomainData(dataArray);
// Display array on time each 3 sec (just to debug)
setInterval(function(){
analyser.getByteTimeDomainData(dataArray);
console.dir(dataArray);
}, 3000);