Hi,
I need to play an audio clip chunk by chunk, to keep in synch with some events.
So i buffer my clip in an array with GetData, the data are in startingClipSamples
and then i associate a new clip to the audio source audio.clip = myNewEmptyClip
then i SetData the different chunks and play them continuously.
i have a working code for mono sounds:
for (int i = 0; i < magic_chunk; i = i + audio.clip.channels) {
playingSamplesArray[i]=startingClipSamples[i + (magic_chunk * audio.clip.channels * videoFrameIndex)];
if (audio.clip.channels == 2) {
playingSamplesArray[i+1]=startingClipSamples[i + 1 + (magic_chunk * audio.clip.channels * videoFrameIndex)];
}
}
audio.clip.SetData(playingSamplesArray,magic_chunk * videoFrameIndex * audio.clip.channels);
i think it doesn’t work because the floats for each channel are stored in a different way from what i suppose (two near floats 1 for channel), but i cannot find any documentation on unity stores this data inside. Some hints?