Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/Limiter.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2006 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 #ifndef MARSYAS_LIMITER_H
00020 #define MARSYAS_LIMITER_H
00021 
00022 #include <marsyas/system/MarSystem.h>
00023 
00024 namespace Marsyas
00025 {
00037 /* How to use the Limiter Marsystem
00038 
00039     The system can be setup using the marsystem manager
00040         series->addMarSystem(mng.create("Limiter", "limiter"));
00041 
00042     Options: Threshold can be set to any value between 0 and 1
00043     Limiter     0 <= thresh <= 1.0
00044         series->updctrl("Limiter/limiter/mrs_real/thresh", thresh);
00045 
00046     Attack time can be calculated using the following formula: at = 1 - exp(-2.2*T/t_AT)
00047     where at = attack time, T = sampling period, t_AT = time parameter 0.00016 < t_AT < 2.6 sec
00048         series->updctrl("Limiter/limiter/mrs_real/at", t_AT);
00049 
00050     Release time can be calculated similar to at time: rt = 1 - exp(-2.2*T/t_RT)
00051     where rt = rt time, T = sampling period, t_RT = time parameter 0.001 < t_RT < 5.0 msec
00052         series->updctrl("Limiter/limiter/mrs_real/rt", t_RT);
00053 
00054     Slope factor: 0 < slope <= 1.0
00055         series->updctrl("NoiseGate/noisegate/mrs_real/rt", slope);
00056 */
00057 
00058 
00059 class Limiter: public MarSystem
00060 {
00061 private:
00062   void addControls();
00063   void myUpdate(MarControlPtr sender);
00064 
00065   mrs_real xdprev_;
00066   realvec xd_;
00067   realvec gains_;
00068   mrs_real alpha_;
00069 
00070 public:
00071   Limiter(std::string name);
00072   ~Limiter();
00073   MarSystem* clone() const;
00074 
00075   void myProcess(realvec& in, realvec& out);
00076 };
00077 
00078 }//namespace Marsyas
00079 
00080 #endif