00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "DeInterleaveSizecontrol.h"
00020
00021 using std::ostringstream;
00022 using namespace Marsyas;
00023
00024 DeInterleaveSizecontrol::DeInterleaveSizecontrol(mrs_string name):MarSystem("DeInterleaveSizecontrol", name)
00025 {
00026
00027
00028
00029
00030
00031
00032
00033 addControls();
00034 }
00035
00036 DeInterleaveSizecontrol::DeInterleaveSizecontrol(const DeInterleaveSizecontrol& a) : MarSystem(a)
00037 {
00038
00039
00040
00041 ctrl_numSets_ = getctrl("mrs_natural/numSets");
00042 ctrl_sizes_ = getctrl("mrs_realvec/sizes");
00043 }
00044
00045 DeInterleaveSizecontrol::~DeInterleaveSizecontrol()
00046 {
00047 }
00048
00049 MarSystem*
00050 DeInterleaveSizecontrol::clone() const
00051 {
00052 return new DeInterleaveSizecontrol(*this);
00053 }
00054
00055 void
00056 DeInterleaveSizecontrol::addControls()
00057 {
00058
00059 addctrl("mrs_natural/numSets", 1, ctrl_numSets_);
00060 addctrl("mrs_realvec/sizes",realvec() , ctrl_sizes_);
00061 }
00062
00063 void
00064 DeInterleaveSizecontrol::myUpdate(MarControlPtr sender)
00065 {
00066 MarSystem::myUpdate(sender);
00067 }
00068
00069
00070 void
00071 DeInterleaveSizecontrol::myProcess(realvec& in, realvec& out)
00072 {
00073 mrs_natural o,t;
00074 for (o=0; o < inSamples_; o++)
00075 {
00076 mrs_natural size=(mrs_natural)(ctrl_sizes_->to<mrs_realvec>()(o));
00077 if (size<=0) size=onSamples_;
00078 mrs_natural rest=size%ctrl_numSets_->to<mrs_natural>();
00079 mrs_natural part=size/ctrl_numSets_->to<mrs_natural>();
00080 mrs_natural count=0;
00081 for(int i=0;i<onObservations_/size;++i)
00082 {
00083 for (t = 0; t < rest; t++)
00084 {
00085 for (mrs_natural n = 0; n <1+part ; n++)
00086 {
00087
00088
00089 mrs_natural outindex=i*size+n+part*t;
00090 mrs_natural inindex=i*size+ctrl_numSets_->to<mrs_natural>()*n+t;
00091 out(outindex,o) = in(inindex,o);
00092 count++;
00093 }
00094 }
00095 for (t = rest; t < ctrl_numSets_->to<mrs_natural>(); t++)
00096 {
00097 for (mrs_natural n = 0; n < part; n++)
00098 {
00099
00100 mrs_natural outindex=i*size+n+rest+part*t;
00101 mrs_natural inindex=i*size+ctrl_numSets_->to<mrs_natural>()*n+t;
00102 out(outindex,o) = in(inindex,o);
00103 count++;
00104 }
00105 }
00106 }
00107 }
00108 }
00109
00110
00111
00112
00113
00114
00115
00116