Marsyas
0.6.0-alpha
|
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_NOISEGATE_H 00020 #define MARSYAS_NOISEGATE_H 00021 00022 #include <marsyas/system/MarSystem.h> 00023 00024 namespace Marsyas 00025 { 00038 /* How to use the Limiter Marsystem 00039 00040 The system can be setup using the marsystem manager 00041 series->addMarSystem(mng.create("Noisegate", "noisegate")); 00042 00043 Options: Threshold can be set to any value between 0 and 1 00044 0 <= thresh <= 1.0 00045 series->updctrl("NoiseGate/noisegate/mrs_real/thresh", thresh); 00046 00047 Release threshold is the value where the gate is in the on possition. This value is usually 00048 higher than the Threshold value. 00049 0 <= release <= 1.0 00050 series->updctrl("NoiseGate/noisegate/mrs_real/release", release); 00051 00052 Rolloff time is the length of time desired for rolloff into noise gate. This feature allows 00053 for a smooth transition between the gate being on and the off: 00054 rolloff = 1 - exp(-2.2*T/t_rolloff) 00055 where rolloff = rolloff time, T = sampling period, t_rolloff = time parameter 0.001 < t_rolloff < 1 sec 00056 series->updctrl("NoiseGate/noisegate/mrs_real/at", t_rolloff); 00057 00058 Attack time can be calculated using the following formula: at = 1 - exp(-2.2*T/t_AT) 00059 where at = attack time, T = sampling period, t_AT = time parameter 0.00016 < t_AT < 2.6 sec 00060 series->updctrl("NoiseGate/noisegate/mrs_real/at", t_AT); 00061 00062 Release time can be calculated similar to attack time: rt = 1 - exp(-2.2*T/t_RT) 00063 where rt = release time, T = sampling period, t_RT = time parameter 0.001 < t_RT < 5.0 msec 00064 series->updctrl("NoiseGate/noisegate/mrs_real/rt", t_RT); 00065 00066 Slope factor: 0 < slope <= 1.0 00067 series->updctrl("NoiseGate/noisegate/mrs_real/rt", slope); 00068 00069 */ 00070 00071 00072 class NoiseGate: public MarSystem 00073 { 00074 private: 00075 void addControls(); 00076 void myUpdate(MarControlPtr sender); 00077 00078 mrs_real state_; 00079 mrs_real xdprev_; 00080 mrs_real gainsprev_; 00081 realvec xd_; 00082 realvec gains_; 00083 mrs_real alpha_; 00084 00085 public: 00086 NoiseGate(std::string name); 00087 ~NoiseGate(); 00088 MarSystem* clone() const; 00089 00090 void myProcess(realvec& in, realvec& out); 00091 }; 00092 00093 }//namespace Marsyas 00094 00095 #endif