Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2010 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #include "ShiftOutput.h" 00020 #include <algorithm> 00021 00022 using namespace std; 00023 using namespace Marsyas; 00024 00025 ShiftOutput::ShiftOutput(mrs_string name):MarSystem("ShiftOutput",name) 00026 { 00027 addControls(); 00028 } 00029 00030 ShiftOutput::ShiftOutput(const ShiftOutput& a):MarSystem(a) 00031 { 00032 ctrl_Interpolation_ = getctrl("mrs_natural/Interpolation"); 00033 } 00034 00035 ShiftOutput::~ShiftOutput() 00036 { 00037 } 00038 00039 MarSystem* 00040 ShiftOutput::clone() const 00041 { 00042 return new ShiftOutput(*this); 00043 } 00044 00045 void 00046 ShiftOutput::addControls() 00047 { 00048 addctrl("mrs_natural/Interpolation", (mrs_natural)MRS_DEFAULT_SLICE_NSAMPLES / 2, ctrl_Interpolation_); 00049 setctrlState("mrs_natural/Interpolation", true); 00050 } 00051 00052 void 00053 ShiftOutput::myUpdate(MarControlPtr sender) 00054 { 00055 (void) sender; //suppress warning of unused parameter(s) 00056 00057 interp_ = ctrl_Interpolation_->to<mrs_natural>(); 00058 00059 ctrl_onSamples_->setValue(ctrl_Interpolation_, NOUPDATE); 00060 ctrl_onObservations_->setValue(ctrl_inObservations_, NOUPDATE); 00061 ctrl_osrate_->setValue(ctrl_israte_, NOUPDATE); 00062 ctrl_onObsNames_->setValue(ctrl_inObsNames_, NOUPDATE); 00063 } 00064 00065 void 00066 ShiftOutput::myProcess(realvec& in, realvec& out) 00067 { 00068 mrs_natural t,o; 00069 00070 if(interp_ > inSamples_) 00071 out.setval(0.0); 00072 00073 for(o=0; o< inObservations_; ++o) 00074 for (t = 0; t < min(inSamples_,interp_); t++) 00075 out(o,t) = in(o,t); 00076 } 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086