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