Marsyas
0.6.0-alpha
|
00001 #include "Threshold.h" 00002 00003 namespace Marsyas { 00004 00005 Threshold::Threshold(const string & name): 00006 MarSystem("Threshold", name) 00007 { 00008 addControl("mrs_real/value", 0.0); 00009 setControlState("mrs_real/value", true); 00010 } 00011 00012 Threshold::Threshold(const Threshold & other): 00013 MarSystem(other) 00014 { 00015 } 00016 00017 void Threshold::myUpdate( MarControlPtr ) 00018 { 00019 m_threshold = getControl("mrs_real/value")->to<mrs_real>(); 00020 00021 ctrl_onObservations_->setValue(1, NOUPDATE); 00022 ctrl_onSamples_->setValue(inSamples_, NOUPDATE); 00023 ctrl_osrate_->setValue(israte_, NOUPDATE); 00024 } 00025 00026 void Threshold::myProcess( realvec & in, realvec & out ) 00027 { 00028 if (!inSamples_ || !inObservations_) 00029 return; 00030 00031 for(mrs_natural s = 0; s < inSamples_; ++s) 00032 { 00033 mrs_natural sum = 0; 00034 for(mrs_natural o=0; o < inObservations_; o++) 00035 { 00036 if (in(o,s) > m_threshold) 00037 ++sum; 00038 } 00039 out(0,s) = sum; 00040 } 00041 } 00042 00043 }