00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "OverlapAdd.h"
00020
00021
00022 using std::ostringstream;
00023 using std::max;
00024
00025 using namespace Marsyas;
00026
00027 OverlapAdd::OverlapAdd(mrs_string name):MarSystem("OverlapAdd",name)
00028 {
00029 this->addControls ();
00030 }
00031
00032 OverlapAdd::~OverlapAdd()
00033 {
00034 }
00035
00036 void
00037 OverlapAdd::addControls()
00038 {
00039 addctrl("mrs_natural/ratioBlock2Hop", 2);
00040 }
00041
00042 MarSystem*
00043 OverlapAdd::clone() const
00044 {
00045 return new OverlapAdd(*this);
00046 }
00047
00048 void
00049 OverlapAdd::myUpdate(MarControlPtr sender)
00050 {
00051 (void) sender;
00052 mrs_natural ratio = max((mrs_natural)1,getctrl("mrs_natural/ratioBlock2Hop")->to<mrs_natural>());
00053 setctrl("mrs_natural/onSamples", ctrl_inSamples_->to<mrs_natural>()/ratio);
00054 setctrl("mrs_natural/onObservations", ctrl_inObservations_->to<mrs_natural>());
00055 setctrl("mrs_real/osrate", getctrl("mrs_real/israte")->to<mrs_real>());
00056
00057 back_.stretch(ctrl_onObservations_->to<mrs_natural>(), ctrl_inSamples_->to<mrs_natural>()-ctrl_onSamples_->to<mrs_natural>());
00058 }
00059
00060 void
00061 OverlapAdd::myProcess(realvec& in, realvec& out)
00062 {
00063 mrs_natural t,o;
00064 for(o=0 ; o<onObservations_; o++)
00065 {
00066
00067 for(t=0;t<onSamples_;t++)
00068 out(o, t) = back_(o, t)+in(o, t);
00069
00070
00071
00072
00073
00074
00075 for (t = onSamples_; t < inSamples_ - onSamples_; t++)
00076 back_(o,t-onSamples_) = back_(o,t) + in(o,t);
00077
00078
00079 for (t = inSamples_-onSamples_; t < inSamples_; t++)
00080 back_(o,t-onSamples_) = in(o,t);
00081 }
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095