Declaring a Waveform Array
- Updated2025-12-08
- 2 minute(s) read
If you are programming in C, C++, or Visual Basic, you need to declare a waveform array in your program. This array allocates space for the data that is acquired with a Fetch function. LabVIEW users do not need to declare a waveform because the Fetch call allocates it for you.
NI-SCOPE coerces up the min record length specified with the Configure Horizontal Timing function. You can retrieve the actual number of samples acquired by the digitizer by calling niScope Actual Record Length.
NI-SCOPE provides the Actual Num Wfms function when declaring your waveform array. This function returns the number of waveforms that are available for fetching, according to the formula:
numWaveforms = NR x NC x AT
where NR is the number of records, NC is the number of channels, and AT is the number of waveforms for the current acquisition type. AT is equal to 1. Using the Actual Num Wfms function allows your program to handle switching between different acquisition types (such as normal or flexible resolution), channel lists, and minimum record lengths without altering the fetching code.
The waveform array is a single dimension array with a size equal to the number of waveforms to fetch times the number of points to fetch in each waveform. For example, if you are fetching scaled voltage data in a C program, your code may look like the following:
ViReal64 *wfmPtr; ViInt32 actualRecordLength, numWfms; niScope_ActualRecordLength (vi, &actualRecordLength); niScope_ActualNumWfms (vi, channelList, &numWfms); wfmPtr = malloc (sizeof(ViReal64) * actualRecordLength * numWfms);
You also need to declare an niScope_WfmInfo structure to hold the relevant constants that describe each waveform. You need one structure for each fetched waveform. The syntax is as follows:
struct niScope_wfmInfo *wfmInfoPtr; wfmInfoPtr = malloc (sizeof(struct niScope_wfmInfo) * numWfms);