[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void setifreq(WFDB_Frequency frequency) |
This function sets the current input sampling frequency (in samples per
second per signal). It should be invoked after opening the input
signals (using isigopen
or wfdbinit
), and before using any
of getvec
, getann
, putann
, isigsettime
,
isgsettime
, timstr
, mstimstr
, or strtim
.
Note that the operation of getframe
is unaffected by
setifreq
.
Use setifreq
when your application requires input samples at a
specific frequency. After invoking setifreq
, getvec
resamples the digitized signals from the input signals at the desired
frequency (see section getvec), and all of the WFDB library functions that
accept or return times in sample intervals automatically convert between
the actual sampling intervals and those corresponding to the desired
frequency. This slightly elaborated version of the example program from
the previous chapter invokes setifreq
, passing it the desired sampling
frequency from the command line, then prints the samples in record 100s,
beginning 1 second (t0
) and ending 2 seconds (t1
) from the
beginning of the record:
#include <stdio.h> #include <wfdb/wfdb.h> main(int argc, char **argv) { WFDB_Frequency f = (WFDB_Frequency)0; WFDB_Sample v[2]; WFDB_Siginfo s[2]; WFDB_Time t, t0, t1; if (argc > 1) sscanf(argv[1], "%lf", &f); if (f <= (WFDB_Frequency)0) f = sampfreq("100s"); if (isigopen("100s", s, 2) < 1) exit(1); setifreq(f); t0 = strtim("1"); isigsettime(t0); t1 = strtim("2"); for (t = t0; t <= t1; t++) { if (getvec(v) < 0) break; printf("%d\t%d\n", v[0], v[1]); } exit(0); } |
(See http://www.physionet.org/physiotools/wfdb/examples/psamplex.c for a
copy of this program. Compile it as shown in the previous chapter, then run it
using a command such as `psamplex 100'.) The QRS detector in chapter 6
also illustrates the use of setifreq
(see section Example 10: A QRS Detector).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |