Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

alternative to audioContext.copyToChannel() in Safari and Edge

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;
like image 906
fhchl Avatar asked Sep 17 '15 21:09

fhchl


1 Answers

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.

like image 54
padenot Avatar answered Nov 02 '22 15:11

padenot