00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "Deinterleave.h"
00020
00021 using std::ostringstream;
00022 using namespace Marsyas;
00023
00024 Deinterleave::Deinterleave(mrs_string name):MarSystem("Deinterleave", name)
00025 {
00026
00027 pat_ = new PatchMatrix("pat");
00028
00029 outindex_.stretch(inObservations_);
00030 inindex_.stretch(inObservations_);
00031 weights_.stretch(inObservations_,inObservations_);
00032
00033 addControls();
00034 }
00035
00036 Deinterleave::Deinterleave(const Deinterleave& a) : MarSystem(a)
00037 {
00038
00039
00040
00041 ctrl_numSets_ = getctrl("mrs_natural/numSets");
00042
00043 pat_ = new PatchMatrix("pat");
00044
00045 outindex_.stretch(inObservations_);
00046 inindex_.stretch(inObservations_);
00047 weights_.stretch(inObservations_,inObservations_);
00048 }
00049
00050 Deinterleave::~Deinterleave()
00051 {
00052 delete pat_;
00053 }
00054
00055 MarSystem*
00056 Deinterleave::clone() const
00057 {
00058 return new Deinterleave(*this);
00059 }
00060
00061 void
00062 Deinterleave::addControls()
00063 {
00064
00065 addctrl("mrs_natural/numSets", 2, ctrl_numSets_);
00066
00067 setControlState("mrs_natural/numSets",true);
00068 }
00069
00070 void
00071 Deinterleave::myUpdate(MarControlPtr sender)
00072 {
00073
00074 MarSystem::myUpdate(sender);
00075
00076 mrs_natural numSets = ctrl_numSets_->to<mrs_natural>();
00077
00078 outindex_.stretch(inObservations_);
00079 inindex_.stretch(inObservations_);
00080 weights_.stretch(inObservations_,inObservations_);
00081
00082
00083 mrs_natural rest=inObservations_%numSets;
00084 mrs_natural part=inObservations_/numSets;
00085 mrs_natural count=0;
00086
00087 for (mrs_natural t = 0; t < rest; t++)
00088 {
00089 for (mrs_natural n = 0; n <1+part ; n++)
00090 {
00091
00092 outindex_(count)=n+part*t;
00093 inindex_(count)=numSets*n+t;
00094 count++;
00095 }
00096 }
00097 for (mrs_natural t = rest; t < numSets; t++)
00098 {
00099 for (mrs_natural n = 0; n < part; n++)
00100 {
00101
00102 outindex_(count)=n+rest+part*t;
00103 inindex_(count)=numSets*n+t;
00104 count++;
00105 }
00106 }
00107
00108
00109 for(mrs_natural i=0;i<inindex_.getSize();++i)
00110 {
00111 weights_((mrs_natural)(outindex_(i)),(mrs_natural)(inindex_(i)))=1.0;
00112 }
00113
00114 pat_->setctrl("mrs_realvec/weights",weights_);
00115
00116
00117 }
00118
00119
00120 void
00121 Deinterleave::myProcess(realvec& in, realvec& out)
00122 {
00123
00124
00125 pat_->process(in,out);
00126
00127 }
00128
00129
00130
00131
00132
00133
00134
00135