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