Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/Panorama.cpp
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2007 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 
00020 #include "Panorama.h"
00021 
00022 using std::ostringstream;
00023 using namespace Marsyas;
00024 
00025 Panorama::Panorama(mrs_string name):MarSystem("Panorama", name)
00026 {
00027   addControls();
00028 }
00029 
00030 Panorama::Panorama(const Panorama& a) : MarSystem(a)
00031 {
00032   ctrl_angle_ = getctrl("mrs_real/angle");
00033 }
00034 
00035 Panorama::~Panorama()
00036 {
00037 }
00038 
00039 MarSystem*
00040 Panorama::clone() const
00041 {
00042   return new Panorama(*this);
00043 }
00044 
00045 void
00046 Panorama::addControls()
00047 {
00048   addctrl("mrs_real/angle", PI/4, ctrl_angle_);
00049 }
00050 
00051 void
00052 Panorama::myUpdate(MarControlPtr sender)
00053 {
00054   (void) sender;  //suppress warning of unused parameter(s)
00055   setctrl("mrs_natural/onSamples", getctrl("mrs_natural/onSamples"));
00056 
00057   mrs_natural inObservations = getctrl("mrs_natural/inObservations")->to<mrs_natural>();
00058 
00059   if (inObservations == 1)
00060   {
00061     setctrl("mrs_natural/onObservations", 2);
00062     mrs_string inObsNames = getctrl("mrs_string/inObsNames")->to<mrs_string>();
00063     inObsNames += ",";
00064     inObsNames += inObsNames;
00065     setctrl("mrs_string/onObsNames", inObsNames);
00066   }
00067   else
00068   {
00069     setctrl("mrs_natural/onObservations", inObservations);
00070     setctrl("mrs_string/onObsNames", getctrl("mrs_string/inObsNames"));
00071   }
00072   setctrl("mrs_real/osrate", getctrl("mrs_real/israte"));
00073 }
00074 
00075 
00076 void
00077 Panorama::myProcess(realvec& in, realvec& out)
00078 {
00079   mrs_natural t,o;
00080   mrs_real angle = ctrl_angle_->to<mrs_real>();
00081   mrs_real gl = cos(angle) - sin(angle);
00082   mrs_real gr = sin(angle) + cos(angle);
00083 
00084   if (inObservations_ == 1)     // mono2stereo
00085   {
00086     for (t = 0; t < inSamples_; t++)
00087     {
00088       out(0,t) =  gl * in(0,t);     // left
00089       out(1,t) =  gr * in(0,t);    // right
00090     }
00091   }
00092 
00093   else // pass through
00094   {
00095     for (o=0; o < onObservations_; o++)
00096       for (t = 0; t < inSamples_; t++)
00097       {
00098         out(o,t) = in(0,t);
00099       }
00100   }
00101 
00102 
00103 }
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111