Index: trunk/ArchTOIPipe/Kernel/toisegment.cc
===================================================================
--- trunk/ArchTOIPipe/Kernel/toisegment.cc	(revision 1860)
+++ trunk/ArchTOIPipe/Kernel/toisegment.cc	(revision 1944)
@@ -3,5 +3,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: toisegment.cc,v 1.25 2001-11-30 21:07:16 aubourg Exp $
+// $Id: toisegment.cc,v 1.26 2002-03-23 23:05:22 aubourg Exp $
 
 #include "toisegment.h"
@@ -158,4 +158,5 @@
 TOISegmented::BufferSegment::~BufferSegment() {
   if (refcount > 0) {
+    cerr << "TOISegment : delete Buffer with refcount>0" << endl;
     throw(ForbiddenError("TOISegment : delete Buffer with refcount>0"));
   }
@@ -183,4 +184,5 @@
   }
   if (status == COMMITTED) {
+    cerr << "TOISegment : putData in committed buffer" << endl;
     throw(ForbiddenError("TOISegment : putData in committed buffer"));
   }
@@ -196,4 +198,5 @@
   }
   if (status == COMMITTED) {
+    cerr << "TOISegment : putData in committed buffer" << endl;
     throw(ForbiddenError("TOISegment : putData in committed buffer"));
   }
@@ -218,6 +221,8 @@
   int nrc = --refcount;
   pthread_mutex_unlock(&refcount_mutex);
-  if (nrc<0)
+  if (nrc<0) {
+    cerr << "TOISegment : buffer refcount < 0" << endl;
     throw(ForbiddenError("TOISegment : buffer refcount < 0"));
+  }
 }
 
Index: trunk/ArchTOIPipe/Kernel/toisegment.h
===================================================================
--- trunk/ArchTOIPipe/Kernel/toisegment.h	(revision 1860)
+++ trunk/ArchTOIPipe/Kernel/toisegment.h	(revision 1944)
@@ -5,5 +5,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: toisegment.h,v 1.17 2001-11-26 15:13:48 aubourg Exp $
+// $Id: toisegment.h,v 1.18 2002-03-23 23:05:22 aubourg Exp $
 
 #ifndef TOISEGMENT_H
@@ -82,16 +82,21 @@
 
     bool isPastEnd(int sn) {
-      return sn >= sn+bufferSize;
+      return sn >= sn0+bufferSize;
     }
     
   private:
     void checkCommitted() {
-      if (status != COMMITTED) 
+      if (status != COMMITTED) { 
+	cerr << "TOISegment: Read on not committed buffer segment" << endl;
 	throw(ForbiddenError("TOISegment: Read on not committed buffer segment"));
+      }
     }
 
     void checkInRange(int sn) {
-      if (sn < sn0 || sn >= sn+bufferSize)
+      if (sn < sn0 || sn >= sn0+bufferSize) {
+	cerr << "TOISegment: out of range access in buffer segment " << sn << " not in " 
+	     << sn0 << " - " << sn0+bufferSize << endl;
 	throw(RangeCheckError("TOISegment: out of range access in buffer segment"));
+      }
     }
 
Index: trunk/ArchTOIPipe/ProcWSophya/noisegen.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/noisegen.cc	(revision 1860)
+++ trunk/ArchTOIPipe/ProcWSophya/noisegen.cc	(revision 1944)
@@ -38,6 +38,4 @@
   int sne = getMaxOut();
 
-  cout << " NoiseGen::run() SNRange=" << snb << " - " << sne << endl; 
-
   for (int i=snb; i<=sne; i++) {
     putData(0,i,gen->Noise(),0);
Index: trunk/ArchTOIPipe/Processors/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/Processors/Makefile.in	(revision 1860)
+++ trunk/ArchTOIPipe/Processors/Makefile.in	(revision 1944)
@@ -47,6 +47,6 @@
 endif
 
-SRCFILES=toisqfilter.cc nooppr.cc
-
+SRCFILES=toisqfilter.cc nooppr.cc correl.cc nrutil.c dlubksb.c dludcmp.c dtoeplz.c \
+	 wienerdecor.cc
 FILES=$(patsubst %.c,%.o,$(SRCFILES:.cc=.o))
 
Index: trunk/ArchTOIPipe/Processors/correl.cc
===================================================================
--- trunk/ArchTOIPipe/Processors/correl.cc	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/correl.cc	(revision 1944)
@@ -0,0 +1,128 @@
+#include <iostream.h>
+#include "correl.h"
+
+CorrelEstimator::CorrelEstimator(int n, int wsize) {
+  ncor = n;
+  winsize = wsize;
+
+  mT  = new int_4[winsize];
+  mX  = new   r_8[winsize];
+  mY  = new   r_8[winsize];
+  
+  mC  = new   r_8[ncor];
+  mNC = new int_4[ncor];
+
+  for (int i=0; i<ncor; i++) {
+    mC[i] = mNC[i] = 0;
+  }
+
+  mNDat = 0;
+  mINext = 0;
+  mIFirst = 0;
+}
+
+CorrelEstimator::~CorrelEstimator() {
+  delete[] mNC;
+  delete[] mC;
+  delete[] mY;
+  delete[] mX;
+  delete[] mT;
+}
+
+void CorrelEstimator::reset() {
+  for (int i=0; i<ncor; i++) {
+    mC[i] = mNC[i] = 0;
+  }
+
+  mNDat = 0;
+  mINext = 0;
+  mIFirst = 0;
+
+}
+
+void CorrelEstimator::push(int_4 t, r_8 x, r_8 y) {
+  if (mNDat == winsize) {
+    pop();
+  }
+  mT[mINext] = t;
+  mX[mINext] = x;
+  mY[mINext] = y;
+  int iCur = mINext;
+  mINext++; if (mINext == winsize) mINext=0;
+  mNDat++;
+  if (mINext > winsize) {cerr << "CorrelEstimator::push mINext > winsize"<< endl; abort();}
+
+  
+  for (int i=0; i<ncor; i++) {
+    int ii=iCur;
+    while (mT[ii] > t-i) {
+      ii--;
+      if (ii<0) ii = winsize-1;
+      if ((mINext <= mIFirst  &&  (ii<mIFirst && ii>=mINext)) ||
+	  (mINext >  mIFirst  &&  (ii<mIFirst || ii>=mINext))) {  // not found
+	ii = -1;
+	break;
+      }
+    }
+    if (ii>0) {
+      mNC[i]++;
+      mC[i] += mX[iCur] * mY[ii];
+    }
+  }
+}
+
+void CorrelEstimator::push(int_4 t, r_8 x) {
+  push(t,x,x);
+}
+
+void CorrelEstimator::pop() {
+  int t = mT[mIFirst];
+  for (int i=0; i<ncor; i++) {
+    int ii=mIFirst;
+    while (mT[ii] < t+i) {
+      ii++;
+      if (ii>=winsize) ii = 0;
+      if ((mINext <= mIFirst  &&  ii<mIFirst  &&  ii>=mINext) ||
+	  (mINext >  mIFirst  &&  ii>=mINext)) {  // not found
+	ii = -1;
+	break;
+      }
+    }
+    if (ii>0) {
+      mNC[i]--;
+      mC[i] -= mX[ii] * mY[mIFirst];
+    }
+ 
+    mIFirst++;
+    if (mIFirst >= winsize) {
+      mIFirst = 0;
+    }
+  }
+}
+
+void CorrelEstimator::recompute() {
+}
+
+r_8 CorrelEstimator::correl(int k) {
+  if (k<0 || k>= ncor) {
+    cerr << "invalid parameter " << k << " for correl "
+	 << "(valid : [0;" << ncor-1<<"])" << endl;
+    abort();
+  }
+
+  if (mNC[k] == 0) {
+    return 0;
+  } else {
+    return mC[k]/mNC[k];
+  }
+}
+
+int_4 CorrelEstimator::ns4correl(int k) {
+  if (k<0 || k>= ncor) {
+    cerr << "invalid parameter " << k << " for correl "
+         << "(valid : [0;" << ncor-1<<"])" << endl;
+    abort();
+  }
+
+  return mNC[k];
+}
Index: trunk/ArchTOIPipe/Processors/correl.h
===================================================================
--- trunk/ArchTOIPipe/Processors/correl.h	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/correl.h	(revision 1944)
@@ -0,0 +1,55 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+// ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL
+//                               Eric Aubourg
+//                               Christophe Magneville
+//                               Reza Ansari
+// $Id: correl.h,v 1.1 2002-03-23 23:05:21 aubourg Exp $
+
+#ifndef CORREL_H
+#define CORREL_H
+
+#include "config.h"
+
+#ifndef NO_SOPHYA
+#include "machdefs.h"
+using namespace SOPHYA;
+#endif
+
+
+class CorrelEstimator {
+public:
+  CorrelEstimator(int n, int wsize); // n = longueur calcul autocorr, wsize = nsamples pour calcul
+  ~CorrelEstimator();
+
+  void push(int_4 t, r_8 x, r_8 y);
+  void push(int_4 t, r_8 x); // auto-correlation
+
+  r_8      correl(int k);    // correlation r_k
+  int_4    ns4correl(int k); // n. samples used for correl
+
+  void reset();
+  
+protected:
+  int winsize;
+  int ncor;
+
+  int_4* mT;
+  r_8*   mX;
+  r_8*   mY;
+
+  int_4  mNDat;
+  int_4  mINext;
+  int_4  mIFirst;
+
+  r_8*   mC;
+  int_4* mNC;
+
+  void pop();
+  void recompute();
+};
+
+
+
+#endif
+
Index: trunk/ArchTOIPipe/Processors/dlubksb.c
===================================================================
--- trunk/ArchTOIPipe/Processors/dlubksb.c	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/dlubksb.c	(revision 1944)
@@ -0,0 +1,20 @@
+void dlubksb(double **a, int n, int *indx, double b[])
+{
+	int i,ii=0,ip,j;
+	double sum;
+
+	for (i=1;i<=n;i++) {
+		ip=indx[i];
+		sum=b[ip];
+		b[ip]=b[i];
+		if (ii)
+			for (j=ii;j<=i-1;j++) sum -= a[i][j]*b[j];
+		else if (sum) ii=i;
+		b[i]=sum;
+	}
+	for (i=n;i>=1;i--) {
+		sum=b[i];
+		for (j=i+1;j<=n;j++) sum -= a[i][j]*b[j];
+		b[i]=sum/a[i][i];
+	}
+}
Index: trunk/ArchTOIPipe/Processors/dludcmp.c
===================================================================
--- trunk/ArchTOIPipe/Processors/dludcmp.c	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/dludcmp.c	(revision 1944)
@@ -0,0 +1,62 @@
+#include <math.h>
+#define NRANSI
+#define TINY 1.0e-20;
+
+void nrerror(char error_text[]);
+double *dvector(long nl, long nh);
+void free_dvector(double *v, long nl, long nh);
+int dludcmp(double **a, int n, int *indx, double *d);
+
+int dludcmp(double **a, int n, int *indx, double *d)
+{
+	int i,imax,j,k;
+	double big,dum,sum,temp;
+	double *vv;
+
+	vv=dvector(1,n);
+	*d=1.0;
+	for (i=1;i<=n;i++) {
+		big=0.0;
+		for (j=1;j<=n;j++)
+			if ((temp=fabs(a[i][j])) > big) big=temp;
+		if (big == 0.0) return -1;
+		vv[i]=1.0/big;
+	}
+	for (j=1;j<=n;j++) {
+		for (i=1;i<j;i++) {
+			sum=a[i][j];
+			for (k=1;k<i;k++) sum -= a[i][k]*a[k][j];
+			a[i][j]=sum;
+		}
+		big=0.0;
+		for (i=j;i<=n;i++) {
+			sum=a[i][j];
+			for (k=1;k<j;k++)
+				sum -= a[i][k]*a[k][j];
+			a[i][j]=sum;
+			if ( (dum=vv[i]*fabs(sum)) >= big) {
+				big=dum;
+				imax=i;
+			}
+		}
+		if (j != imax) {
+			for (k=1;k<=n;k++) {
+				dum=a[imax][k];
+				a[imax][k]=a[j][k];
+				a[j][k]=dum;
+			}
+			*d = -(*d);
+			vv[imax]=vv[j];
+		}
+		indx[j]=imax;
+		if (a[j][j] == 0.0) a[j][j]=TINY;
+		if (j != n) {
+			dum=1.0/(a[j][j]);
+			for (i=j+1;i<=n;i++) a[i][j] *= dum;
+		}
+	}
+	free_dvector(vv,1,n);
+	return 0;
+}
+#undef TINY
+#undef NRANSI
Index: trunk/ArchTOIPipe/Processors/dtoeplz.c
===================================================================
--- trunk/ArchTOIPipe/Processors/dtoeplz.c	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/dtoeplz.c	(revision 1944)
@@ -0,0 +1,59 @@
+#define NRANSI
+#include "nrutil.h"
+#define FREERETURN {free_dvector(h,1,n);free_dvector(g,1,n);return;}
+
+void dtoeplz(double r[], double x[], double y[], int n)
+{
+	int j,k,m,m1,m2;
+	double pp,pt1,pt2,qq,qt1,qt2,sd,sgd,sgn,shn,sxn;
+	double *g,*h;
+
+	if (r[n] == 0.0) nrerror("dtoeplz-1 singular principal minor");
+	g=dvector(1,n);
+	h=dvector(1,n);
+	x[1]=y[1]/r[n];
+	if (n == 1) FREERETURN
+	g[1]=r[n-1]/r[n];
+	h[1]=r[n+1]/r[n];
+	for (m=1;m<=n;m++) {
+		m1=m+1;
+		sxn = -y[m1];
+		sd = -r[n];
+		for (j=1;j<=m;j++) {
+			sxn += r[n+m1-j]*x[j];
+			sd += r[n+m1-j]*g[m-j+1];
+		}
+		if (sd == 0.0) nrerror("dtoeplz-2 singular principal minor");
+		x[m1]=sxn/sd;
+		for (j=1;j<=m;j++) x[j] -= x[m1]*g[m-j+1];
+		if (m1 == n) FREERETURN
+		sgn = -r[n-m1];
+		shn = -r[n+m1];
+		sgd = -r[n];
+		for (j=1;j<=m;j++) {
+			sgn += r[n+j-m1]*g[j];
+			shn += r[n+m1-j]*h[j];
+			sgd += r[n+j-m1]*h[m-j+1];
+		}
+		if (sd == 0.0 || sgd == 0.0) nrerror("dtoeplz-3 singular principal minor");
+		g[m1]=sgn/sgd;
+		h[m1]=shn/sd;
+		k=m;
+		m2=(m+1) >> 1;
+		pp=g[m1];
+		qq=h[m1];
+		for (j=1;j<=m2;j++) {
+			pt1=g[j];
+			pt2=g[k];
+			qt1=h[j];
+			qt2=h[k];
+			g[j]=pt1-pp*qt2;
+			g[k]=pt2-pp*qt1;
+			h[j]=qt1-qq*pt2;
+			h[k--]=qt2-qq*pt1;
+		}
+	}
+	nrerror("dtoeplz - should not arrive here!");
+}
+#undef FREERETURN
+#undef NRANSI
Index: trunk/ArchTOIPipe/Processors/nrutil.c
===================================================================
--- trunk/ArchTOIPipe/Processors/nrutil.c	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/nrutil.c	(revision 1944)
@@ -0,0 +1,618 @@
+#if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#define NR_END 1
+#define FREE_ARG char*
+
+void nrerror(char error_text[]);
+
+void nrerror(char error_text[])
+/* Numerical Recipes standard error handler */
+{
+	fprintf(stderr,"Numerical Recipes run-time error...\n");
+	fprintf(stderr,"%s\n",error_text);
+	fprintf(stderr,"...now exiting to system...\n");
+	exit(1);
+}
+
+double *dvector(long nl, long nh)
+/* allocate a double vector with subscript range v[nl..nh] */
+{
+	double *v;
+
+	v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
+	if (!v) nrerror("allocation failure in vector()");
+	return v-nl+NR_END;
+}
+
+int *ivector(long nl, long nh)
+/* allocate an int vector with subscript range v[nl..nh] */
+{
+	int *v;
+
+	v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
+	if (!v) nrerror("allocation failure in ivector()");
+	return v-nl+NR_END;
+}
+
+unsigned char *cvector(long nl, long nh)
+/* allocate an unsigned char vector with subscript range v[nl..nh] */
+{
+	unsigned char *v;
+
+	v=(unsigned char *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
+	if (!v) nrerror("allocation failure in cvector()");
+	return v-nl+NR_END;
+}
+
+unsigned long *lvector(long nl, long nh)
+/* allocate an unsigned long vector with subscript range v[nl..nh] */
+{
+	unsigned long *v;
+
+	v=(unsigned long *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(long)));
+	if (!v) nrerror("allocation failure in lvector()");
+	return v-nl+NR_END;
+}
+
+#if 0
+double *dvector(long nl, long nh)
+/* allocate a double vector with subscript range v[nl..nh] */
+{
+	double *v;
+
+	v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
+	if (!v) nrerror("allocation failure in dvector()");
+	return v-nl+NR_END;
+}
+#endif
+
+double **matrix(long nrl, long nrh, long ncl, long nch)
+/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	double **m;
+
+	/* allocate pointers to rows */
+	m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure 1 in matrix()");
+	m += NR_END;
+	m -= nrl;
+
+	/* allocate rows and set pointers to them */
+	m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
+	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+	m[nrl] += NR_END;
+	m[nrl] -= ncl;
+
+	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double **dmatrix(long nrl, long nrh, long ncl, long nch)
+/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	double **m;
+
+	/* allocate pointers to rows */
+	m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure 1 in matrix()");
+	m += NR_END;
+	m -= nrl;
+
+	/* allocate rows and set pointers to them */
+	m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
+	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+	m[nrl] += NR_END;
+	m[nrl] -= ncl;
+
+	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+int **imatrix(long nrl, long nrh, long ncl, long nch)
+/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	int **m;
+
+	/* allocate pointers to rows */
+	m=(int **) malloc((size_t)((nrow+NR_END)*sizeof(int*)));
+	if (!m) nrerror("allocation failure 1 in matrix()");
+	m += NR_END;
+	m -= nrl;
+
+
+	/* allocate rows and set pointers to them */
+	m[nrl]=(int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int)));
+	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+	m[nrl] += NR_END;
+	m[nrl] -= ncl;
+
+	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double **submatrix(double **a, long oldrl, long oldrh, long oldcl, long oldch,
+	long newrl, long newcl)
+/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
+{
+	long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
+	double **m;
+
+	/* allocate array of pointers to rows */
+	m=(double **) malloc((size_t) ((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure in submatrix()");
+	m += NR_END;
+	m -= newrl;
+
+	/* set pointers to rows */
+	for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double **convert_matrix(double *a, long nrl, long nrh, long ncl, long nch)
+/* allocate a double matrix m[nrl..nrh][ncl..nch] that points to the matrix
+declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
+and ncol=nch-ncl+1. The routine should be called with the address
+&a[0][0] as the first argument. */
+{
+	long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	double **m;
+
+	/* allocate pointers to rows */
+	m=(double **) malloc((size_t) ((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure in convert_matrix()");
+	m += NR_END;
+	m -= nrl;
+
+	/* set pointers to rows */
+	m[nrl]=a-ncl;
+	for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
+/* allocate a double 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
+{
+	long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
+	double ***t;
+
+	/* allocate pointers to pointers to rows */
+	t=(double ***) malloc((size_t)((nrow+NR_END)*sizeof(double**)));
+	if (!t) nrerror("allocation failure 1 in f3tensor()");
+	t += NR_END;
+	t -= nrl;
+
+	/* allocate pointers to rows and set pointers to them */
+	t[nrl]=(double **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double*)));
+	if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
+	t[nrl] += NR_END;
+	t[nrl] -= ncl;
+
+	/* allocate rows and set pointers to them */
+	t[nrl][ncl]=(double *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(double)));
+	if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
+	t[nrl][ncl] += NR_END;
+	t[nrl][ncl] -= ndl;
+
+	for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
+	for(i=nrl+1;i<=nrh;i++) {
+		t[i]=t[i-1]+ncol;
+		t[i][ncl]=t[i-1][ncl]+ncol*ndep;
+		for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
+	}
+
+	/* return pointer to array of pointers to rows */
+	return t;
+}
+
+void free_vector(double *v, long nl, long nh)
+/* free a double vector allocated with vector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_ivector(int *v, long nl, long nh)
+/* free an int vector allocated with ivector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_cvector(unsigned char *v, long nl, long nh)
+/* free an unsigned char vector allocated with cvector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_lvector(unsigned long *v, long nl, long nh)
+/* free an unsigned long vector allocated with lvector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_dvector(double *v, long nl, long nh)
+/* free a double vector allocated with dvector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_matrix(double **m, long nrl, long nrh, long ncl, long nch)
+/* free a double matrix allocated by matrix() */
+{
+	free((FREE_ARG) (m[nrl]+ncl-NR_END));
+	free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch)
+/* free a double matrix allocated by dmatrix() */
+{
+	free((FREE_ARG) (m[nrl]+ncl-NR_END));
+	free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch)
+/* free an int matrix allocated by imatrix() */
+{
+	free((FREE_ARG) (m[nrl]+ncl-NR_END));
+	free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_submatrix(double **b, long nrl, long nrh, long ncl, long nch)
+/* free a submatrix allocated by submatrix() */
+{
+	free((FREE_ARG) (b+nrl-NR_END));
+}
+
+void free_convert_matrix(double **b, long nrl, long nrh, long ncl, long nch)
+/* free a matrix allocated by convert_matrix() */
+{
+	free((FREE_ARG) (b+nrl-NR_END));
+}
+
+void free_f3tensor(double ***t, long nrl, long nrh, long ncl, long nch,
+	long ndl, long ndh)
+/* free a double f3tensor allocated by f3tensor() */
+{
+	free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
+	free((FREE_ARG) (t[nrl]+ncl-NR_END));
+	free((FREE_ARG) (t+nrl-NR_END));
+}
+
+#else /* ANSI */
+/* traditional - K&R */
+
+#include <stdio.h>
+#define NR_END 1
+#define FREE_ARG char*
+
+void nrerror(error_text)
+char error_text[];
+/* Numerical Recipes standard error handler */
+{
+	void exit();
+
+	fprintf(stderr,"Numerical Recipes run-time error...\n");
+	fprintf(stderr,"%s\n",error_text);
+	fprintf(stderr,"...now exiting to system...\n");
+	exit(1);
+}
+
+double *vector(nl,nh)
+long nh,nl;
+/* allocate a double vector with subscript range v[nl..nh] */
+{
+	double *v;
+
+	v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
+	if (!v) nrerror("allocation failure in vector()");
+	return v-nl+NR_END;
+}
+
+int *ivector(nl,nh)
+long nh,nl;
+/* allocate an int vector with subscript range v[nl..nh] */
+{
+	int *v;
+
+	v=(int *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(int)));
+	if (!v) nrerror("allocation failure in ivector()");
+	return v-nl+NR_END;
+}
+
+unsigned char *cvector(nl,nh)
+long nh,nl;
+/* allocate an unsigned char vector with subscript range v[nl..nh] */
+{
+	unsigned char *v;
+
+	v=(unsigned char *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
+	if (!v) nrerror("allocation failure in cvector()");
+	return v-nl+NR_END;
+}
+
+unsigned long *lvector(nl,nh)
+long nh,nl;
+/* allocate an unsigned long vector with subscript range v[nl..nh] */
+{
+	unsigned long *v;
+
+	v=(unsigned long *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(long)));
+	if (!v) nrerror("allocation failure in lvector()");
+	return v-nl+NR_END;
+}
+
+double *dvector(nl,nh)
+long nh,nl;
+/* allocate a double vector with subscript range v[nl..nh] */
+{
+	double *v;
+
+	v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
+	if (!v) nrerror("allocation failure in dvector()");
+	return v-nl+NR_END;
+}
+
+double **matrix(nrl,nrh,ncl,nch)
+long nch,ncl,nrh,nrl;
+/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	double **m;
+
+	/* allocate pointers to rows */
+	m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure 1 in matrix()");
+	m += NR_END;
+	m -= nrl;
+
+	/* allocate rows and set pointers to them */
+	m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
+	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+	m[nrl] += NR_END;
+	m[nrl] -= ncl;
+
+	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double **dmatrix(nrl,nrh,ncl,nch)
+long nch,ncl,nrh,nrl;
+/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	double **m;
+
+	/* allocate pointers to rows */
+	m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure 1 in matrix()");
+	m += NR_END;
+	m -= nrl;
+
+	/* allocate rows and set pointers to them */
+	m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
+	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+	m[nrl] += NR_END;
+	m[nrl] -= ncl;
+
+	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+int **imatrix(nrl,nrh,ncl,nch)
+long nch,ncl,nrh,nrl;
+/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	int **m;
+
+	/* allocate pointers to rows */
+	m=(int **) malloc((unsigned int)((nrow+NR_END)*sizeof(int*)));
+	if (!m) nrerror("allocation failure 1 in matrix()");
+	m += NR_END;
+	m -= nrl;
+
+
+	/* allocate rows and set pointers to them */
+	m[nrl]=(int *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(int)));
+	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+	m[nrl] += NR_END;
+	m[nrl] -= ncl;
+
+	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double **submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)
+double **a;
+long newcl,newrl,oldch,oldcl,oldrh,oldrl;
+/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
+{
+	long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
+	double **m;
+
+	/* allocate array of pointers to rows */
+	m=(double **) malloc((unsigned int) ((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure in submatrix()");
+	m += NR_END;
+	m -= newrl;
+
+	/* set pointers to rows */
+	for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
+
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double **convert_matrix(a,nrl,nrh,ncl,nch)
+double *a;
+long nch,ncl,nrh,nrl;
+/* allocate a double matrix m[nrl..nrh][ncl..nch] that points to the matrix
+declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
+and ncol=nch-ncl+1. The routine should be called with the address
+&a[0][0] as the first argument. */
+{
+	long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	double **m;
+
+	/* allocate pointers to rows */
+	m=(double **) malloc((unsigned int) ((nrow+NR_END)*sizeof(double*)));
+	if (!m)	nrerror("allocation failure in convert_matrix()");
+	m += NR_END;
+	m -= nrl;
+
+	/* set pointers to rows */
+	m[nrl]=a-ncl;
+	for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+double ***f3tensor(nrl,nrh,ncl,nch,ndl,ndh)
+long nch,ncl,ndh,ndl,nrh,nrl;
+/* allocate a double 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
+{
+	long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
+	double ***t;
+
+	/* allocate pointers to pointers to rows */
+	t=(double ***) malloc((unsigned int)((nrow+NR_END)*sizeof(double**)));
+	if (!t) nrerror("allocation failure 1 in f3tensor()");
+	t += NR_END;
+	t -= nrl;
+
+	/* allocate pointers to rows and set pointers to them */
+	t[nrl]=(double **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double*)));
+	if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
+	t[nrl] += NR_END;
+	t[nrl] -= ncl;
+
+	/* allocate rows and set pointers to them */
+	t[nrl][ncl]=(double *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(double)));
+	if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
+	t[nrl][ncl] += NR_END;
+	t[nrl][ncl] -= ndl;
+
+	for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
+	for(i=nrl+1;i<=nrh;i++) {
+		t[i]=t[i-1]+ncol;
+		t[i][ncl]=t[i-1][ncl]+ncol*ndep;
+		for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
+	}
+
+	/* return pointer to array of pointers to rows */
+	return t;
+}
+
+void free_vector(v,nl,nh)
+double *v;
+long nh,nl;
+/* free a double vector allocated with vector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_ivector(v,nl,nh)
+int *v;
+long nh,nl;
+/* free an int vector allocated with ivector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_cvector(v,nl,nh)
+long nh,nl;
+unsigned char *v;
+/* free an unsigned char vector allocated with cvector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_lvector(v,nl,nh)
+long nh,nl;
+unsigned long *v;
+/* free an unsigned long vector allocated with lvector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_dvector(v,nl,nh)
+double *v;
+long nh,nl;
+/* free a double vector allocated with dvector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_matrix(m,nrl,nrh,ncl,nch)
+double **m;
+long nch,ncl,nrh,nrl;
+/* free a double matrix allocated by matrix() */
+{
+	free((FREE_ARG) (m[nrl]+ncl-NR_END));
+	free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_dmatrix(m,nrl,nrh,ncl,nch)
+double **m;
+long nch,ncl,nrh,nrl;
+/* free a double matrix allocated by dmatrix() */
+{
+	free((FREE_ARG) (m[nrl]+ncl-NR_END));
+	free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_imatrix(m,nrl,nrh,ncl,nch)
+int **m;
+long nch,ncl,nrh,nrl;
+/* free an int matrix allocated by imatrix() */
+{
+	free((FREE_ARG) (m[nrl]+ncl-NR_END));
+	free((FREE_ARG) (m+nrl-NR_END));
+}
+
+void free_submatrix(b,nrl,nrh,ncl,nch)
+double **b;
+long nch,ncl,nrh,nrl;
+/* free a submatrix allocated by submatrix() */
+{
+	free((FREE_ARG) (b+nrl-NR_END));
+}
+
+void free_convert_matrix(b,nrl,nrh,ncl,nch)
+double **b;
+long nch,ncl,nrh,nrl;
+/* free a matrix allocated by convert_matrix() */
+{
+	free((FREE_ARG) (b+nrl-NR_END));
+}
+
+void free_f3tensor(t,nrl,nrh,ncl,nch,ndl,ndh)
+double ***t;
+long nch,ncl,ndh,ndl,nrh,nrl;
+/* free a double f3tensor allocated by f3tensor() */
+{
+	free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
+	free((FREE_ARG) (t[nrl]+ncl-NR_END));
+	free((FREE_ARG) (t+nrl-NR_END));
+}
+
+#endif /* ANSI */
Index: trunk/ArchTOIPipe/Processors/nrutil.h
===================================================================
--- trunk/ArchTOIPipe/Processors/nrutil.h	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/nrutil.h	(revision 1944)
@@ -0,0 +1,101 @@
+#ifndef _NR_UTILS_H_
+#define _NR_UTILS_H_
+
+static double sqrarg;
+#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
+
+static double dsqrarg;
+#define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
+
+static double dmaxarg1,dmaxarg2;
+#define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
+        (dmaxarg1) : (dmaxarg2))
+
+static double dminarg1,dminarg2;
+#define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
+        (dminarg1) : (dminarg2))
+
+static double maxarg1,maxarg2;
+#define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
+        (maxarg1) : (maxarg2))
+
+static double minarg1,minarg2;
+#define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
+        (minarg1) : (minarg2))
+
+static long lmaxarg1,lmaxarg2;
+#define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
+        (lmaxarg1) : (lmaxarg2))
+
+static long lminarg1,lminarg2;
+#define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
+        (lminarg1) : (lminarg2))
+
+static int imaxarg1,imaxarg2;
+#define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
+        (imaxarg1) : (imaxarg2))
+
+static int iminarg1,iminarg2;
+#define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
+        (iminarg1) : (iminarg2))
+
+#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
+
+#if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
+
+void nrerror(char error_text[]);
+double *dvector(long nl, long nh);
+int *ivector(long nl, long nh);
+unsigned char *cvector(long nl, long nh);
+unsigned long *lvector(long nl, long nh);
+double *dvector(long nl, long nh);
+double **matrix(long nrl, long nrh, long ncl, long nch);
+double **dmatrix(long nrl, long nrh, long ncl, long nch);
+int **imatrix(long nrl, long nrh, long ncl, long nch);
+double **submatrix(double **a, long oldrl, long oldrh, long oldcl, long oldch,
+	long newrl, long newcl);
+double **convert_matrix(double *a, long nrl, long nrh, long ncl, long nch);
+double ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
+void free_vector(double *v, long nl, long nh);
+void free_ivector(int *v, long nl, long nh);
+void free_cvector(unsigned char *v, long nl, long nh);
+void free_lvector(unsigned long *v, long nl, long nh);
+void free_dvector(double *v, long nl, long nh);
+void free_matrix(double **m, long nrl, long nrh, long ncl, long nch);
+void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
+void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
+void free_submatrix(double **b, long nrl, long nrh, long ncl, long nch);
+void free_convert_matrix(double **b, long nrl, long nrh, long ncl, long nch);
+void free_f3tensor(double ***t, long nrl, long nrh, long ncl, long nch,
+	long ndl, long ndh);
+
+#else /* ANSI */
+/* traditional - K&R */
+
+void nrerror();
+double *vector();
+double **matrix();
+double **submatrix();
+double **convert_matrix();
+double ***f3tensor();
+double *dvector();
+double **dmatrix();
+int *ivector();
+int **imatrix();
+unsigned char *cvector();
+unsigned long *lvector();
+void free_vector();
+void free_dvector();
+void free_ivector();
+void free_cvector();
+void free_lvector();
+void free_matrix();
+void free_submatrix();
+void free_convert_matrix();
+void free_dmatrix();
+void free_imatrix();
+void free_f3tensor();
+
+#endif /* ANSI */
+
+#endif /* _NR_UTILS_H_ */
Index: trunk/ArchTOIPipe/Processors/wienerdecor.cc
===================================================================
--- trunk/ArchTOIPipe/Processors/wienerdecor.cc	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/wienerdecor.cc	(revision 1944)
@@ -0,0 +1,80 @@
+#include "toimanager.h"
+#include "correl.h"
+#include "wienerdecor.h"
+extern "C" {
+#include "nrutil.h"
+}
+extern "C" void dtoeplz(double r[], double x[], double y[], int n);
+
+WienerDecorrelator::WienerDecorrelator(int n, int l) {
+  nsamples = n;
+  lcorr = l;
+}
+
+void WienerDecorrelator::init() {
+  declareInput("signal");
+  declareInput("probe");
+  declareOutput("signal");
+  name="WienerDecorrelator";
+  setNeededHistory(nsamples+lcorr+1);
+  lowExtra = lcorr;
+}
+
+void WienerDecorrelator::run() {
+  int snb = getMinIn();
+  int sne = getMaxIn();
+
+  //  cout << "Wiener " << snb << " - " << sne << endl;
+
+  CorrelEstimator corr(lcorr, nsamples), autocorr(lcorr, nsamples);
+
+  double* r = new double[2*lcorr];  // autocorr toeplitz matrix
+  double* w = new double[lcorr+1];  // filter
+  double* y = new double[lcorr+1];  // corr vector
+  double* window = new double[lcorr];
+  double* filter = w+1;
+  
+  int sn = snb;
+  int snstartcorr = -1;
+  
+  while (sn < sne) {
+    if (snstartcorr < 0 || 
+	(snstartcorr + nsamples < sn && sn+nsamples < sne)) {
+      // let's (re)compute the correlation
+      snstartcorr = sn;
+      corr.reset();
+      autocorr.reset();
+      for (int i=sn; i<sn+nsamples; i++) {
+	double sig = getData(0, i);
+	double prb = getData(1, i);
+	corr.push(i, sig, prb);
+	autocorr.push(i, prb);
+      }
+      // correlation is recomputed, let's recompute the wiener filter from wiener equations
+      for (int i=0; i<lcorr; i++) {
+	r[lcorr+i] = r[lcorr-i] = autocorr.correl(i);
+	y[i+1] = corr.correl(i);
+      }
+      dtoeplz(r,w,y,lcorr);
+      /*      cout << "Wiener filter : \n ";
+      for (int i=0; i<lcorr; i++) {
+	cout << filter[i] << " ";
+      }
+      cout << endl;*/
+    }
+
+    if (sn >= snb+lcorr-1) {
+      getData(1, sn-lcorr+1, lcorr, window);
+      double outSig = 0;
+      for (int i=0; i<lcorr; i++) {
+	outSig += filter[i] * window[lcorr-1 - i];
+      }
+      putData(0, sn, getData(0, sn) - outSig);
+    }
+    sn++;
+  }
+
+  delete[] y;
+  delete[] w;
+  delete[] r;
+}
Index: trunk/ArchTOIPipe/Processors/wienerdecor.h
===================================================================
--- trunk/ArchTOIPipe/Processors/wienerdecor.h	(revision 1944)
+++ trunk/ArchTOIPipe/Processors/wienerdecor.h	(revision 1944)
@@ -0,0 +1,32 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+// ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL
+//                               Eric Aubourg
+//                               Christophe Magneville
+//                               Reza Ansari
+// $Id: wienerdecor.h,v 1.1 2002-03-23 23:05:22 aubourg Exp $
+
+#ifndef WIENERDECOR_H
+#define WIENERDECOR_H
+
+#include "toiprocessor.h"
+#include "flagtoidef.h"
+
+class WienerDecorrelator : public TOIProcessor {
+public:
+  WienerDecorrelator(int nsamp, int lcor);
+
+  virtual void init();
+  virtual void run();
+
+  //  inline void doNotLookAt(uint_8 flag=FlgToiAll) {flgNotLookAt = flag;}
+
+protected:  
+  int nsamples;
+  int lcorr;
+  // uint_8 flgNotLookAt;
+};
+
+
+
+#endif
Index: trunk/ArchTOIPipe/TestPipes/tstnoisecancel.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/tstnoisecancel.cc	(revision 1944)
+++ trunk/ArchTOIPipe/TestPipes/tstnoisecancel.cc	(revision 1944)
@@ -0,0 +1,77 @@
+#include <math.h>
+#include "tstnoisecancel.h"
+#include "noisegen.h"
+#include "wienerdecor.h"
+#include "asciitoiwtr.h"
+#include "toimanager.h"
+#include "toisegment.h"
+
+TstNoiseCancel::TstNoiseCancel() {
+
+}
+
+void TstNoiseCancel::init() {
+  declareInput("noise");
+  declareOutput("signal");
+  declareOutput("probe");
+  declareOutput("theoric");
+}
+
+void TstNoiseCancel::run() {
+  int snb = getMinIn();
+  int sne = getMaxIn();
+
+  //cout << "TstNoiseCancel " << snb << " - " << sne << endl;
+
+  double v1=0;
+  double v2=0;
+  for (int i=snb; i<=sne; i++) {
+    double noise = getData(0, i);
+    v1 = 0.8*v1 + noise;
+    v2 = -0.6*v2 + noise;
+
+    double sig = sin(i * 0.05 * 3.1415926);
+
+    putData(0, i, sig+v1);
+    putData(1, i, v2);
+    putData(2, i, sig);
+  }
+
+  //cout << "tstnoisecancel done" << endl;
+}
+
+int main() {
+  TOIManager* mgr = TOIManager::getManager();
+  mgr->setRequestedSample(100,300);
+  
+  NoiseGenGauss gauss(1);
+  TstNoiseCancel correlnoise;
+  WienerDecorrelator wiener(200, 20);
+  ASCIITOIWriter wtr("noisecancel.out");
+
+  TOISegmented* toi = new TOISegmented("gaussnoise");
+  gauss.addOutput("noise", toi);
+  correlnoise.addInput("noise", toi);
+
+  toi = new TOISegmented("signal");
+  correlnoise.addOutput("signal" , toi);
+  wiener.addInput("signal", toi);
+  wtr.addInput("signal", toi);
+
+  toi = new TOISegmented("probe");
+  correlnoise.addOutput("probe", toi);
+  wiener.addInput("probe", toi);
+  wtr.addInput("probe", toi);
+
+  toi = new TOISegmented("filtered");
+  wiener.addOutput("signal", toi);
+  wtr.addInput("filtered", toi);
+
+  toi = new TOISegmented("theoric");
+  correlnoise.addOutput("theoric", toi);
+  wtr.addInput("theoric", toi);
+
+  gauss.start(); correlnoise.start(); wiener.start(); wtr.start();
+  
+  mgr->joinAll();
+}
Index: trunk/ArchTOIPipe/TestPipes/tstnoisecancel.h
===================================================================
--- trunk/ArchTOIPipe/TestPipes/tstnoisecancel.h	(revision 1944)
+++ trunk/ArchTOIPipe/TestPipes/tstnoisecancel.h	(revision 1944)
@@ -0,0 +1,23 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+// ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL
+//                               Eric Aubourg
+//                               Christophe Magneville
+//                               Reza Ansari
+// $Id: tstnoisecancel.h,v 1.1 2002-03-23 23:05:22 aubourg Exp $
+
+#ifndef TSTNOISECANCEL_H
+#define TSTNOISECANCEL_H
+
+#include "toiprocessor.h"
+
+class TstNoiseCancel : public TOIProcessor {
+public:
+  TstNoiseCancel();
+
+  virtual void init();
+  virtual void run();
+};
+
+#endif
+
Index: trunk/ArchTOIPipe/configure.in
===================================================================
--- trunk/ArchTOIPipe/configure.in	(revision 1860)
+++ trunk/ArchTOIPipe/configure.in	(revision 1944)
@@ -123,5 +123,5 @@
 AC_CHECK_HEADERS(values.h stdint.h)
 
-outfiles="Makefile kernel/Makefile processors/Makefile pipes/Makefile"
+outfiles="Makefile kernel/Makefile processors/Makefile pipes/Makefile Makefile.h"
 if [[ $use_sophya = 1 ]]; then
   outfiles="$outfiles sophya/Makefile"
Index: trunk/ArchTOIPipe/files_pipes
===================================================================
--- trunk/ArchTOIPipe/files_pipes	(revision 1860)
+++ trunk/ArchTOIPipe/files_pipes	(revision 1944)
@@ -17,2 +17,4 @@
 tsttoi2map.cc
 tstktoibad.cc
+tstnoisecancel.h
+tstnoisecancel.cc
Index: trunk/ArchTOIPipe/files_processors
===================================================================
--- trunk/ArchTOIPipe/files_processors	(revision 1860)
+++ trunk/ArchTOIPipe/files_processors	(revision 1944)
@@ -3,2 +3,11 @@
 nooppr.h
 nooppr.cc
+correl.cc
+correl.h
+nrutil.h
+nrutil.c
+dlubksb.c  
+dludcmp.c  
+dtoeplz.c
+wienerdecor.cc
+wienerdecor.h
