00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "common.h"
00020 #include "RemoveObservations.h"
00021
00022 using std::ostringstream;
00023 using namespace Marsyas;
00024
00025 RemoveObservations::RemoveObservations(mrs_string name) : MarSystem("RemoveObservations", name)
00026 {
00028 addControls();
00029 lowestObs_ = 0;
00030 numObs_ = inObservations_;
00031 }
00032
00033 RemoveObservations::RemoveObservations(const RemoveObservations& a) : MarSystem(a)
00034 {
00035 lowestObs_ = 0;
00036 numObs_ = inObservations_;
00037 }
00038
00039
00040 RemoveObservations::~RemoveObservations()
00041 {
00042 }
00043
00044 MarSystem*
00045 RemoveObservations::clone() const
00046 {
00047 return new RemoveObservations(*this);
00048 }
00049
00050 void
00051 RemoveObservations::addControls()
00052 {
00054
00055 addctrl("mrs_real/lowCutoff", 0.0);
00056 addctrl("mrs_real/highCutoff", 1.0);
00057
00058 }
00059
00060 void
00061 RemoveObservations::myUpdate(MarControlPtr sender)
00062 {
00063 MRSDIAG("RemoveObservations.cpp - RemoveObservations:myUpdate");
00064
00065 MarSystem::myUpdate(sender);
00066
00067
00068 lowestObs_ = inObservations_
00069 * getctrl("mrs_real/lowCutoff")->to<mrs_real>();
00070
00071 numObs_ = ceil( inObservations_
00072 * getctrl("mrs_real/highCutoff")->to<mrs_real>()
00073 ) - lowestObs_;
00074
00075 ctrl_onObservations_->setValue(numObs_, NOUPDATE);
00076
00077
00078
00079
00080 mrs_string names = ctrl_inObsNames_->to<mrs_string>();
00081 int lowNamePos = 0;
00082 int highNamePos = 0;
00083 for (int i=0; i < lowestObs_; i++) {
00084 lowNamePos = names.find(",", lowNamePos) + 1;
00085 }
00086 for (int i=0; i < numObs_; i++) {
00087 highNamePos = names.find(",", highNamePos) + 1;
00088 }
00089 if (highNamePos > 0) {
00090 names = names.substr(lowNamePos, highNamePos);
00091 ctrl_onObsNames_->setValue(names, NOUPDATE);
00092 }
00093 }
00094
00095 void
00096 RemoveObservations::myProcess(realvec& in, realvec& out)
00097 {
00098 mrs_natural t,o;
00099
00101 for (o = 0; o < numObs_; o++)
00102 {
00103 for (t = 0; t < inSamples_; t++)
00104 {
00105 out(o, t) = in(o+lowestObs_, t);
00106 }
00107 }
00108 }