[med-svn] [SCM] aghermann branch, master, updated. 83bfc7bafe1055d29be61afe3e8ec4482539aa1d

Andrei Zavada johnhommer at gmail.com
Thu Nov 22 23:45:47 UTC 2012


The following commit has been merged in the master branch:
commit 0f805171017e35a54cf8ba9631b3191a22824e5f
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sat Nov 17 23:21:36 2012 +0200

    winfun.hh, to avoid #includ'ing mighty sigproc.hh

diff --git a/src/expdesign/primaries.hh b/src/expdesign/primaries.hh
index 65334e2..f4cba26 100644
--- a/src/expdesign/primaries.hh
+++ b/src/expdesign/primaries.hh
@@ -24,7 +24,7 @@
 #include <stdexcept>
 
 #include "common/config-validate.hh"
-#include "sigproc/sigproc.hh" // for TWinType
+#include "sigproc/winfun.hh"
 #include "model/achermann.hh"
 #include "recording.hh"
 #include "forward-decls.hh"
diff --git a/src/libsigfile/source-base.hh b/src/libsigfile/source-base.hh
index cc60386..343bda2 100644
--- a/src/libsigfile/source-base.hh
+++ b/src/libsigfile/source-base.hh
@@ -15,7 +15,7 @@
 
 #include "common/fs.hh"
 #include "common/alg.hh"
-#include "sigproc/sigproc.hh"
+#include "sigproc/winfun.hh"
 #include "channel.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
diff --git a/src/metrics/psd.hh b/src/metrics/psd.hh
index 0cff6f1..b69a9e4 100644
--- a/src/metrics/psd.hh
+++ b/src/metrics/psd.hh
@@ -18,7 +18,7 @@
 #include <list>
 #include <valarray>
 
-#include "sigproc/sigproc.hh"
+#include "sigproc/winfun.hh"
 #include "forward-decls.hh"
 #include "page-metrics-base.hh"
 
diff --git a/src/sigproc/Makefile.am b/src/sigproc/Makefile.am
index b91c016..a718648 100644
--- a/src/sigproc/Makefile.am
+++ b/src/sigproc/Makefile.am
@@ -7,12 +7,14 @@ noinst_LIBRARIES := liba.a
 liba_a_SOURCES := \
 	exstrom.cc exstrom.hh \
 	ext-filters.cc ext-filters.hh \
-	sigproc.cc sigproc.hh
+	sigproc.cc sigproc.hh \
+	winfun.cc winfun.hh
 
 if DO_PCH
 BUILT_SOURCES := \
 	ext-filters.hh.gch \
 	exstrom.hh.gch \
+	winfun.hh.gch \
 	sigproc.hh.gch
 %.hh.gch: %.hh
 	$(CXXCOMPILE) -c $<
diff --git a/src/sigproc/sigproc.cc b/src/sigproc/sigproc.cc
index 841a12c..3a28440 100644
--- a/src/sigproc/sigproc.cc
+++ b/src/sigproc/sigproc.cc
@@ -19,15 +19,6 @@
 
 using namespace std;
 
-// must match those defined in glade
-const char*
-	sigproc::welch_window_type_names[sigproc::TWinType::_total] = {
-	"Bartlett", "Blackman", "Blackman-Harris",
-	"Hamming",  "Hanning",  "Parzen",
-	"Square",   "Welch"
-};
-
-
 
 template void sigproc::smooth( valarray<TFloat>&, size_t);
 template void sigproc::normalize( valarray<TFloat>&);
@@ -149,118 +140,4 @@ interpolate( const vector<size_t>& xi,
 	return out;
 }
 
-
-
-
-
-
-
-
-// window functions
-
-// The following window functions have been taken from fft.c, part of WFDB package
-
-#define TWOPI (M_PI*2)
-
-/* See Oppenheim & Schafer, Digital Signal Processing, p. 241 (1st ed.) */
-TFloat
-__attribute__ ((const))
-win_bartlett( size_t j, size_t n)
-{
-	TFloat a = 2.0/(n-1), w;
-	if ( (w = j*a) > 1. )
-		w = 2. - w;
-	return w;
-}
-
-/* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.) */
-TFloat
-__attribute__ ((const))
-win_blackman( size_t j, size_t n)
-{
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.42 - .5 * cos(a * j) + .08 * cos(2 * a * j);
-	return w;
-}
-
-/* See Harris, F.J., "On the use of windows for harmonic analysis with the
-   discrete Fourier transform", Proc. IEEE, Jan. 1978 */
-TFloat
-__attribute__ ((const))
-win_blackman_harris( size_t j, size_t n)
-{
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.35875 - 0.48829 * cos(a * j) + 0.14128 * cos(2 * a * j) - 0.01168 * cos(3 * a * j);
-	return w;
-}
-
-/* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.) */
-TFloat
-__attribute__ ((const))
-win_hamming( size_t j, size_t n)
-{
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.54 - 0.46*cos(a*j);
-	return w;
-}
-
-/* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.)
-   The second edition of Numerical Recipes calls this the "Hann" window. */
-TFloat
-__attribute__ ((const))
-win_hanning( size_t j, size_t n)
-{
-	TFloat a = TWOPI/(n-1), w;
-	w = 0.5 - 0.5*cos(a*j);
-	return w;
-}
-
-/* See Press, Flannery, Teukolsky, & Vetterling, Numerical Recipes in C,
-   p. 442 (1st ed.) */
-TFloat
-__attribute__ ((const))
-win_parzen( size_t j, size_t n)
-{
-	TFloat a = (n-1)/2.0, w;
-	if ( (w = (j-a)/(a+1)) > 0.0 )
-		w = 1 - w;
-	else
-		w = 1 + w;
-	return w;
-}
-
-/* See any of the above references. */
-TFloat
-__attribute__ ((const))
-win_square( size_t, size_t)
-{
-	return 1.0;
-}
-
-/* See Press, Flannery, Teukolsky, & Vetterling, Numerical Recipes in C,
-   p. 442 (1st ed.) or p. 554 (2nd ed.) */
-TFloat
-__attribute__ ((const))
-win_welch( size_t j, size_t n)
-{
-	TFloat a = (n-1)/2.0, w;
-	w = (j-a)/(a+1);
-	w = 1 - w*w;
-	return w;
-}
-
-
-
-TFloat (*sigproc::winf[])(size_t, size_t) = {
-	win_bartlett,
-	win_blackman,
-	win_blackman_harris,
-	win_hamming,
-	win_hanning,
-	win_parzen,
-	win_square,
-	win_welch
-};
-
-
 // eof
diff --git a/src/sigproc/sigproc.hh b/src/sigproc/sigproc.hh
index 441f26e..f658265 100644
--- a/src/sigproc/sigproc.hh
+++ b/src/sigproc/sigproc.hh
@@ -31,25 +31,6 @@ using namespace std;
 
 namespace sigproc {
 
-enum TWinType : int {
-	bartlett,
-	blackman,
-	blackman_harris,
-	hamming,
-	hanning,
-	parzen,
-	square,
-	welch,
-	_total
-};
-
-extern const char*
-	welch_window_type_names[TWinType::_total];
-
-
-extern TFloat (*winf[])(size_t, size_t);
-
-
 template <typename T>
 void
 smooth( valarray<T>&, size_t side);
diff --git a/src/sigproc/winfun.cc b/src/sigproc/winfun.cc
new file mode 100644
index 0000000..77282ff
--- /dev/null
+++ b/src/sigproc/winfun.cc
@@ -0,0 +1,136 @@
+// ;-*-C++-*-
+/*
+ *       File name:  sigproc/winfun.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2011-11-17
+ *
+ *         Purpose:  windowing functions
+ *
+ *         License:  GPL
+ */
+
+#include <cmath>
+#include "winfun.hh"
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+// must match those defined in glade
+const char*
+	sigproc::welch_window_type_names[sigproc::TWinType::_total] = {
+	"Bartlett", "Blackman", "Blackman-Harris",
+	"Hamming",  "Hanning",  "Parzen",
+	"Square",   "Welch"
+};
+
+
+// The following window functions have been taken from fft.c, part of WFDB package
+
+#define TWOPI (M_PI*2)
+
+/* See Oppenheim & Schafer, Digital Signal Processing, p. 241 (1st ed.) */
+TFloat
+__attribute__ ((const))
+win_bartlett( size_t j, size_t n)
+{
+	TFloat a = 2.0/(n-1), w;
+	if ( (w = j*a) > 1. )
+		w = 2. - w;
+	return w;
+}
+
+/* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.) */
+TFloat
+__attribute__ ((const))
+win_blackman( size_t j, size_t n)
+{
+	TFloat a = TWOPI/(n-1), w;
+	w = 0.42 - .5 * cos(a * j) + .08 * cos(2 * a * j);
+	return w;
+}
+
+/* See Harris, F.J., "On the use of windows for harmonic analysis with the
+   discrete Fourier transform", Proc. IEEE, Jan. 1978 */
+TFloat
+__attribute__ ((const))
+win_blackman_harris( size_t j, size_t n)
+{
+	TFloat a = TWOPI/(n-1), w;
+	w = 0.35875 - 0.48829 * cos(a * j) + 0.14128 * cos(2 * a * j) - 0.01168 * cos(3 * a * j);
+	return w;
+}
+
+/* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.) */
+TFloat
+__attribute__ ((const))
+win_hamming( size_t j, size_t n)
+{
+	TFloat a = TWOPI/(n-1), w;
+	w = 0.54 - 0.46*cos(a*j);
+	return w;
+}
+
+/* See Oppenheim & Schafer, Digital Signal Processing, p. 242 (1st ed.)
+   The second edition of Numerical Recipes calls this the "Hann" window. */
+TFloat
+__attribute__ ((const))
+win_hanning( size_t j, size_t n)
+{
+	TFloat a = TWOPI/(n-1), w;
+	w = 0.5 - 0.5*cos(a*j);
+	return w;
+}
+
+/* See Press, Flannery, Teukolsky, & Vetterling, Numerical Recipes in C,
+   p. 442 (1st ed.) */
+TFloat
+__attribute__ ((const))
+win_parzen( size_t j, size_t n)
+{
+	TFloat a = (n-1)/2.0, w;
+	if ( (w = (j-a)/(a+1)) > 0.0 )
+		w = 1 - w;
+	else
+		w = 1 + w;
+	return w;
+}
+
+/* See any of the above references. */
+TFloat
+__attribute__ ((const))
+win_square( size_t, size_t)
+{
+	return 1.0;
+}
+
+/* See Press, Flannery, Teukolsky, & Vetterling, Numerical Recipes in C,
+   p. 442 (1st ed.) or p. 554 (2nd ed.) */
+TFloat
+__attribute__ ((const))
+win_welch( size_t j, size_t n)
+{
+	TFloat a = (n-1)/2.0, w;
+	w = (j-a)/(a+1);
+	w = 1 - w*w;
+	return w;
+}
+
+
+
+TFloat (*sigproc::winf[])(size_t, size_t) = {
+	win_bartlett,
+	win_blackman,
+	win_blackman_harris,
+	win_hamming,
+	win_hanning,
+	win_parzen,
+	win_square,
+	win_welch
+};
+
+
+// eof
diff --git a/src/sigproc/winfun.hh b/src/sigproc/winfun.hh
new file mode 100644
index 0000000..920c4be
--- /dev/null
+++ b/src/sigproc/winfun.hh
@@ -0,0 +1,46 @@
+// ;-*-C++-*-
+/*
+ *       File name:  sigproc/winfun.hh
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2012-11-17
+ *
+ *         Purpose:  windowing functions
+ *
+ *         License:  GPL
+ */
+
+#ifndef _SIGPROC_WINFUN_H
+#define _SIGPROC_WINFUN_H
+
+#if HAVE_CONFIG_H && !defined(VERSION)
+#  include "config.h"
+#endif
+
+using namespace std;
+
+namespace sigproc {
+
+enum TWinType {
+	bartlett,
+	blackman,
+	blackman_harris,
+	hamming,
+	hanning,
+	parzen,
+	square,
+	welch,
+	_total
+};
+
+extern const char*
+	welch_window_type_names[TWinType::_total];
+
+extern TFloat (*winf[])(size_t, size_t);
+
+} // namespace sigproc
+
+
+#endif
+
+// eof
diff --git a/src/ui/sf/sf.hh b/src/ui/sf/sf.hh
index ecdf85b..0dd9d17 100644
--- a/src/ui/sf/sf.hh
+++ b/src/ui/sf/sf.hh
@@ -18,7 +18,7 @@
 #include <gtk/gtk.h>
 
 #include "common/config-validate.hh"
-#include "sigproc/sigproc.hh"
+#include "sigproc/winfun.hh"
 #include "metrics/page-metrics-base.hh"
 #include "expdesign/primaries.hh"
 #include "ica/ica.hh"

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list