在Safari和Edge中替代audioContext.copyToChannel() [英] alternative to audioContext.copyToChannel() in Safari and Edge
问题描述
Safari和Edge都不支持audioContext.copyToChannel()
函数,以使用自定义内容填充audioBuffer.还有其他方法吗?
Both Safari and Edge do not support the audioContext.copyToChannel()
function to populate an audioBuffer with custom content. Is there any other way to do it?
就我而言,我想创建一个脉冲响应,用该响应填充一个缓冲区,然后用该缓冲区卷积一些声音.对于Chrome和Firefox,此方法有效:
In my case, I want to create an impulse response, populate a buffer with that response and convolve some sound with that buffer. For Chrome and Firefox this works:
buffer = audioCtx.createBuffer(numOfChannels, 1, sampleRate);
buffer.copyToChannel(impulseResponse, 0);
buffer.copyToChannel(impulseResponse, 1);
convolverNode.buffer = buffer;
推荐答案
您可以只在AudioBuffer
上使用getChannelData(channel)
,然后获得一个常规的Float32Array
,可以随意修改.也许您想看看set
方法?
You can just use getChannelData(channel)
on the AudioBuffer
, you then get a regular Float32Array
than you can modify at will. Maybe you want to look at the set
method ?
copyToChannel
在那里可以优化缓冲区副本. -long-channelNumber-unsigned-long-startInChannel"rel =" noreferrer>规范(请参见下面的绿色小框.
copyToChannel
is there to optimize buffer copies , as noted in the spec (see the little green box below.
这篇关于在Safari和Edge中替代audioContext.copyToChannel()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!