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 "MarSystem.h" 00023 00024 namespace Marsyas 00025 { 00043 /* How to use the Limiter Marsystem 00044 00045 The system can be setup using the marsystem manager 00046 series->addMarSystem(mng.create("Limiter", "limiter")); 00047 00048 Options: Threshold can be set to any value between 0 and 1 00049 Limiter 0 <= thresh <= 1.0 00050 series->updctrl("Limiter/limiter/mrs_real/thresh", thresh); 00051 00052 Attack time can be calculated using the following formula: at = 1 - exp(-2.2*T/t_AT) 00053 where at = attack time, T = sampling period, t_AT = time parameter 0.00016 < t_AT < 2.6 sec 00054 series->updctrl("Limiter/limiter/mrs_real/at", t_AT); 00055 00056 Release time can be calculated similar to at time: rt = 1 - exp(-2.2*T/t_RT) 00057 where rt = rt time, T = sampling period, t_RT = time parameter 0.001 < t_RT < 5.0 msec 00058 series->updctrl("Limiter/limiter/mrs_real/rt", t_RT); 00059 00060 Slope factor: 0 < slope <= 1.0 00061 series->updctrl("NoiseGate/noisegate/mrs_real/rt", slope); 00062 */ 00063 00064 00065 class Limiter: public MarSystem 00066 { 00067 private: 00068 void addControls(); 00069 void myUpdate(MarControlPtr sender); 00070 00071 mrs_real xdprev_; 00072 realvec xd_; 00073 realvec gains_; 00074 mrs_real alpha_; 00075 00076 public: 00077 Limiter(std::string name); 00078 ~Limiter(); 00079 MarSystem* clone() const; 00080 00081 void myProcess(realvec& in, realvec& out); 00082 }; 00083 00084 }//namespace Marsyas 00085 00086 #endif
1.5.6