-2

I try the following. I got data in the following two-dimensioanl buffer array from 2 channels:

object[,] buffer;
buffer = new buffer[2,1000000];

Now i only want to extract one channel to an one-dimensional array.

object[] bufferdata = buffer(1,???);

Does somebody know an way to get those data in a new array WITHOUT copying each value of the buffer(1,i) in a loop. Iam also able to use this kind of two-dimensional array object[][] buffer. Maybe this is bestter to find a solution.

REMberry
  • 172
  • 1
  • 2
  • 12

1 Answers1

0

Going from a 2D array object[,] to a 1D array object[] is always going to be slow. It helps if you don't use object and know what types are stored. Buffer.BlockCopy() wont help you because it only works with array of primitives only.

I suggest either storing the buffer in a jagged array object[][] per channel and then retrieval is trivial object[] data = buffer[i]

Or create a long 1D array of size 2*1000000 and layer the data by channel. Then you can use Array.Copy() or maybe Buffer.BlockCopy() if you know the types to move either the first 1000000 elements out, or the last 1000000 elements out.

John Alexiou
  • 28,472
  • 11
  • 77
  • 133