alternative to audioContext.copyToChannel() in Safari and Edge

走远了吗. 提交于 2019-12-10 13:52:26

问题


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?

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;

回答1:


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 is there to optimize buffer copies , as noted in the spec (see the little green box below.




回答2:


edge now supports copyToChannel (tested on edge 38.14393.0.0)



来源:https://stackoverflow.com/questions/32640573/alternative-to-audiocontext-copytochannel-in-safari-and-edge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!