diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/app/nguess.c wfdb-10.4.7/app/nguess.c
--- wfdb-10.4.6/app/nguess.c	2003-02-23 14:14:06.000000000 -0500
+++ wfdb-10.4.7/app/nguess.c	2008-06-11 11:22:36.000000000 -0400
@@ -1,8 +1,8 @@
 /* file: nguess.c		G. Moody	9 June 1986
-				Last revised: 17 February 2003
+				Last revised:  11 June 2008
 -------------------------------------------------------------------------------
 nguess: Guess the times of missing normal sinus beats in an annotation file
-Copyright (C) 2003 George B. Moody
+Copyright (C) 1986-2008 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -127,6 +127,13 @@
 	    help();
 	    exit(0);
 	    break;
+	  case 'm':  /* multiple of predicted interval needed for inserting Q */
+	    if (++i >= argc || (alpha = atof(argv[i]) - 1.0) <= 0) {
+		(void)fprintf(stderr, "%s: multiplier (> 1) must follow -m\n",
+			      pname);
+		exit(1);
+	    }
+	    break;
 	  case 'o':	/* output annotator follows */
 	    if (++i >= argc) {
 		(void)fprintf(stderr, "%s: output annotator must follow -o\n",
@@ -192,7 +199,7 @@
 	to = strtim(argv[(int)to]);
 	if (to < (WFDB_Time)0) to = -to;
     }
-    if (to < from) {
+    if (to < from && to > 0L) {
 	WFDB_Time tt = from;
 
 	from = to;
@@ -231,8 +238,13 @@
 
 	/* From the previous RR intervals, choose the best predictor. */
 	for (i = n, bestpe = 99999., worst = 0.; i > 0; i--) {
+	    double error;
+
+	    /* Put an upper bound on the prediction error, to limit the
+	       influence of a single observation on pe[i]. */
+	    if ((error = fabs(rr[i] - rr[0])) > sps/2) error = sps/2;
 	    if (rr[i] > 0 &&
-		(pe[i] += (fabs(rr[i]-rr[0])-pe[i])/20.) <= bestpe) {
+		(pe[i] += (error - pe[i])/20.) <= bestpe) {
 		bestpe = pe[i];
 		best = i; 
 	    }		/* find best predicting interval */
@@ -336,6 +348,7 @@
  "where RECORD and ANNOTATOR specify the input, and OPTIONS may include:",
  " -f TIME    start at specified TIME",
  " -h         print this usage summary",
+ " -m M       insert a Q if RR > M * prediction (M > 1; default: M = 1.75)",
  " -o OANN    write output as annotator OANN (default: nguess)",
  " -t TIME    stop at specified TIME",
  "The output contains copies of all N annotations, with additional Q",
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/app/sqrs.c wfdb-10.4.7/app/sqrs.c
--- wfdb-10.4.6/app/sqrs.c	2008-01-14 23:01:12.000000000 -0500
+++ wfdb-10.4.7/app/sqrs.c	2008-05-15 17:51:47.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: sqrs.c		G. Moody	27 October 1990
-			Last revised:	14 January 2008
+			Last revised:	  15 May 2008
 
 -------------------------------------------------------------------------------
 sqrs: Single-channel QRS detector
@@ -89,7 +89,7 @@
     long from = 0L, next_minute, now, spm, to = 0L;
     WFDB_Anninfo a;
     WFDB_Annotation annot;
-    static int gvmode = 0;
+    static int gvmode = WFDB_LOWRES;
     static WFDB_Siginfo *s;
     void help();
 
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/app/wqrs.c wfdb-10.4.7/app/wqrs.c
--- wfdb-10.4.6/app/wqrs.c	2008-01-14 18:51:51.000000000 -0500
+++ wfdb-10.4.7/app/wqrs.c	2008-05-15 17:44:58.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wqrs.c		Wei Zong      23 October 1998
-			Last revised: 14 January 2008 (by G. Moody)
+			Last revised:   15 May 2008 (by G. Moody)
 -----------------------------------------------------------------------------
 wqrs: Single-lead QRS detector based on length transform
 Copyright (C) 1998-2008 Wei Zong
@@ -165,7 +165,7 @@
     WFDB_Sample *v;
     WFDB_Siginfo *s;
     WFDB_Time from = 0L, next_minute, now, spm, t, tj, tpq, to = 0L, tt, t1;
-    static int gvmode = 0;
+    static int gvmode = WFDB_GVPAD | WFDB_LOWRES;
     char *prog_name();
     void help();
 
@@ -188,7 +188,7 @@
 	    exit(0);
 	    break;
 	  case 'H':	/* operate in WFDB_HIGHRES mode */
-	    gvmode = WFDB_HIGHRES;
+	    gvmode = WFDB_GVPAD | WFDB_HIGHRES;
 	    break;
 	  case 'j':	/* annotate J-points (ends of QRS complexes) */
 	    jflag = 1;
@@ -262,21 +262,24 @@
 	(void)fprintf(stderr, "%s: insufficient memory\n", pname);
 	exit(2);
     }
-    a.name = "wqrs"; a.stat = WFDB_WRITE;
-    if ((nsig = wfdbinit(record, &a, 1, s, nsig)) < 1) exit(2);
-    if (sig < 0 || sig >= nsig) sig = 0;
-    if ((gain = s[sig].gain) == 0.0) gain = WFDB_DEFGAIN;
+    if ((nsig = isigopen(record, s, nsig)) < 1) exit(2);
     sps = sampfreq((char *)NULL);
-    if (Rflag) {
-    	if (PWFreq == 60.0) setifreq(sps = 120.);
-    	else setifreq(sps = 150.);
-    }
     if (sps < PWFreq) {
 	(void)fprintf(stderr, "%s: sampling frequency (%g Hz) is too low%s",
 		      pname, sps,
 		      (gvmode & WFDB_HIGHRES) ? "\n" : ", try -H option\n");
 	exit(3);
     }
+    if (gvmode & WFDB_HIGHRES)
+	setafreq(sampfreq((char *)NULL));
+    a.name = "wqrs"; a.stat = WFDB_WRITE;
+    if (annopen(record, &a, 1) < 0) exit(2);
+    if (sig < 0 || sig >= nsig) sig = 0;
+    if ((gain = s[sig].gain) == 0.0) gain = WFDB_DEFGAIN;
+    if (Rflag) {
+    	if (PWFreq == 60.0) setifreq(sps = 120.);
+    	else setifreq(sps = 150.);
+    }
     if (from > 0L) {
 	if ((from = strtim(argv[from])) < 0L)
 	from = -from;
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/app/wrsamp.c wfdb-10.4.7/app/wrsamp.c
--- wfdb-10.4.6/app/wrsamp.c	2005-08-11 15:50:13.000000000 -0400
+++ wfdb-10.4.7/app/wrsamp.c	2008-04-18 12:04:25.000000000 -0400
@@ -1,8 +1,8 @@
 /* file: wrsamp.c	G. Moody	10 August 1993
-			Last revised:   11 August 2005
+			Last revised:   18 April 2008
 -------------------------------------------------------------------------------
 wrsamp: Select fields or columns from a file and generate a WFDB record
-Copyright (C) 2002 George B. Moody
+Copyright (C) 1993-2008 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -27,8 +27,11 @@
 */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <wfdb/wfdb.h>
 
+/* The following definition yields dither with a triangular PDF in (-1,1). */
+#define DITHER	        (drand48() + drand48() - 1.0)
 #define isfsep(c)	((fsep && ((c)==fsep)) || ((c)==' ' || (c)=='\t'))
 
 char *pname;
@@ -44,7 +47,7 @@
 #ifndef atof
     double atof();
 #endif
-    int c, cf = 0, *fv = NULL, i, lmax = 1024, mf;
+    int c, cf = 0, dflag = 0, *fv = NULL, i, lmax = 1024, mf;
     FILE *ifile = stdin;
     long t = 0L, t0 = 0L, t1 = 0L;
 #ifndef atol
@@ -62,6 +65,11 @@
 	  case 'c':
 	    cf = -1;
 	    break;
+	  case 'd':
+	    dflag = 1;
+	    srand48((long)0);	/* seed for dither RNG -- replace 0 with a
+				   different value to get different dither */
+	    break;
 	  case 'f':
 	    if (++i >= argc || (t0 = atol(argv[i])) <= 0L) {
 	       (void)fprintf(stderr, "%s: starting line # must follow -f\n",
@@ -275,6 +283,7 @@
 		    }
 		    else {
 			v *= scalef[i];
+			if (dflag) v += DITHER;
 			if (v >= 0) vout[i] = (int)(v + 0.5);
 			else vout[i] = (int)(v - 0.5);
 		    }
@@ -332,6 +341,7 @@
  "where COLUMN selects a field to be copied (leftmost field is column 0),",
  "and OPTIONS may include:",
  " -c          check that each input line contains the same number of fields",
+ " -d          add dither to the input",
  " -f N        start copying with line N (default: 0)",
  " -F FREQ     specify frequency to be written to header file (default: 250)",
  " -G GAIN     specify gain(s) to be written to header file (default: 200)",
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/app/xform.c wfdb-10.4.7/app/xform.c
--- wfdb-10.4.6/app/xform.c	2005-11-20 15:35:52.000000000 -0500
+++ wfdb-10.4.7/app/xform.c	2008-04-18 12:20:15.000000000 -0400
@@ -1,9 +1,9 @@
 /* file: xform.c	G. Moody        8 December 1983
-			Last revised:  20 November 2005
+			Last revised:    18 April 2008
 
 -------------------------------------------------------------------------------
 xform: Sampling frequency, amplitude, and format conversion for WFDB records
-Copyright (C) 1983-2005 George B. Moody
+Copyright (C) 1983-2008 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -26,8 +26,12 @@
 */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <wfdb/wfdb.h>
 
+/* The following definition yields dither with a triangular PDF in (-1,1). */
+#define DITHER	        (drand48() + drand48() - 1.0)
+
 char *pname, *prog_name();
 double gcd();
 void help();
@@ -39,8 +43,8 @@
     char btstring[30], **description, **filename, *irec = NULL, *orec = NULL,
 	*nrec = NULL, *script = NULL, *startp = "0:0", **units;
     double *gain, ifreq, ofreq = 0.0;
-    int clip = 0, *deltav, fflag = 0, gflag = 0, Hflag = 0, i, iframelen,
-	j, m, Mflag = 0, mn, *msiglist, n, nann = 0, nisig,
+    int clip = 0, *deltav, dflag = 0, fflag = 0, gflag = 0, Hflag = 0, i,
+	iframelen, j, m, Mflag = 0, mn, *msiglist, n, nann = 0, nisig,
 	nminutes = 0, nosig = 0, oframelen, reopen = 0, sflag = 0,
 	*siglist = NULL, spf, uflag = 0, use_irec_desc = 1, *v, *vin, *vmax,
 	*vmin, *vout, vt, *vv;
@@ -81,6 +85,11 @@
 	  case 'c':	/* clip (limit) output (default: discard high bits) */
 	    clip = 1;
 	    break;
+	  case 'd':
+	    dflag = 1;
+	    srand48((long)0);	/* seed for dither RNG -- replace 0 with a
+				   different value to get different dither */
+	    break;
 	  case 'f':	/* starting time */
 	    if (++i >= argc) {
 		(void)fprintf(stderr, "%s: time must follow -f\n", pname);
@@ -813,7 +822,11 @@
 		if ((vt = vin[siglist[i]]) == WFDB_INVALID_SAMPLE)
 		    vout[i] = vt;
 		else {
-		    vout[i] = vt*gain[i] + deltav[i];
+		    double vd = vt*gain[i] + deltav[i];
+
+		    if (dflag) vd += DITHER;
+		    if (vd >= 0) vout[i] = (int)(vd + 0.5);
+		    else vout[i] = (int)(vd - 0.5);
 		    if (vout[i] > vmax[i]) {
 			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
 				      i, vout[i]);
@@ -849,7 +862,11 @@
 		if ((vt = vin[msiglist[i] + k]) == WFDB_INVALID_SAMPLE)
 		    vout[j] = vt;
 		else {
-		    vout[j] = vt*gain[i] + deltav[i];
+		    double vd = vt*gain[i] + deltav[i];
+
+		    if (dflag) vd += DITHER;
+		    if (vd >= 0) vout[i] = (int)(vd + 0.5);
+		    else vout[i] = (int)(vd - 0.5);
 		    if (vout[j] > vmax[i]) {
 			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
 				      i, vout[j]);
@@ -893,7 +910,11 @@
 			vv[i] == WFDB_INVALID_SAMPLE)
 			vout[i] = WFDB_INVALID_SAMPLE;
 		    else {
-			vout[i] = vv[i] + x*(v[i]-vv[i]);
+			double vd = vv[i] + x*(v[i]-vv[i]);
+
+			if (dflag) vd += DITHER;
+			if (vd >= 0) vout[i] = (int)(vd + 0.5);
+			else vout[i] = (int)(vd - 0.5);
 			if (vout[i] > vmax[i]) {
 			    (void)fprintf(stderr,"v[%d] = %d (out of range)\n",
 					  i, vout[i]);
@@ -931,8 +952,13 @@
 	    for (i = 0; i < nosig; i++) {
 		if ((vt = vin[siglist[i]]) == WFDB_INVALID_SAMPLE)
 		    v[i] = vt;
-		else
-		    v[i] = vt * gain[i] + deltav[i];
+		else {
+		    double vd = vt*gain[i] + deltav[i];
+
+		    if (dflag) vd += DITHER;
+		    if (vd >= 0) v[i] = (int)(vd + 0.5);
+		    else v[i] = (int)(vd - 0.5);
+		}
 	    }
 	    while (ot <= it) {
 		double x = (ot%n == 0) ? 1.0 : (double)(ot % n)/(double)n;
@@ -941,7 +967,11 @@
 			vv[i] == WFDB_INVALID_SAMPLE)
 			vout[i] = WFDB_INVALID_SAMPLE;
 		    else {
-			vout[i] = vv[i] + x*(v[i]-vv[i]);
+			double vd =  vv[i] + x*(v[i]-vv[i]);
+
+			if (dflag) vd += DITHER;
+			if (vd >= 0) vout[i] = (int)(vd + 0.5);
+			else vout[i] = (int)(vd - 0.5);
 			if (vout[i] > vmax[i]) {
 			    (void)fprintf(stderr,"v[%d] = %d (out of range)\n",
 					  i, vout[i]);
@@ -1060,6 +1090,7 @@
  " -a ANNOTATOR [ANNOTATOR ...]  copy annotations for the specified ANNOTATOR",
  "              from IREC;  two or more ANNOTATORs may follow -a",
  " -c          clip output (default: wrap around if out-of-range)",
+ " -d          add dither to the input if changing sampling frequency or gain",
  " -f TIME     begin at specified time",
  " -h          print this usage summary",
  " -H          open the input record in `high resolution' mode",
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/checkpkg/checkfile wfdb-10.4.7/checkpkg/checkfile
--- wfdb-10.4.6/checkpkg/checkfile	2001-12-11 11:51:30.000000000 -0500
+++ wfdb-10.4.7/checkpkg/checkfile	2008-04-10 15:53:42.000000000 -0400
@@ -1,26 +1,27 @@
 #! /bin/sh
 # file: checkfile		G. Moody	11 December 2001
-#
-# 
+#				Last revised:	 10 April 2008
 #
 # This script compares FILE with the identically-named file in the 'expected'
 # directory.  It returns 0 if the files match, and 1 if there is a difference.
 # If the -v option is used, 'checkfile' prints the differences if any were
 # found; otherwise it prints a message indicating that the files match.
 
+DIFF="diff --strip-trailing-cr"
+
 case $# in
- 1) ( diff $1 expected/$1 >/dev/null 2>&1 ) && exit 0
+ 1) ( $DIFF $1 expected/$1 >/dev/null 2>&1 ) && exit 0
     echo " Files $1 and expected/$1 differ: test failed"
     exit 1 ;;
  2) if [ "$1" = "-v" ]
     then
-        if ( diff $2 expected/$2 >/dev/null 2>&1 )
+        if ( $DIFF $2 expected/$2 >/dev/null 2>&1 )
 	then
 	    echo " Files $2 and expected/$2 match: test succeeded"
 	    exit 0
 	else
 	    echo " Files $2 and expected/$2 differ: test failed"
-	    diff $2 expected/$2
+	    $DIFF $2 expected/$2
 	    exit 1
 	fi
     else
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/conf/version.def wfdb-10.4.7/conf/version.def
--- wfdb-10.4.6/conf/version.def	2008-02-08 10:31:06.000000000 -0500
+++ wfdb-10.4.7/conf/version.def	2008-04-15 12:11:06.000000000 -0400
@@ -1,10 +1,11 @@
 # file: version.def		G. Moody	24 May 2000
-#				Last revised:	8 February 2008
+#				Last revised:	15 April 2008
 # Each release of the WFDB Software Package is identified by a three-part
-# version number, defined here:
+# version number, defined below.  Be sure to leave a single space before
+# and after the "=" in each of the next three lines!
 MAJOR = 10
 MINOR = 4
-RELEASE = 6
+RELEASE = 7
 VERSION = $(MAJOR).$(MINOR).$(RELEASE)
 
 # RPMRELEASE can be incremented if changes are made between official
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/configure wfdb-10.4.7/configure
--- wfdb-10.4.6/configure	2007-03-26 14:59:41.000000000 -0400
+++ wfdb-10.4.7/configure	2008-04-15 12:14:35.000000000 -0400
@@ -1,6 +1,6 @@
 #! /bin/sh
 # file: configure             G. Moody         24 May 2000
-#                             Last revised:   8 August 2005
+#                             Last revised:   15 April 2008
 # Configuration script for the WFDB Software Package
 
 # This script was not generated using 'autoconf'.  If you can implement
@@ -36,7 +36,7 @@
     *)                  cat <<EOF
 usage: $0 [options]
 Options:
-    --dynamic           make a shared (dynamically linkable) WFDB library
+   --dynamic           make a shared (dynamically linkable) WFDB library
                          if possible [default]
     --help              print this message
     -m32                on 64-bit Linux, force compilation in 32-bit mode
@@ -380,7 +380,14 @@
 
 echo "NETFILES=$NETFILES" >../config.cache
 echo "NETFILES_LIBCURL=$NETFILES_LIBCURL" >>../config.cache
+MAJOR=`grep ^MAJOR ../conf/version.def | cut -f 3 -d " "`
+MINOR=`grep ^MINOR ../conf/version.def | cut -f 3 -d " "`
+RELEASE=`grep ^RELEASE ../conf/version.def | cut -f 3 -d " "`
+echo "MAJOR = $MAJOR, MINOR = $MINOR, RELEASE = $RELEASE"
 sed "s/WFDB_NETFILES 1/WFDB_NETFILES $NETFILES/" < ../lib/wfdb.h0 | \
+    sed "s/WFDBMAJOR/$MAJOR/" | \
+    sed "s/WFDBMINOR/$MINOR/" | \
+    sed "s/WFDBRELEASE/$RELEASE/" | \
     sed "s/WFDB_NETFILES_LIBCURL 1/WFDB_NETFILES_LIBCURL $NETFILES_LIBCURL/" \
       >../lib/wfdb.h
 if [ $LIBTYPE = "static" -a $NETLIB != "none" ]
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/doc/wag-src/nguess.1 wfdb-10.4.7/doc/wag-src/nguess.1
--- wfdb-10.4.6/doc/wag-src/nguess.1	2003-02-17 07:18:11.000000000 -0500
+++ wfdb-10.4.7/doc/wag-src/nguess.1	2008-06-11 11:31:07.000000000 -0400
@@ -1,4 +1,4 @@
-.TH NGUESS 1 "17 February 2003" "WFDB 10.3.2" "WFDB Applications Guide"
+.TH NGUESS 1 "11 June 2008" "WFDB 10.4.7" "WFDB Applications Guide"
 .SH NAME
 nguess \- guess the times of missing normal beats in an annotation file
 .SH SYNOPSIS
@@ -24,6 +24,12 @@
 \fB-h\fR
 Print a usage summary.
 .TP
+\fB-m\fR \fIM\fR
+Insert Q annotations in the output at the inferred locations of sinus beats
+only when the input RR interval exceeds \fIM\fR times the predicted RR interval
+(default: \fIM\fR = 1.75).  \fIM\fR must be greater than 1;  its useful range
+is roughly 1.5 to 2.
+.TP
 \fB-o\fR \fIoutput-annotator\fR
 Write output to the annotation file specified by \fIoutput-annotator\fR
 (default: \fBnguess\fR).
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/doc/wag-src/wag.ht1 wfdb-10.4.7/doc/wag-src/wag.ht1
--- wfdb-10.4.6/doc/wag-src/wag.ht1	2005-06-12 01:22:11.000000000 -0400
+++ wfdb-10.4.7/doc/wag-src/wag.ht1	2008-07-14 11:44:51.000000000 -0400
@@ -6,12 +6,15 @@
 <BR><HR>
 <H2>Other links of interest</H2>
 <UL>
-<LI><A HREF="http://www.physionet.org/">PhysioNet</A><BR>
+<LI><A HREF="http://physionet.org/">PhysioNet</A><BR>
 PhysioNet offers free access via the web to large collections of
 recorded physiologic signals and related open-source software.
-PhysioNet is a public service of the Research Resource for
-Complex Physiologic Signals, funded by the National Center for
-Research Resources of the National Institutes of Health.  
+The PhysioNet web site is a public service of the 
+<A HREF="http://physionet.org/resource.shtml">PhysioNet Resource</a>
+funded by the <a href="http://www.nih.gov/" target="other">National
+Institutes of Health</a>'s <a href="http://www.nibib.nih.gov"
+target="other">NIBIB</a> and <a href="http://www.nigms.nih.gov"
+target="other">NIGMS</a>.
 The most recent version of this guide, and of the software it
 describes, may be obtained from PhysioNet.
 <LI><I><A HREF="../wpg/wpg.htm">WFDB Programmer's Guide</A></I>
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/doc/wag-src/wrsamp.1 wfdb-10.4.7/doc/wag-src/wrsamp.1
--- wfdb-10.4.6/doc/wag-src/wrsamp.1	2004-01-26 15:36:26.000000000 -0500
+++ wfdb-10.4.7/doc/wag-src/wrsamp.1	2008-04-18 12:43:34.000000000 -0400
@@ -1,4 +1,4 @@
-.TH WRSAMP 1 "26 January 2004" "WFDB 10.3.12" "WFDB Applications Guide"
+.TH WRSAMP 1 "18 April 2008" "WFDB 10.4.7" "WFDB Applications Guide"
 .SH NAME
 wrsamp \- write WFDB signal files
 .SH SYNOPSIS
@@ -32,6 +32,15 @@
 normally disabled, to allow for input files containing preambles, trailers,
 or occasional extra fields not intended to be read as samples.)
 .TP
+\fB-d\fR
+Dither the input before converting it to integer output, by adding a random
+value to each sample.  The random values are selected from a triangular
+probability density function between -1 and +1.  Dithering is appropriate
+whenever the output has a lower resolution than the input.  Note that the RNG
+used to generate the pseudo-random values is started with a fixed seed, so
+that \fBwrsamp\fR's output is strictly reproducible.  Change the seed in the
+source and recompile to obtain a different realization of dither if desired.
+.TP
 \fB-f\fR \fIn\fR
 Start copying with line \fIn\fR.  By default, \fBwrsamp\fR starts at the
 beginning of its standard input (line 0).
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/doc/wag-src/xform.1 wfdb-10.4.7/doc/wag-src/xform.1
--- wfdb-10.4.6/doc/wag-src/xform.1	2004-01-26 16:00:24.000000000 -0500
+++ wfdb-10.4.7/doc/wag-src/xform.1	2008-04-18 12:43:32.000000000 -0400
@@ -1,4 +1,4 @@
-.TH XFORM 1 "26 January 2004" "WFDB 10.3.12" "WFDB Applications Guide"
+.TH XFORM 1 "18 April 2008" "WFDB 10.4.7" "WFDB Applications Guide"
 .SH NAME
 xform \- sampling frequency, amplitude, and format conversion for WFDB records
 .SH SYNOPSIS
@@ -28,6 +28,18 @@
 devices that must operate using a more restricted amplitude range than was
 used when digitizing the original record.
 .TP
+\fB-d\fR
+Dither the input by adding a pseudo-random value to each
+sample.  The pseudo-random values are selected from a triangular
+probability density function between -1 and +1.  Dithering is
+appropriate whenever the output has a lower resolution than the input,
+as may occur when changing the sampling frequency or gain.  The
+\fB-d\fR option has no effect unless the sampling frequency or gain
+are changed in the output record.  Note that the RNG used to generate the
+pseudo-random values is started with a fixed seed, so that \fBxform\fR's
+output is strictly reproducible.  Change the seed in the source and recompile
+to obtain a different realization of dither if desired.
+.TP
 \fB-f\fR \fItime\fR
 Begin at the specified \fItime\fR in the input record (default: the
 beginning of the record).
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/doc/wpg-src/wpg0.tex wfdb-10.4.7/doc/wpg-src/wpg0.tex
--- wfdb-10.4.6/doc/wpg-src/wpg0.tex	2008-04-09 16:14:03.000000000 -0400
+++ wfdb-10.4.7/doc/wpg-src/wpg0.tex	2008-07-14 12:24:13.000000000 -0400
@@ -510,6 +510,12 @@
 WFDB Software Package distribution, for information on any more recent
 changes that may not be described here.
 
+@unnumberedsubsec Changes in version 10.4.7
+
+Yinqi Zhang reported and contributed a fix for a memory leak in
+@code{make_vsd()} (an internal WFDB library function defined in
+@file{signal.c}).
+
 @unnumberedsubsec Changes in version 10.4.6
 
 The WFDB functions @code{setafreq()} and @code{getafreq()} (for
@@ -522,11 +528,12 @@
 now treated as fatal by default (in previous versions, the functions
 that encountered them returned error values that permitted the
 application to handle them).  These errors occur when there is
-insufficient memory available to the WFDB library.  After invoking
-@code{wfdbmemerr(0)}, if such an error occurs, the function in which it
-occurs will continue running if possible. By default, however, such an
-error will cause the process to terminate.  In either case, the WFDB
-library emits an appropriate error message to aid in troubleshooting.
+insufficient memory available to the WFDB library. To obtain the old
+behavior, in which the calling function will continue execution if
+possible after a memory allocation error, invoke @code{wfdbmemerr(0)}.
+By default, however, such an error will cause the process to
+terminate.  In either case, the WFDB library emits an appropriate
+error message to aid in troubleshooting.
 
 New macros for handling dynamically allocated memory are defined in
 @file{lib/wfdblib.h} and used throughout the WFDB library, eliminating most
@@ -4197,20 +4204,20 @@
 @findex wfdbmemerr (10.4.6)
 
 @example
-@code{void wfdbmemerr(int behavior)}
+@code{void wfdbmemerr(int exit_on_error)}
 @end example
 @noindent
 @c @end group
 
 @noindent
 This function sets how the WFDB library behaves in the event of a memory
-allocation error.  If @var{behavior} is any non-zero value, then such an
-event causes the WFDB library to emit an appropriate error message and then
-terminate the running program.  (This behavior is the default.)
-
-If @var{behavior} is zero, a subsequent memory allocation error will cause
-the WFDB library function in which it occurs to continue running if possible
-(after emitting an error message as above).
+allocation error.  If @var{exit_on_error} is true (any non-zero value), then
+such an event causes the WFDB library to emit an appropriate error message
+and then terminate the running program.  (This behavior is the default.)
+
+If @var{exit_on_error} is false (zero), a subsequent memory allocation error
+will cause the WFDB library function in which it occurs to continue running
+if possible (after emitting an error message as above).
 
 This function was first introduced in WFDB library version 10.4.6.
 
@@ -8759,13 +8766,13 @@
 @end display
 
 PhysioNet offers free access via the web to large collections of
-recorded physiologic signals and related open-source software.
-PhysioNet is a public service of the Research Resource for
-Complex Physiologic Signals, funded by the National Center for
-Research Resources of the National Institutes of Health.  The
-master PhysioNet web server is located at MIT in Cambridge, Massachusetts;
-about ten public mirrors are located elsewhere in the US and around
-the world (see @uref{http://@-www.@-physio@-net.@-org/@-mirrors/} for a list).
+recorded physiologic signals and related open-source software.  The
+PhysioNet web site is a public service of the PhysioNet Resource
+funded by the National Institutes of Health's NIBIB and NIGMS.  The
+master PhysioNet web server is located at MIT in Cambridge,
+Massachusetts; about ten public mirrors are located elsewhere in the
+US and around the world (see
+@uref{http://@-www.@-physio@-net.@-org/@-mirrors/} for a list).
 
 @cindex CDROM
 @cindex ESC DB
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/doc/wpg-src/wpg.ht0 wfdb-10.4.7/doc/wpg-src/wpg.ht0
--- wfdb-10.4.6/doc/wpg-src/wpg.ht0	2008-04-09 16:13:35.000000000 -0400
+++ wfdb-10.4.7/doc/wpg-src/wpg.ht0	2008-07-14 11:44:42.000000000 -0400
@@ -56,9 +56,12 @@
 <LI><A HREF="http://www.physionet.org/">PhysioNet</A><BR>
 PhysioNet offers free access via the web to large collections of
 recorded physiologic signals and related open-source software.
-PhysioNet is a public service of the Research Resource for
-Complex Physiologic Signals, funded by the National Center for
-Research Resources of the National Institutes of Health.  
+The PhysioNet web site is a public service of the 
+<A HREF="http://physionet.org/resource.shtml">PhysioNet Resource</a>
+funded by the <a href="http://www.nih.gov/" target="other">National
+Institutes of Health</a>'s <a href="http://www.nibib.nih.gov"
+target="other">NIBIB</a> and <a href="http://www.nigms.nih.gov"
+target="other">NIGMS</a>.
 The most recent version of this guide, and of the software it
 describes, may be obtained from PhysioNet.
 
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/doc/wug-src/wug0.tex wfdb-10.4.7/doc/wug-src/wug0.tex
--- wfdb-10.4.6/doc/wug-src/wug0.tex	2008-04-09 16:14:54.000000000 -0400
+++ wfdb-10.4.7/doc/wug-src/wug0.tex	2008-07-14 11:50:16.000000000 -0400
@@ -125,7 +125,9 @@
 \htmladdnormallink{PhysioNet}
 {http://www.physionet.org/} \\
 Freely available databases of ECGs and other physiologic signals,
-and related software.  This is the source for the software described in this
+and related software.  The PhysioNet web site is a public service of the 
+PhysioNet Resource funded by the National Institutes of Health's
+NIBIB and NIGMS.  This is the source for the software described in this
 guide.
 
 \item
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/fortran/wfdbf.c wfdb-10.4.7/fortran/wfdbf.c
--- wfdb-10.4.6/fortran/wfdbf.c	2008-02-08 10:45:50.000000000 -0500
+++ wfdb-10.4.7/fortran/wfdbf.c	2008-07-14 12:28:36.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdbf.c	G. Moody	 23 August 1995
-			Last revised:   8 February 2008		wfdblib 10.4.6
+			Last revised:     14 July 2008		wfdblib 10.4.7
 
 _______________________________________________________________________________
 wfdbf: Fortran wrappers for the WFDB library functions
@@ -235,7 +235,8 @@
 
 long setafreq_(double *freq)
 {
-    return (setafreq(*freq));
+    setafreq(*freq);
+    return (0L);
 }
 
 double getafreq_(long int *dummy)
@@ -662,6 +663,12 @@
     return (0L);
 }
 
+long wfdbmemerr_(long int *exit_if_error)
+{
+    wfdbmemerr((int)(*exit_if_error));
+    return (0L);
+}
+
 long wfdbflush_(long int *dummy)
 {
     wfdbflush();
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/lib/annot.c wfdb-10.4.7/lib/annot.c
--- wfdb-10.4.6/lib/annot.c	2008-04-08 14:28:58.000000000 -0400
+++ wfdb-10.4.7/lib/annot.c	2008-04-18 14:35:15.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: annot.c	G. Moody       	 13 April 1989
-			Last revised:     8 April 2008	wfdblib 10.4.6
+			Last revised:    18 April 2008	wfdblib 10.4.7
 WFDB library functions for annotations
 
 _______________________________________________________________________________
@@ -154,7 +154,7 @@
 
 static int get_ann_table(WFDB_Annotator i)
 {
-    char *p1, *p2, *s1, *s2;
+    char *p1, *p2, *s1 = NULL, *s2 = NULL;
     int a;
     WFDB_Annotation annot;
 
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/lib/signal.c wfdb-10.4.7/lib/signal.c
--- wfdb-10.4.6/lib/signal.c	2008-04-08 13:31:07.000000000 -0400
+++ wfdb-10.4.7/lib/signal.c	2008-04-15 11:43:46.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: signal.c	G. Moody	13 April 1989
-			Last revised:    8 April 2008		wfdblib 10.4.6
+			Last revised:   15 April 2008		wfdblib 10.4.7
 WFDB library functions for signals
 
 _______________________________________________________________________________
@@ -482,7 +482,11 @@
 	wfdb_error("make_vsd: oops! nvsig = %d, nisig = %d\n", nvsig, nisig);
 	return (-1);
     }
-
+    for (i = 0; i < maxvsig; i++) {
+        SFREE(vsd[i]->info.fname);
+        SFREE(vsd[i]->info.desc);
+        SFREE(vsd[i]->info.units);
+    } 
     if (maxvsig < nvsig) {
 	unsigned m = maxvsig;
 
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/lib/wfdb.h0 wfdb-10.4.7/lib/wfdb.h0
--- wfdb-10.4.6/lib/wfdb.h0	2008-02-08 10:33:17.000000000 -0500
+++ wfdb-10.4.7/lib/wfdb.h0	2008-07-14 12:20:15.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdb.h		G. Moody	13 June 1983
-			Last revised:   8 February 2008	wfdblib 10.4.6
+			Last revised:   14 July 2008		wfdblib 10.4.7
 WFDB library type, constant, structure, and function interface definitions
 
 _______________________________________________________________________________
@@ -31,9 +31,9 @@
 #define wfdb_WFDB_H
 
 /* WFDB library version. */
-#define WFDB_MAJOR   10
-#define WFDB_MINOR   4
-#define WFDB_RELEASE 6
+#define WFDB_MAJOR   WFDBMAJOR
+#define WFDB_MINOR   WFDBMINOR
+#define WFDB_RELEASE WFDBRELEASE
 #define WFDB_NETFILES 1	/* if 1, library includes code for HTTP, FTP clients */
 #define WFDB_NETFILES_LIBCURL 1
 
@@ -321,6 +321,7 @@
 extern FINT setobsize(int output_buffer_size);
 extern FSTRING wfdbfile(char *file_type, char *record);
 extern FVOID wfdbflush(void);
+extern FVOID wfdbmemerr(int exit_on_error);
 #endif
 
 #ifdef wfdb_CPP
@@ -346,7 +347,7 @@
 extern FDATE strdat();
 extern FVOID setafreq(), setgvmode(), wfdbquit(), wfdbquiet(), dbverbose(),
     setdb(), wfdbflush(), setcfreq(), setbasecount(), flushcal(),
-    wfdbsetiskew(), wfdbsetskew(), wfdbsetstart();
+    wfdbsetiskew(), wfdbsetskew(), wfdbsetstart(), wfdbmemerr();
 extern FFREQUENCY getafreq(), getifreq(), sampfreq(), getcfreq();
 extern FDOUBLE aduphys(), getbasecount();
 #endif
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/Makefile.tpl wfdb-10.4.7/Makefile.tpl
--- wfdb-10.4.6/Makefile.tpl	2006-05-11 15:43:25.000000000 -0400
+++ wfdb-10.4.7/Makefile.tpl	2008-07-14 14:54:33.000000000 -0400
@@ -159,3 +159,5 @@
 	mv $(RPMROOT)/RPMS/*/wfdb*-$(VERSION)-$(RPMRELEASE).*.rpm ..
 	mv $(RPMROOT)/SRPMS/$(PACKAGE)-$(RPMRELEASE).src.rpm ..
 	rm -f $(PACKAGE)-$(RPMRELEASE).spec
+        echo "Remember to sign the RPMs by"
+        echo "   cd ..; rpm --addsign wfdb*$(VERSION)*rpm"
\ No newline at end of file
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/NEWS wfdb-10.4.7/NEWS
--- wfdb-10.4.6/NEWS	2008-04-09 15:49:23.000000000 -0400
+++ wfdb-10.4.7/NEWS	2008-07-14 11:59:07.000000000 -0400
@@ -1,3 +1,13 @@
+10.4.7: 
+	Yinqi Zhang reported and contributed a fix for a memory leak in
+	make_vsd() (an internal WFDB library function defined in signal.c).
+
+	Application nguess has new -m option that allows varying the
+	threshold for inserting inferred sinus beat labels in its output.
+
+	Applications wrsamp and xform can now add dithering to their
+	inputs using a new -d option.
+
 10.4.6:
 	The WFDB functions setafreq() and getafreq() (for setting and getting
 	the time resolution of newly-created output annotation files in ticks
@@ -9,11 +19,12 @@
 	now treated as fatal by default (in previous versions, the functions
 	that encountered them returned error values that permitted the
 	application to handle them).  These errors occur when there is
-	insufficient memory available to the WFDB library.  After invoking
-	wfdbmemerr(0), if such an error occurs, the function in which it
-	occurs will continue if possible.  By default, however, such an
-	error will cause the process to terminate.  In either case, the WFDB
-	library emits an appropriate error message to aid in troubleshooting.
+	insufficient memory available to the WFDB library.  To obtain the
+        old behavior, in which the calling function will continue execution
+        if possible after a memory allocation error, invoke wfdbmemerr(0).
+        By default, however, such an error will cause the process to terminate.
+        In either case, the WFDB library emits an appropriate error message to
+        aid in troubleshooting.
 
 	New macros for handling dynamically allocated memory are defined in
 	lib/wfdblib.h and used throughout the WFDB library, eliminating most
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/wave/wave.c wfdb-10.4.7/wave/wave.c
--- wfdb-10.4.6/wave/wave.c	2005-06-10 10:30:40.000000000 -0400
+++ wfdb-10.4.7/wave/wave.c	2008-05-09 15:48:13.000000000 -0400
@@ -350,6 +350,9 @@
 	setwfdb(nwfdbp);
     }
 
+    /* Make sure there is a calibration database defined. */
+    if (!getenv("WFDBCAL"))
+	putenv("WFDBCAL=wfdbcal");
     /* Initialize the annotation table. */
     (void)read_anntab();
 
diff -Naur --exclude Makefile --exclude info wfdb-10.4.6/wfdb.spec wfdb-10.4.7/wfdb.spec
--- wfdb-10.4.6/wfdb.spec	2006-05-11 15:26:30.000000000 -0400
+++ wfdb-10.4.7/wfdb.spec	2008-04-09 18:36:33.000000000 -0400
@@ -15,6 +15,9 @@
 BuildRoot: /var/tmp/%{name}-root
 
 %changelog
+* Wed Apr 9 2008 George B Moody <george@mit.edu>
+- added rdedfann, signame, signum
+
 * Wed May 11 2006 George B Moody <george@mit.edu>
 - better solution for problems with compiled-in paths
 
@@ -161,6 +164,7 @@
 %{_bindir}/pschart
 %{_bindir}/psfd
 %{_bindir}/rdann
+%{_bindir}/rdedfann
 %{_bindir}/rdsamp
 %{_bindir}/readid
 %{_bindir}/revise
@@ -170,6 +174,8 @@
 %{_bindir}/setwfdb
 %{_bindir}/sigamp
 %{_bindir}/sigavg
+%{_bindir}/signame
+%{_bindir}/signum
 %{_bindir}/skewedit
 %{_bindir}/snip
 %{_bindir}/sortann
