Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/Clip.cpp
Go to the documentation of this file.
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 "Clip.h"
00020 
00021 using std::ostringstream;
00022 using namespace Marsyas;
00023 
00024 Clip::Clip(mrs_string name):MarSystem("Clip",name)
00025 {
00026   addControls();
00027 }
00028 
00029 
00030 Clip::~Clip()
00031 {
00032 }
00033 
00034 
00035 Clip::Clip(const Clip& a) : MarSystem(a)
00036 {
00037   ctrl_range_ = getctrl("mrs_real/range");
00038 }
00039 
00040 
00041 
00042 
00043 MarSystem*
00044 Clip::clone() const
00045 {
00046   return new Clip(*this);
00047 }
00048 
00049 void
00050 Clip::addControls()
00051 {
00052   //Add specific controls needed by this MarSystem.
00053   addctrl("mrs_real/range", 1.0, ctrl_range_);
00054 }
00055 
00056 
00057 void
00058 Clip::myUpdate(MarControlPtr sender)
00059 {
00060   MarSystem::myUpdate(sender);
00061 }
00062 
00063 void
00064 Clip::myProcess(realvec& in, realvec& out)
00065 {
00066   mrs_natural o,t;
00067   mrs_real range = ctrl_range_->to<mrs_real>();
00068 
00069   for (o=0; o < inObservations_; o++)
00070   {
00071     for (t = 0; t < inSamples_; t++)
00072     {
00073       if (in(o,t) > range)
00074         out(o,t) = range;
00075       else if (in(o,t) < -range)
00076         out(o,t) = -range;
00077       else
00078         out(o,t) = in(o,t);
00079 
00080     }
00081   }
00082 }
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092