00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "common.h"
00020 #include "ADRessStereoSpectrum.h"
00021
00022
00023 using std::ostringstream;
00024 using namespace Marsyas;
00025
00026 ADRessStereoSpectrum::ADRessStereoSpectrum(mrs_string name):MarSystem("ADRessStereoSpectrum", name)
00027 {
00028 addControls();
00029 }
00030
00031 ADRessStereoSpectrum::ADRessStereoSpectrum(const ADRessStereoSpectrum& a) : MarSystem(a)
00032 {
00033
00034 }
00035
00036 ADRessStereoSpectrum::~ADRessStereoSpectrum()
00037 {
00038 }
00039
00040 MarSystem*
00041 ADRessStereoSpectrum::clone() const
00042 {
00043 return new ADRessStereoSpectrum(*this);
00044 }
00045
00046 void
00047 ADRessStereoSpectrum::addControls()
00048 {
00049 }
00050
00051 void
00052 ADRessStereoSpectrum::myUpdate(MarControlPtr sender)
00053 {
00054 MRSDIAG("ADRessStereoSpectrum.cpp - ADRessStereoSpectrum:myUpdate");
00055
00056 (void) sender;
00057
00058 N2_ = ctrl_inObservations_->to<mrs_natural>()/2;
00059
00060 ctrl_onSamples_->setValue(1, NOUPDATE);
00061 ctrl_onObservations_->setValue(N2_, NOUPDATE);
00062 ctrl_osrate_->setValue(ctrl_israte_, NOUPDATE);
00063
00064 ostringstream oss;
00065 for (mrs_natural n=0; n < N2_; n++)
00066 oss << "ADRess_stereobin_" << n << ",";
00067 ctrl_onObsNames_->setValue(oss.str(), NOUPDATE);
00068
00069 beta_ = ctrl_inSamples_->to<mrs_natural>()-2;
00070 }
00071
00072 void
00073 ADRessStereoSpectrum::myProcess(realvec& in, realvec& out)
00074 {
00075 mrs_natural o,t;
00076 for(o=0; o < N2_; ++o)
00077 {
00078
00079
00080 maxVal_ = 0.0;
00081 maxIndex_ = beta_;
00082 for(t=0;t<=beta_; ++t)
00083 {
00084 if(in(o,t+1) > maxVal_)
00085 {
00086 maxVal_ = in(o,t+1);
00087 maxIndex_ = t;
00088 }
00089 if(in(N2_+o, t+1) > maxVal_)
00090 {
00091 maxVal_ = in(N2_+o,t+1);
00092 maxIndex_ = beta_*2+1-t;
00093 }
00094 }
00095
00096
00097 if(maxIndex_ > beta_)
00098 maxIndex_--;
00099
00100
00101
00102 out(o,0) = (mrs_real)maxIndex_/(beta_*2.0)*2.0 - 1.0;
00103 }
00104
00105
00106
00107 }