source: Sophya/trunk/ArchTOIPipe/TestPipes/tstnoisecancel.cc@ 1944

Last change on this file since 1944 was 1944, checked in by aubourg, 24 years ago

decorrelateur wiener

File size: 1.7 KB
Line 
1#include <math.h>
2#include "tstnoisecancel.h"
3#include "noisegen.h"
4#include "wienerdecor.h"
5#include "asciitoiwtr.h"
6#include "toimanager.h"
7#include "toisegment.h"
8
9TstNoiseCancel::TstNoiseCancel() {
10
11}
12
13void TstNoiseCancel::init() {
14 declareInput("noise");
15 declareOutput("signal");
16 declareOutput("probe");
17 declareOutput("theoric");
18}
19
20void TstNoiseCancel::run() {
21 int snb = getMinIn();
22 int sne = getMaxIn();
23
24 //cout << "TstNoiseCancel " << snb << " - " << sne << endl;
25
26 double v1=0;
27 double v2=0;
28 for (int i=snb; i<=sne; i++) {
29 double noise = getData(0, i);
30 v1 = 0.8*v1 + noise;
31 v2 = -0.6*v2 + noise;
32
33 double sig = sin(i * 0.05 * 3.1415926);
34
35 putData(0, i, sig+v1);
36 putData(1, i, v2);
37 putData(2, i, sig);
38 }
39
40 //cout << "tstnoisecancel done" << endl;
41}
42
43int main() {
44 TOIManager* mgr = TOIManager::getManager();
45 mgr->setRequestedSample(100,300);
46
47 NoiseGenGauss gauss(1);
48 TstNoiseCancel correlnoise;
49 WienerDecorrelator wiener(200, 20);
50 ASCIITOIWriter wtr("noisecancel.out");
51
52 TOISegmented* toi = new TOISegmented("gaussnoise");
53 gauss.addOutput("noise", toi);
54 correlnoise.addInput("noise", toi);
55
56 toi = new TOISegmented("signal");
57 correlnoise.addOutput("signal" , toi);
58 wiener.addInput("signal", toi);
59 wtr.addInput("signal", toi);
60
61 toi = new TOISegmented("probe");
62 correlnoise.addOutput("probe", toi);
63 wiener.addInput("probe", toi);
64 wtr.addInput("probe", toi);
65
66 toi = new TOISegmented("filtered");
67 wiener.addOutput("signal", toi);
68 wtr.addInput("filtered", toi);
69
70 toi = new TOISegmented("theoric");
71 correlnoise.addOutput("theoric", toi);
72 wtr.addInput("theoric", toi);
73
74 gauss.start(); correlnoise.start(); wiener.start(); wtr.start();
75
76 mgr->joinAll();
77}
Note: See TracBrowser for help on using the repository browser.