public static void ConvertInterleavedToPlanar(float[] buffer)
if (buffer == null || buffer.Length % 2 != 0)
throw new ArgumentException("Buffer must be non-null and have an even number of elements.");
int totalSamples = buffer.Length;
int halfSamples = totalSamples / 2;
fixed (float* ptr = buffer)
for (int start = 1; start < totalSamples - 1; start++)
float temp = ptr[current];
int next = (current < halfSamples) ? 2 * current + 1 : 2 * (current - halfSamples);
while (current != start);
float[] interleaved = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
Console.WriteLine("Before Conversion:");
Console.WriteLine(string.Join(", ", interleaved));
ConvertInterleavedToPlanar(interleaved);
Console.WriteLine("After Conversion:");
Console.WriteLine(string.Join(", ", interleaved));