00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "Shifter.h"
00020
00021 using namespace std;
00022 using namespace Marsyas;
00023
00024 Shifter::Shifter(mrs_string name):MarSystem("Shifter", name)
00025 {
00026 addControls();
00027 }
00028
00029
00030 Shifter::~Shifter()
00031 {
00032 }
00033
00034 MarSystem*
00035 Shifter::clone() const
00036 {
00037 return new Shifter(*this);
00038 }
00039
00040 void
00041 Shifter::addControls()
00042 {
00043 addctrl("mrs_natural/shift", 0);
00044 setctrlState("mrs_natural/shift", true);
00045 }
00046
00047 void
00048 Shifter::myUpdate(MarControlPtr sender)
00049 {
00050 (void) sender;
00051 MRSDIAG("Shifter.cpp - Shifter:myUpdate");
00052
00053 shift_ = getctrl("mrs_natural/shift")->to<mrs_natural>();
00054
00055 mrs_natural onsamples = getctrl("mrs_natural/inSamples")->to<mrs_natural>()- shift_;
00056
00057 if(onsamples < 0)
00058 onsamples = inSamples_;
00059
00060 setctrl("mrs_natural/onSamples", onsamples);
00061 setctrl("mrs_natural/onObservations", getctrl("mrs_natural/inObservations")->to<mrs_natural>()*2);
00062 setctrl("mrs_real/osrate", getctrl("mrs_real/israte"));
00063 setctrl("mrs_string/onObsNames", getctrl("mrs_string/inObsNames"));
00064 }
00065
00066 void
00067 Shifter::myProcess(realvec& in, realvec& out)
00068 {
00069 mrs_natural t,o;
00070 int delta = 0;
00071 for (o=0; o < onObservations_; o++)
00072 {
00073 for (t = 0; t < onSamples_; t++)
00074 {
00075 out(o,t) = in(0,t+delta);
00076 }
00077 delta +=shift_;
00078 }
00079
00080
00081
00082
00083 }