Spectrum Brands MI.20xx Network Card User Manual


 
48 MI.20xx Manual
Programming Standard acquisition modes
Please refer to the relating chapter earlier in this manual. The examples in this section are written in Visual C++ for Windows, so the examples
differ a little bit for the use with linux.
As the data is read out individually for every memory channel, it is important to know where the data has been stored. Please refer to the
data organization section, to get the information you need first.
Assuming that you know the memory channel or channels that contain the acquired data, you now have to decide whether you want to read
out the whole memory or just one part of it. To select the area to be read out two values are needed by the function SpcGetData.
The value ’start’ as a 32 bit integer value
This value defines the start of the memory area to be read out in samples. This result is, that you do not need to care for the number of bytes
a single sample contains. If you want to read out the whole memory this value must be set to 0.
The value ’len’ as a 32 bit integer value
This value defines the number of samples that are read out, beginning with the first sample defined by the ’start’ value mentioned above. If
you want to read out the whole on-board memory you need to program the „len“ parameter to the before programmed memory size. At this
point please keep in mind that depending on the activated channels there may be more than one board channel in one memory channel.
This „len“ value must be a total memsize for all channels that are acquired in that memory channel. As a result that means if acquiring two
channels to memory channel 0 the „len“ value must be set to „2 * memsize“.
Multiplexed data
Depending on the activated channels and the board type several channels could be stored in one memory channel. As a result that means
that „start“ and „len“ parameter have to be multiplied by the number of channels per memory channel (module). If for example two channels
have been acquired into one memory channel a call like:
reads out data of both channels from memory channel 0 starting at sample position 4k and a length of 2k. The Data array must be of course
large enough to hold data of both channels (in that case 2 * 2k = 4k of data).
Standard mode
Reading out the data is really easy, if a recording modes is used that stores non multiplexed data in the dedicated memory channels. The
next example shows, how to read out the data after having recorded two channels that have been written without multiplexing to both memory
channels.
Example for SpcGetData, no memory allocation error checking performed:
If you use two channels for recording using only one memory channel or four channels, the data in the memory channel(s) is multiplexed and
needs to be unsorted by the user. The following example shows how to unsort the data for the recording of two channels using memory chan-
nel 0.
SpcGetData (hDrv, 0, 2 * 4096, 2 * 2048, Data);
for (i = 0; i < 2; i++) // both memory channels have been used
pbyData[i] = (ptr8) malloc (lMemsize * sizeof(int8)); // allocate memory for the data pointers
// with the maximum size (lMemsize)
SpcGetData (hDrv, 0, 0, lMemsize, (dataptr) pbyData[0]); // no demultiplexing is necessary on channel 0
SpcGetData (hDrv, 1, 0, lMemsize, (dataptr) pbyData[1]); // neither it is on channel 1
for (i = 0; i < 2; i++) // 2 channels to read out from 1 memory channel
pbyData[i] = (ptr8) malloc (lMemsize * sizeof(int8)); // allocate memory for the data pointers
// with the maximum size (lMemsize) per channel
pbyTmp = (ptr8) malloc (lMemsize * 2 * sizeof(int8)); // allocate temporary buffer for copy
SpcGetData (hDrv, 0, 0, 2 * lMemsize, (dataptr) pbyTmp); // get both channels together
// from memory channel 0
for (i = 0; i < lMemsize; i++) // split data in the two channels
{
pbyData[0][i] = pbyTmp[(2 * i)];
pbyData[1][i] = pbyTmp[(2 * i) + 1];
}
free (pbyTmp); // free the temporary buffer