Marsyas
0.6.0-alpha
|
00001 /* 00002 * Delta.cpp 00003 * testDelta 00004 * 00005 * Created by tsunoo on 09/05/07. 00006 * Copyright 2009 Emiru Tsunoo. All rights reserved. 00007 * 00008 */ 00009 00010 #include "Delta.h" 00011 00012 using std::ostringstream; 00013 using namespace Marsyas; 00014 00015 Delta::Delta(mrs_string name): MarSystem("Delta", name) 00016 { 00017 } 00018 00019 Delta::Delta(const Delta& a): MarSystem(a) 00020 { 00021 } 00022 00023 MarSystem* 00024 Delta::clone() const 00025 { 00026 return new Delta(*this); 00027 } 00028 00029 void 00030 Delta::myUpdate(MarControlPtr) 00031 { 00032 ctrl_onObservations_->setValue(inObservations_, NOUPDATE); 00033 ctrl_onSamples_->setValue(inSamples_, NOUPDATE); 00034 ctrl_osrate_->setValue(israte_, NOUPDATE); 00035 m_memory.create(inObservations_, 1); 00036 } 00037 00038 void 00039 Delta::myProcess(realvec& in, realvec& out) 00040 { 00041 if (!inSamples_) 00042 return; 00043 00044 mrs_natural last_sample = onSamples_ - 1; 00045 00046 for(mrs_natural o = 0; o < onObservations_; o++) 00047 { 00048 out(o, 0) = in(o, 0) - m_memory(o); 00049 } 00050 00051 for(mrs_natural s = 1; s < onSamples_; ++s) 00052 { 00053 for(mrs_natural o=0; o < onObservations_; o++) 00054 { 00055 out(o, s) = in(o, s) - in(o, s-1); 00056 } 00057 } 00058 00059 for(mrs_natural o=0; o < onObservations_; o++) 00060 { 00061 m_memory(o) = in(o, last_sample); 00062 } 00063 } 00064