Creating an infinite AudioClip no longer works

In Unity 4.3.4 I could create an infinite AudioClip by passing -1 to the length parameter, like this:

AudioClip.Create("Name", -1, channels, sampleRate, false, true, ReadData);

However, in Unity 4.5 that gives me an error message telling me that the length of a clip cannot be below 0.

Was the ability to create infinite AudioClips before 4.5 an unintended feature (bug) that got fixed? Or was it an intended feature that got accidentally removed by new error checking code?

Hello,

You did not have an infinite clip, if you are streaming data, the size of the clip does not matter and should be twice the size of the highest data.Length value (usually 4096, depends on sample rate, channels you use…) to reduce the output delay. In the documentation they use a 1 second clip to generate more easily a continuous sinus waveform. I think you can replace -1 by sampleRate or 4096 and it should work the same.

FYI I tried to put -1 in the clip, even if it is working, if I clip on the clip to see how it looks like, unity crashes ! So yeah that parameter was not intented :stuck_out_tongue: .

If you have any question on this don’t hesitate, I am also programming audio on unity.

regards