Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/CompExp.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_COMPEXP_H
00020 #define MARSYAS_COMPEXP_H
00021 
00022 #include <marsyas/system/MarSystem.h>
00023 
00024 namespace Marsyas
00025 {
00047 /* How to use the Compressor/Expander Marsystem
00048 
00049   The system can be setup using the marsystem manager
00050     series->addMarSystem(mng.create("CompExp", "compexp"));
00051 
00052   Options: Threshold can be set to any value between -1.0 and 1
00053   Compressor  -1.0 <= thresh < 0
00054   Expander  0 <= thresh <= 1.0
00055     series->updctrl("CompExp/compexp/mrs_real/thresh", thresh);
00056 
00057   Attack time can be calculated using the following formula: at = 1 - exp(-2.2*T/t_AT)
00058   where at = attack time, T = sampling period, t_AT = time parameter 0.00016 < t_AT < 2.6 sec
00059     series->updctrl("CompExp/compexp/mrs_real/rolloff", t_AT);
00060 
00061   Release time can be calculated similar to at time: rt = 1 - exp(-2.2*T/t_RT)
00062   where rt = release time, T = sampling period, t_RT = time parameter 0.001 < t_RT < 5.0 msec
00063     series->updctrl("CompExp/compexp/mrs_real/rt", t_RT);
00064 
00065   Slope factor: 0 < slope <= 1.0
00066     series->updctrl("CompExp/compexp/mrs_real/rt", slope);
00067 */
00068 
00069 
00070 class CompExp: public MarSystem
00071 {
00072 private:
00073   void addControls();
00074   void myUpdate(MarControlPtr sender);
00075 
00076   MarControlPtr ctl_thresh;
00077   MarControlPtr ctl_slope;
00078   MarControlPtr ctl_attack;
00079   MarControlPtr ctl_release;
00080 
00081   mrs_real m_thresh;
00082   mrs_real m_thresh_log10;
00083   mrs_real m_slope;
00084   mrs_real m_k_attack;
00085   mrs_real m_k_release;
00086 
00087   realvec m_xd;
00088 
00089 public:
00090   CompExp(std::string name);
00091   ~CompExp();
00092   MarSystem* clone() const;
00093 
00094   void myProcess(realvec& in, realvec& out);
00095 };
00096 
00097 }//namespace Marsyas
00098 
00099 #endif