Unsigned short Format

WaveBPS "wbps" unsigned short

After the number of channels described in the parent topic, the short type includes the multipliers for each channel and the sample rates at which the data was captured. This is repeated for each channel (Table 1).

Table 1 - Multipliers for Time and Voltage (repeated for each channel)

TypeHeader

Double Precision Float (8 bytes)

m_dSampleRateInMicroseconds

Double Precision Float (8 bytes)

m_dVoltsPerCount

After the multipliers, a 4 byte integer describing the offset to the data (Table 2). You can use the offset to set the file position to the start of the data. Using the offset, the number of raw data samples in the file can be calculated with this equation. (You probably want to cast each item in the equation to an __int64 considering the file's size can be very large)

Numbered = (SizeOfFile() - m_iOffsetToTheData) / (sizeof(short) * (m_iNumberOfChannels))

Table 2 - Offset to the data

TypeHeader

Unsigned int (32 bits)

m_iOffsetToTheData

At the offset there is one short (2 byte value) for each channel. This repeats for every data sample. The time is in microsecond units multiplied by the offset.

Table 3 - Voltage and Time for each sample

TypeHeader

Time (in microseconds)

m_dSampleRateInMicroseconds * ((double) iIndexOfSample)

Voltage (in volts)

m_dVoltsPerCount * ((double) iShortData)

For reading the wbps format the above information is the minimum needed to use the format. For writing the format you must have the following information as well.

After the offset integer are two parameters that describe the trigger (Table 4). First is a unsigned integer that indicates whether there is a trigger location present in the file. This will be either 0 meaning no trigger or 1 meaning a trigger is present. Following the trigger is a double precision parameter indicating where in microseconds the trigger exists.

Table 4 - Trigger Information in File

TypeHeader

Unsigned int (32 bits)

m_iHasTriggerLocation

Double Precision Floating Point (8 bytes)

m_dTriggerLocationInMicroseconds

Following the trigger is information about the decoders used when the file is saved. The decoder is stored as a convenience in the wbps file so when it is loaded it will be properly displayed. This feature is very useful when sharing waveforms.

The file format for the decoders will not be described here. For readers of the file format this data can simply be ignored. For writers of this format, you can write a signed integer equal to -1 for each channel and WaveBPS will simply ignore the decoder section when it reads the file (Table 5).

Table 5 - Decoder Ignore Sequence (repeat for each channel)

TypeHeader

Signed int (32 bits)

iDecoderType (set to -1)

Last updated