Here is my code:
long max = pcmU16.Length;
long index = 0;
fixed (ushort* srcFix = pcmU16)
{
ushort* src = srcFix;
next:
*src = 32768;
src++;
index++;
if (index != max)
{
goto next;
}
}
Like you see, it is writing 2 bytes at once. How to use ulong type and write 8 bytes at once? pcmU16 is ushort[] array.
You just coerce it:
Things to watch, though:
maxneeds to be divided by 4, else you’re going out of rangeushortvalues (maxwas 10 initially); that is 2 sets ofulong(4 each), and a final 2ushort; the usual divisor/remainder stuffAs a final note, you might find the index syntax more convenient, i.e.