00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "SubtractMean.h"
00020
00021 using namespace std;
00022 using namespace Marsyas;
00023
00024 SubtractMean::SubtractMean(mrs_string name) :
00025 MarSystem("SubtractMean", name)
00026 {
00027
00028 }
00029
00030 SubtractMean::SubtractMean(const SubtractMean& a) :
00031 MarSystem(a)
00032 {
00033
00034 }
00035
00036 SubtractMean::~SubtractMean()
00037 {
00038 }
00039
00040 MarSystem*
00041 SubtractMean::clone() const
00042 {
00043 return new SubtractMean(*this);
00044 }
00045
00046 void SubtractMean::myUpdate(MarControlPtr sender)
00047 {
00048 MRSDIAG("SubtractMean.cpp - SubtractMean:myUpdate");
00049
00051 MarSystem::myUpdate(sender);
00052 }
00053
00054 void SubtractMean::myProcess(realvec& in, realvec& out)
00055 {
00056 mrs_natural t,o;
00057 mrs_real mean;
00059 for (o = 0; o < inObservations_; o++)
00060 {
00061
00062 mean = 0;
00063 for (t = 0; t < inSamples_; t++)
00064 {
00065 mean += in(o, t);
00066 }
00067 mean /= inSamples_;
00068
00069 for (t = 0; t < inSamples_; t++)
00070 {
00071 out(o, t) = in(o, t) - mean;
00072 }
00073 }
00074 }