So, I pulled the channel data from AudioBufferand sent it through the portable object to the web worker to do some processing on it, and now I want to get it back. Do I really need to copy it like this?
var myData = new Float32Array(audioBuf.length);
var chanData = audioBuf.getChannelData(0);
for ( var n = 0; n < chanData.length; n++ ) {
chanData[n] = myData[n];
}
I really hope that there is some way to simply change ArrayBuffereach of the feed links AudioBuffer. Sort of...
audioBuf.channel[0].buffer = myData.buffer;
... would be surprisingly simple and effective, but doesn't seem to exist. Is there any way to change the link and avoid copying the data?
The EDIT: . With a little further research, I see that the problem of using the Web Audio API with portable objects is even more annoying. When you transfer the buffers of the array to the working one, the buffers of the base array AudioBufferare cleared, I find it impossible to make the copy operation through the Float32Arrayreturned getChannelDataimpossible. The only way I can accomplish what I want now is to abandon the original AudioBuffer, create a completely new one AudioBuffer, and then copy my data into it. Really??
source
share