[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int getvec(WFDB_Sample *vector) |
This function reads a sample from each input signal. The caller should
allocate storage for an array of WFDB_Sample
s (integers) and pass a
pointer to this array to getvec
. (The length of the array must
be no less than the number of input signals, as obtained from
isigopen
or wfdbinit
.) On return, vector[i]
contains the next sample from signal i. For example, this
modified version of the example from chapter 1 reads and prints the
first ten samples of each available input signal:
#include <stdio.h> #include <malloc.h> #include <wfdb/wfdb.h> main() { int i, j, nsig; WFDB_Sample *v; WFDB_Siginfo *s; nsig = isigopen("100s", NULL, 0); if (nsig < 1) exit(1); s = (WFDB_Siginfo *)malloc(nsig * sizeof(WFDB_Siginfo)); if (isigopen("100s", s, nsig) != nsig) exit(1); v = (WFDB_Sample *)malloc(nsig * sizeof(WFDB_Sample)); for (i = 0; i < 10; i++) { if (getvec(v) < 0) break; for (j = 0; j < nsig; j++) printf("%8d", v[j]); printf("\n"); } exit(0); } |
(See http://www.physionet.org/physiotools/wfdb/examples/exgetvec.c for a copy of this program.)
Notice how the value returned by the first invocation of isigopen
is used to determine how many input signals there are. Several of the
example programs in chapter 6 illustrate the use of getvec
; for
example, see section Example 6: A Differentiator.
If setifreq
has been used to modify the input sampling rate,
getvec
resamples the input signals at the desired rate, using
linear interpolation between the pair of samples nearest in time to that
of the sample to be returned. The results will generally be
satisfactory, provided that the original signals do not contain
frequencies near or above the Nyquist limit (half of the desired
sampling frequency). If this is a concern, you may wish to low-pass
filter the input signals using, for example, `fir' (see the
WFDB Applications Guide) before resampling them. If you use
setifreq
to increase the sampling frequency by a large
factor, you may wish to filter the resampled signals within your
application to remove harmonics of the original sampling frequency
introduced by resampling.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |