"Cannot get/set data from streamed sample" from audioclip

I’m trying to reverse an audioclip at run time using the “getData” and “setData” functions. However, whenever I try to use either of those functions, I get this error:

Cannot get/set data from streamed sample
UnityEngine.AudioClip:GetData(Single, Int32)

The audio I’m using in the clip is a .wav set to “Load into Memory”. Is there anything else I need to do?

I know this is an ancient question but i just had the same problem.

It’s because when your script is sampling audio data and attempting to modify them, the audio data must be available as a chunk and not streamed or compressed.

Just modify the audio clip’s load type to “Decompress on load”.

67137-getdata-problem.jpg