问题
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