[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

sample and sample_valid

 
WFDB_Sample sample(WFDB_Signal s, WFDB_Time t)
int sample_valid(void)
Return:

n
(from sample): The value (in raw adus) of sample number t in open signal s,if successful, or the value of the previous successfully read sample.
1
(from sample_valid): The most recent value returned by sample was valid
0
(from sample_valid): The most recent t given to sample follows the end of the record
-1
(from sample_valid): The most recent value returned by sample was invalid (because signal s is not available at time t)

The sample function allows the caller to read samples of the currently open input signals in any order. The first argument is a signal number (a non-negative integer between 0 and nsig-1, where nsig is the number of open input signals), and the second is a time, expressed as a non-negative sample number. If sample is invoked with valid input arguments, the companion function sample_valid returns 1.

The sample_valid function can be used to check the results of the most recent invocation of sample. If sample_valid returns 1, the latest value returned by sample is valid. sample_valid returns 0 if sample has most recently returned a padded value following the end of the record. This allows code that uses sample to use the condition `sample_valid() != 0' (or simply `sample_valid()' to determine if more samples are available. If sample_valid returns -1, the most recent value returned by sample was WFDB_INVALID_SAMPLE (because the requested signal s was unavailable at the requested time t). Use the condition `sample_valid() > 0' to check if the most recent value returned by sample is a valid value (e.g., suitable for inclusion in a running average or similar calculation).

For an example of the use of sample and sample_valid, see section Example 7: A General-Purpose FIR Filter.

Be sure to call wfdbquit before exiting from any program that uses sample, to be certain that dynamically allocated memory used by sample is freed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

George B. Moody (george@mit.edu)