node-web-audio-api icon indicating copy to clipboard operation
node-web-audio-api copied to clipboard

Fix `AudioBuffer::getChannelData` implementation

Open b-ma opened this issue 1 year ago • 1 comments

This function relies on unsafe to be able to mutate the returned channel, which may be a problem in some situations

I think this inhibits some undefined behaviour - theoretically.

You are asking the compiler for a mutable reference of the AudioBuffer, but then this information is 'erased' via the unsafe slice cast. This means if you call the method twice and mutate one of the copies, the compiler could assume the other copy will not be affected.

I don't have a clear solution though (perhaps return the same TypedArray via set_property??) - should we add an issue to address this later?

Originally posted by @orottier in https://github.com/ircam-ismm/node-web-audio-api/issues/79#issuecomment-1930401582

b-ma avatar Feb 06 '24 17:02 b-ma