00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "MaxMin.h"
00021 using std::ostringstream;
00022 using namespace Marsyas;
00023
00024 MaxMin::MaxMin(mrs_string name): MarSystem("MaxMin",name)
00025 {
00026 }
00027
00028 MaxMin::~MaxMin()
00029 {
00030 }
00031
00032 MarSystem*
00033 MaxMin::clone() const
00034 {
00035 return new MaxMin(*this);
00036 }
00037
00038 void
00039 MaxMin::myUpdate(MarControlPtr sender)
00040 {
00041
00042
00043 MarSystem::myUpdate(sender);
00044
00045
00046 setControl("mrs_natural/onSamples", (mrs_natural)2);
00047 setControl("mrs_real/osrate",
00048 getControl("mrs_real/israte")->to<mrs_real>() / getControl("mrs_natural/inSamples")->to<mrs_natural>()
00049 );
00050 }
00051
00052 void
00053 MaxMin::myProcess(realvec& in, realvec& out)
00054 {
00055 mrs_natural t,o;
00056 for (o=0; o < inObservations_; o++)
00057 {
00058 max_ = -1.0 * DBL_MAX;
00059 min_ = DBL_MAX;
00060 for (t=0; t < inSamples_; t++)
00061 {
00062 if (in(o,t) > max_)
00063 {
00064 max_ = in(o,t);
00065 }
00066 if (in(o,t) < min_)
00067 {
00068 min_ = in(o,t);
00069 }
00070 }
00071 out(o,0) = max_;
00072 out(o,1) = min_;
00073 }
00074 }