00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "RealvecSource.h"
00020
00021 using namespace std;
00022 using namespace Marsyas;
00023
00024 RealvecSource::RealvecSource(mrs_string name):MarSystem("RealvecSource",name)
00025 {
00026 count_= 0;
00027 addControls();
00028 }
00029
00030 RealvecSource::RealvecSource(const RealvecSource& a):MarSystem(a)
00031 {
00032 count_ = 0;
00033 ctrl_data_ = getctrl("mrs_realvec/data");
00034 }
00035
00036
00037 RealvecSource::~RealvecSource()
00038 {
00039 }
00040
00041
00042 MarSystem*
00043 RealvecSource::clone() const
00044 {
00045 return new RealvecSource(*this);
00046 }
00047
00048 void
00049 RealvecSource::addControls()
00050 {
00051 samplesToUse_ = (mrs_natural)MRS_DEFAULT_SLICE_NSAMPLES;
00052 addctrl("mrs_bool/done", false);
00053 setctrlState("mrs_bool/done", true);
00054 addctrl("mrs_realvec/data", realvec(), ctrl_data_);
00055 setctrlState("mrs_realvec/data", true);
00056 setctrlState("mrs_real/israte", true);
00057 }
00058
00059
00060 void
00061 RealvecSource::myUpdate(MarControlPtr sender)
00062 {
00063 (void)sender;
00064 MRSDIAG("RealvecSource.cpp - RealvecSource:myUpdate");
00065
00066 inSamples_ = getctrl("mrs_natural/inSamples")->to<mrs_natural>();
00067 inObservations_ = getctrl("mrs_natural/inObservations")->to<mrs_natural>();
00068 israte_ = getctrl("mrs_real/israte")->to<mrs_real>();
00069
00070 const realvec& data = ctrl_data_->to<realvec> ();
00071
00072 setctrl("mrs_natural/onObservations", data.getRows());
00073 setctrl("mrs_natural/onSamples", inSamples_);
00074 setctrl("mrs_real/osrate", israte_);
00075 samplesToUse_ = data.getCols();
00076
00077 count_ = 0;
00078
00079 if( getctrl("mrs_bool/done")->isTrue()){
00080 setctrl("mrs_bool/done", false);
00081 }
00082 }
00083
00084 void
00085 RealvecSource::myProcess(realvec& in, realvec& out)
00086 {
00087 mrs_natural o,t;
00088 (void) in;
00089
00090 const realvec& data = ctrl_data_->to<realvec> ();
00091
00092 if( count_ < samplesToUse_)
00093 {
00094 for (o=0; o < onObservations_; o++)
00095 {
00096 for (t=0; t < onSamples_; t++)
00097 {
00098 out(o,t) = data(o,count_ + t);
00099 }
00100 }
00101 count_ += onSamples_;
00102 }
00103 else
00104 setctrl("mrs_bool/done", true);
00105
00106 if (count_ >= samplesToUse_)
00107 {
00108 setctrl("mrs_bool/done", true);
00109 }
00110
00111
00112 }